ref: 71320bfe1d69359a5bc816b16b5c5781f6cfb55e
parent: ba4a1c07f1bc7622f8a3dcd4f2d383f4ec70fc1c
author: qwx <qwx@sciops.net>
date: Sat Sep 27 06:54:29 EDT 2025
simplified version of tolower/toupper no need for the test on plan9.
--- a/run.c
+++ b/run.c
@@ -1523,7 +1523,6 @@
Node *nextarg;
Biobuf *fp;
void flush_all(void);
- int (*test)(Rune);
Rune (*conv)(Rune);
t = ptoi(a[0]);
@@ -1584,17 +1583,10 @@
n = utflen(buf) * UTFmax + 1; /* just in case size differs... */
if ((rbuf = malloc(n)) == nil)
FATAL("out of space in %s", t == FTOUPPER ? "toupper" : "tolower");- if (t == FTOUPPER) {- test = islowerrune;
- conv = toupperrune;
- } else {- test = isupperrune;
- conv = tolowerrune;
- }
- for (p = rbuf, s = buf; *s; s += n) {- n = chartorune(&wc, s);
- if (test(wc))
- wc = conv(wc);
+ conv = t == FTOUPPER ? toupperrune : tolowerrune;
+ for (p = rbuf, s = buf; *s != '\0';) {+ s += chartorune(&wc, s);
+ wc = conv(wc);
p += runetochar(p, &wc);
}
*p = 0;
--
⑨