diff --git a/lib/libedit/chared.c b/lib/libedit/chared.c index 62e2f6a22219..b8acf510b412 100644 --- a/lib/libedit/chared.c +++ b/lib/libedit/chared.c @@ -148,7 +148,7 @@ protected int ce__isword(p) int p; { - return isalpha(p) || isdigit(p) || strchr("*?_-.[]~=", p) != NULL; + return isalpha((unsigned char) p) || isdigit((unsigned char) p) || strchr("*?_-.[]~=", p) != NULL; } @@ -159,7 +159,7 @@ protected int cv__isword(p) int p; { - return !isspace(p); + return !isspace((unsigned char) p); } diff --git a/lib/libedit/common.c b/lib/libedit/common.c index c8be2b79ec44..a321c52cf11c 100644 --- a/lib/libedit/common.c +++ b/lib/libedit/common.c @@ -256,7 +256,7 @@ ed_move_to_beg(el, c) if (el->el_map.type == MAP_VI) { /* We want FIRST non space character */ - while (isspace(*el->el_line.cursor)) + while (isspace((unsigned char) *el->el_line.cursor)) el->el_line.cursor++; if (el->el_chared.c_vcmd.action & DELETE) { cv_delfini(el); @@ -408,7 +408,7 @@ ed_digit(el, c) EditLine *el; int c; { - if (!isdigit(c)) + if (!isdigit((unsigned char) c)) return CC_ERROR; if (el->el_state.doingarg) { @@ -451,7 +451,7 @@ ed_argument_digit(el, c) EditLine *el; register int c; { - if (!isdigit(c)) + if (!isdigit((unsigned char) c)) return CC_ERROR; if (el->el_state.doingarg) { diff --git a/lib/libedit/emacs.c b/lib/libedit/emacs.c index a3a19759f00c..d84c36022317 100644 --- a/lib/libedit/emacs.c +++ b/lib/libedit/emacs.c @@ -298,8 +298,8 @@ em_upper_case(el, c) el->el_state.argument, ce__isword); for (cp = el->el_line.cursor; cp < ep; cp++) - if (islower(*cp)) - *cp = toupper(*cp); + if (islower((unsigned char)*cp)) + *cp = toupper((unsigned char)*cp); el->el_line.cursor = ep; if (el->el_line.cursor > el->el_line.lastchar) @@ -324,16 +324,16 @@ em_capitol_case(el, c) el->el_state.argument, ce__isword); for (cp = el->el_line.cursor; cp < ep; cp++) { - if (isalpha(*cp)) { - if (islower(*cp)) - *cp = toupper(*cp); + if (isalpha((unsigned char)*cp)) { + if (islower((unsigned char)*cp)) + *cp = toupper((unsigned char)*cp); cp++; break; } } for (; cp < ep; cp++) - if (isupper(*cp)) - *cp = tolower(*cp); + if (isupper((unsigned char)*cp)) + *cp = tolower((unsigned char)*cp); el->el_line.cursor = ep; if (el->el_line.cursor > el->el_line.lastchar) @@ -357,8 +357,8 @@ em_lower_case(el, c) el->el_state.argument, ce__isword); for (cp = el->el_line.cursor; cp < ep; cp++) - if (isupper(*cp)) - *cp = tolower(*cp); + if (isupper((unsigned char)*cp)) + *cp = tolower((unsigned char)*cp); el->el_line.cursor = ep; if (el->el_line.cursor > el->el_line.lastchar) diff --git a/lib/libedit/key.c b/lib/libedit/key.c index 302b6bd68d54..a84f413b5510 100644 --- a/lib/libedit/key.c +++ b/lib/libedit/key.c @@ -640,6 +640,8 @@ key__decode_char(buf, cnt, ch) char *buf; int cnt, ch; { + ch &= 0xFF; + if (ch == 0) { buf[cnt++] = '^'; buf[cnt] = '@'; diff --git a/lib/libedit/refresh.c b/lib/libedit/refresh.c index 6ad552283317..6fc8a562b6f5 100644 --- a/lib/libedit/refresh.c +++ b/lib/libedit/refresh.c @@ -43,7 +43,6 @@ static char sccsid[] = "@(#)refresh.c 8.1 (Berkeley) 6/4/93"; */ #include "sys.h" #include -#include #include #include @@ -98,6 +97,7 @@ re_addc(el, c) int c; { c &= 0xFF; + if (isprint(c)) { re_putc(el, c); return; diff --git a/lib/libedit/vi.c b/lib/libedit/vi.c index 1a467809dd88..a9e6111993d9 100644 --- a/lib/libedit/vi.c +++ b/lib/libedit/vi.c @@ -277,7 +277,7 @@ vi_change_case(el, c) int c; { if (el->el_line.cursor < el->el_line.lastchar) { - c = *el->el_line.cursor; + c = *el->el_line.cursor & 0xFF; if (isupper(c)) *el->el_line.cursor++ = tolower(c); else if (islower(c))