summaryrefslogtreecommitdiff
path: root/Src/Zle
diff options
context:
space:
mode:
authorOliver Kiddle <opk@zsh.org>2022-12-16 23:22:33 +0100
committerOliver Kiddle <opk@zsh.org>2022-12-16 23:28:10 +0100
commita73c705b0c864a9ce042fca6e72e0c92d4ad8237 (patch)
tree6ea60926217bfc66140a8f60bbc8c37f36396ea2 /Src/Zle
parent7fb6c133bfdf445b4478897adc142ed7d07b5fd6 (diff)
downloadzsh-a73c705b0c864a9ce042fca6e72e0c92d4ad8237.tar.gz
zsh-a73c705b0c864a9ce042fca6e72e0c92d4ad8237.zip
51212: remove STOUC() macro
This served as a workaround for ancient compilers where casts to unsigned char were broken.
Diffstat (limited to 'Src/Zle')
-rw-r--r--Src/Zle/compcore.c6
-rw-r--r--Src/Zle/complete.c2
-rw-r--r--Src/Zle/complist.c12
-rw-r--r--Src/Zle/zle.h2
-rw-r--r--Src/Zle/zle_keymap.c22
-rw-r--r--Src/Zle/zle_main.c4
-rw-r--r--Src/Zle/zle_thingy.c4
-rw-r--r--Src/Zle/zle_utils.c4
8 files changed, 28 insertions, 28 deletions
diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index 4ac5d089f..64a860fa3 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -2898,9 +2898,9 @@ add_match_data(int alt, char *str, char *orig, Cline line,
*t++ = '$';
*t++ = '\'';
*t++ = '\\';
- *t++ = '0' + ((STOUC(curchar) >> 6) & 7);
- *t++ = '0' + ((STOUC(curchar) >> 3) & 7);
- *t++ = '0' + (STOUC(curchar) & 7);
+ *t++ = '0' + (((unsigned char) curchar >> 6) & 7);
+ *t++ = '0' + (((unsigned char) curchar >> 3) & 7);
+ *t++ = '0' + ((unsigned char) curchar & 7);
*t++ = '\'';
} while (cnt == MB_INCOMPLETE && fs < fe);
/* Scanning restarts from the spot after the char we skipped. */
diff --git a/Src/Zle/complete.c b/Src/Zle/complete.c
index 67a60963e..96ad7b3f1 100644
--- a/Src/Zle/complete.c
+++ b/Src/Zle/complete.c
@@ -518,7 +518,7 @@ parse_class(Cpattern p, char *iptr)
ch = range_type((char *)iptr, nptr-iptr);
iptr = nptr + 2;
if (ch != PP_UNKWN)
- *optr++ = STOUC(Meta) + ch;
+ *optr++ = (unsigned char) Meta + ch;
} else {
/* characters stay metafied */
char *ptr1 = iptr;
diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index 0dc64db6a..6e0eac31f 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -291,12 +291,12 @@ getcolval(char *s, int multi)
case '?': *p = '\177'; break;
default:
if (*s >= '0' && *s <= '7') {
- int i = STOUC(*s);
+ int i = (unsigned char) *s;
if (*++s >= '0' && *s <= '7') {
- i = (i * 8) + STOUC(*s);
+ i = (i * 8) + (unsigned char) *s;
if (*++s >= '0' && *s <= '7')
- i = (i * 8) + STOUC(*s);
+ i = (i * 8) + (unsigned char) *s;
}
*p = (char) i;
} else
@@ -305,7 +305,7 @@ getcolval(char *s, int multi)
} else if (*s == '^') {
if ((s[1] >= '@' && s[1] <= '_') ||
(s[1] >= 'a' && s[1] <= 'z'))
- *p = (char) (STOUC(*s) & ~0x60);
+ *p = (char) ((unsigned char) *s & ~0x60);
else if (s[1] == '?')
*p = '\177';
else {
@@ -794,7 +794,7 @@ clnicezputs(int do_colors, char *s, int ml)
*/
for (t = sptr; *t; t++) {
/* Input is metafied... */
- int nc = (*t == Meta) ? STOUC(*++t ^ 32) : STOUC(*t);
+ int nc = (*t == Meta) ? (unsigned char) (*++t ^ 32) : (unsigned char) *t;
/* Is the screen full? */
if (ml == mlend - 1 && col == zterm_columns - 1) {
mlprinted = ml - oml;
@@ -852,7 +852,7 @@ clnicezputs(int do_colors, char *s, int ml)
cc = *s++ ^ 32;
for (t = nicechar(cc); *t; t++) {
- int nc = (*t == Meta) ? STOUC(*++t ^ 32) : STOUC(*t);
+ int nc = (*t == Meta) ? (unsigned char) (*++t ^ 32) : (unsigned char) *t;
if (ml == mlend - 1 && col == zterm_columns - 1) {
mlprinted = ml - oml;
return 0;
diff --git a/Src/Zle/zle.h b/Src/Zle/zle.h
index f59545397..97cc7d797 100644
--- a/Src/Zle/zle.h
+++ b/Src/Zle/zle.h
@@ -526,7 +526,7 @@ typedef REFRESH_ELEMENT *REFRESH_STRING;
((int)((unsigned)(x) - ZSH_INVALID_WCHAR_BASE))
/* Turn a single byte character into a private wide character */
#define ZSH_CHAR_TO_INVALID_WCHAR(x) \
- ((wchar_t)(STOUC(x) + ZSH_INVALID_WCHAR_BASE))
+ ((wchar_t)((unsigned char) x + ZSH_INVALID_WCHAR_BASE))
#endif
diff --git a/Src/Zle/zle_keymap.c b/Src/Zle/zle_keymap.c
index 48691e8d0..ec8dd031e 100644
--- a/Src/Zle/zle_keymap.c
+++ b/Src/Zle/zle_keymap.c
@@ -404,7 +404,7 @@ static void
scankeys(HashNode hn, UNUSED(int flags))
{
Key k = (Key) hn;
- int f = k->nam[0] == Meta ? STOUC(k->nam[1])^32 : STOUC(k->nam[0]);
+ int f = k->nam[0] == Meta ? (unsigned char) k->nam[1]^32 : (unsigned char) k->nam[0];
char m[3];
while(skm_last < f) {
@@ -566,7 +566,7 @@ mod_export int
bindkey(Keymap km, const char *seq, Thingy bind, char *str)
{
Key k;
- int f = seq[0] == Meta ? STOUC(seq[1])^32 : STOUC(seq[0]);
+ int f = seq[0] == Meta ? (unsigned char) seq[1]^32 : (unsigned char) seq[0];
char *buf, *ptr;
if(km->flags & KM_IMMUTABLE)
@@ -661,7 +661,7 @@ keybind(Keymap km, char *seq, char **strp)
Key k;
if(ztrlen(seq) == 1) {
- int f = seq[0] == Meta ? STOUC(seq[1])^32 : STOUC(seq[0]);
+ int f = seq[0] == Meta ? (unsigned char) seq[1]^32 : (unsigned char) seq[0];
Thingy bind = km->first[f];
if(bind)
@@ -687,7 +687,7 @@ keyisprefix(Keymap km, char *seq)
if(!*seq)
return 1;
if(ztrlen(seq) == 1) {
- int f = seq[0] == Meta ? STOUC(seq[1])^32 : STOUC(seq[0]);
+ int f = seq[0] == Meta ? (unsigned char) seq[1]^32 : (unsigned char) seq[0];
if(km->first[f])
return 0;
@@ -764,10 +764,10 @@ bin_bindkey(char *name, char **argv, Options ops, UNUSED(int func))
int n;
/* select operation and ensure no clashing arguments */
- for(op = opns; op->o && !OPT_ISSET(ops,STOUC(op->o)); op++) ;
+ for(op = opns; op->o && !OPT_ISSET(ops,(unsigned char) op->o); op++) ;
if(op->o)
for(opp = op; (++opp)->o; )
- if(OPT_ISSET(ops,STOUC(opp->o))) {
+ if(OPT_ISSET(ops,(unsigned char) opp->o)) {
zwarnnam(name, "incompatible operation selection options");
return 1;
}
@@ -1049,7 +1049,7 @@ bin_bindkey_bind(char *name, char *kmname, Keymap km, char **argv, Options ops,
char m[3];
if(len < 2 || len > 2 + (bseq[1] == '-') ||
- (first = STOUC(bseq[0])) > (last = STOUC(bseq[len - 1]))) {
+ (first = (unsigned char) bseq[0]) > (last = (unsigned char) bseq[len - 1])) {
zwarnnam(name, "malformed key range `%s'", useq);
ret = 1;
} else {
@@ -1149,8 +1149,8 @@ scanbindlist(char *seq, Thingy bind, char *str, void *magic)
if(bind == bs->bind && (bind || !strcmp(str, bs->str)) &&
ztrlen(seq) == 1 && ztrlen(bs->lastseq) == 1) {
int l = bs->lastseq[1] ?
- STOUC(bs->lastseq[1]) ^ 32 : STOUC(bs->lastseq[0]);
- int t = seq[1] ? STOUC(seq[1]) ^ 32 : STOUC(seq[0]);
+ (unsigned char) bs->lastseq[1] ^ 32 : (unsigned char) bs->lastseq[0];
+ int t = seq[1] ? (unsigned char) seq[1] ^ 32 : (unsigned char) seq[0];
if(t == l + 1) {
zsfree(bs->lastseq);
@@ -1526,10 +1526,10 @@ getrestchar_keybuf(void)
*/
while (1) {
if (bufind < buflen) {
- c = STOUC(keybuf[bufind++]);
+ c = (unsigned char) keybuf[bufind++];
if (c == Meta) {
DPUTS(bufind == buflen, "Meta at end of keybuf");
- c = STOUC(keybuf[bufind++]) ^ 32;
+ c = (unsigned char) keybuf[bufind++] ^ 32;
}
} else {
/*
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index 9edf30e01..40b902901 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -876,7 +876,7 @@ getbyte(long do_keytmout, int *timeout, int full)
#endif
if (kungetct)
- ret = STOUC(kungetbuf[--kungetct]);
+ ret = (unsigned char) kungetbuf[--kungetct];
else {
for (;;) {
int q = queue_signal_level();
@@ -940,7 +940,7 @@ getbyte(long do_keytmout, int *timeout, int full)
else if (cc == '\n')
cc = '\r';
- ret = STOUC(cc);
+ ret = (unsigned char) cc;
}
/*
* curvichg.buf is raw bytes, not wide characters, so is dealt
diff --git a/Src/Zle/zle_thingy.c b/Src/Zle/zle_thingy.c
index cd3f2c356..1b036a8a0 100644
--- a/Src/Zle/zle_thingy.c
+++ b/Src/Zle/zle_thingy.c
@@ -366,10 +366,10 @@ bin_zle(char *name, char **args, Options ops, UNUSED(int func))
int n;
/* select operation and ensure no clashing arguments */
- for(op = opns; op->o && !OPT_ISSET(ops,STOUC(op->o)); op++) ;
+ for(op = opns; op->o && !OPT_ISSET(ops, (unsigned char) op->o); op++) ;
if(op->o)
for(opp = op; (++opp)->o; )
- if(OPT_ISSET(ops,STOUC(opp->o))) {
+ if(OPT_ISSET(ops, (unsigned char) opp->o)) {
zwarnnam(name, "incompatible operation selection options");
return 1;
}
diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c
index 3d9017dcf..2536e9faa 100644
--- a/Src/Zle/zle_utils.c
+++ b/Src/Zle/zle_utils.c
@@ -1265,7 +1265,7 @@ bindztrdup(char *str)
char *buf, *ptr, *ret;
for(ptr = str; *ptr; ptr++) {
- c = *ptr == Meta ? STOUC(*++ptr) ^ 32 : STOUC(*ptr);
+ c = *ptr == Meta ? (unsigned char) *++ptr ^ 32 : (unsigned char) *ptr;
if(c & 0x80) {
len += 3;
c &= 0x7f;
@@ -1279,7 +1279,7 @@ bindztrdup(char *str)
}
ptr = buf = zalloc(len);
for(; *str; str++) {
- c = *str == Meta ? STOUC(*++str) ^ 32 : STOUC(*str);
+ c = *str == Meta ? (unsigned char) *++str ^ 32 : (unsigned char) *str;
if(c & 0x80) {
*ptr++ = '\\';
*ptr++ = 'M';