diff options
author | ache <ache@FreeBSD.org> | 1997-06-27 11:50:56 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1997-06-27 11:50:56 +0000 |
commit | 21e75aae3104eb74e54c62aaf5c810755d92d17e (patch) | |
tree | c115335d4586e736fda1900f600c892e54c4a7db | |
parent | 189c9c5d470c401df32c18a99d4ce6ae09571f19 (diff) | |
download | FreeBSD-src-21e75aae3104eb74e54c62aaf5c810755d92d17e.zip FreeBSD-src-21e75aae3104eb74e54c62aaf5c810755d92d17e.tar.gz |
ctype: portability, sign extension and cleanup fixes
-rw-r--r-- | lib/libedit/chared.c | 6 | ||||
-rw-r--r-- | lib/libedit/key.c | 8 | ||||
-rw-r--r-- | lib/libedit/parse.c | 4 | ||||
-rw-r--r-- | lib/libedit/refresh.c | 13 | ||||
-rw-r--r-- | lib/libedit/vi.c | 2 |
5 files changed, 16 insertions, 17 deletions
diff --git a/lib/libedit/chared.c b/lib/libedit/chared.c index b8acf51..dcd189c 100644 --- a/lib/libedit/chared.c +++ b/lib/libedit/chared.c @@ -575,8 +575,8 @@ c_gets(el, buf) if (el_getc(el, &ch) != 1) return ed_end_of_file(el, 0); switch (ch) { - case 0010: /* Delete and backspace */ - case 0177: + case '\010': /* Delete and backspace */ + case '\177': if (len > 1) { *el->el_line.cursor-- = '\0'; el->el_line.lastchar = el->el_line.cursor; @@ -592,7 +592,7 @@ c_gets(el, buf) ch = 0; break; - case 0033: /* ESC */ + case '\033': /* ESC */ case '\r': /* Newline */ case '\n': break; diff --git a/lib/libedit/key.c b/lib/libedit/key.c index a84f413..3da65d5 100644 --- a/lib/libedit/key.c +++ b/lib/libedit/key.c @@ -640,7 +640,7 @@ key__decode_char(buf, cnt, ch) char *buf; int cnt, ch; { - ch &= 0xFF; + ch = (unsigned char)ch; if (ch == 0) { buf[cnt++] = '^'; @@ -650,10 +650,10 @@ key__decode_char(buf, cnt, ch) if (iscntrl(ch)) { buf[cnt++] = '^'; - if (ch == '\177') + if (ch == 0177) buf[cnt] = '?'; else - buf[cnt] = ch | 0100; + buf[cnt] = toascii(ch) | 0100; } else if (ch == '^') { buf[cnt++] = '\\'; @@ -704,7 +704,7 @@ key__decode_str(str, buf, sep) if (*p == '\177') *b++ = '?'; else - *b++ = *p | 0100; + *b++ = toascii(*p) | 0100; } else if (*p == '^' || *p == '\\') { *b++ = '\\'; diff --git a/lib/libedit/parse.c b/lib/libedit/parse.c index 751cc19..dd5bd94 100644 --- a/lib/libedit/parse.c +++ b/lib/libedit/parse.c @@ -193,14 +193,14 @@ parse__escape(ptr) break; } } - else if (*p == '^' && isalpha((unsigned char) p[1])) { + else if (*p == '^' && isascii(p[1]) && (p[1] == '?' || isalpha(p[1]))) { p++; c = (*p == '?') ? '\177' : (*p & 0237); } else c = *p; *ptr = ++p; - return c; + return (unsigned char)c; } /* parse__string(): diff --git a/lib/libedit/refresh.c b/lib/libedit/refresh.c index 46dbe8b..6c3ee93 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 <stdio.h> -#include <ctype.h> #include <unistd.h> #include <string.h> @@ -97,7 +96,7 @@ re_addc(el, c) EditLine *el; int c; { - c &= 0xFF; + c = (unsigned char)c; if (isprint(c)) { re_putc(el, c); @@ -118,11 +117,11 @@ re_addc(el, c) } else if (iscntrl(c)) { re_putc(el, '^'); - if (c == '\177') + if (c == 0177) re_putc(el, '?'); else /* uncontrolify it; works only for iso8859-1 like sets */ - re_putc(el, (c | 0100)); + re_putc(el, (toascii(c) | 0100)); } else { re_putc(el, '\\'); @@ -876,7 +875,7 @@ re_refresh_cursor(el) /* do input buffer to el->el_line.cursor */ for (cp = el->el_line.buffer; cp < el->el_line.cursor; cp++) { - c = *cp & 0xFF; + c = (unsigned char)*cp; h++; /* all chars at least this long */ if (c == '\n') { /* handle newline in data part too */ @@ -949,7 +948,7 @@ re_fastaddc(el) { int c; - c = el->el_line.cursor[-1] & 0xFF; + c = (unsigned char)el->el_line.cursor[-1]; if (c == '\t' || el->el_line.cursor != el->el_line.lastchar) { re_refresh(el); /* too hard to handle */ @@ -957,7 +956,7 @@ re_fastaddc(el) } /* else (only do at end of line, no TAB) */ if (iscntrl(c)) { /* if control char, do caret */ - char mc = (c == '\177') ? '?' : (c | 0100); + char mc = (c == 0177) ? '?' : (toascii(c) | 0100); re_fastputc(el, '^'); re_fastputc(el, mc); } diff --git a/lib/libedit/vi.c b/lib/libedit/vi.c index a9e6111..3a8ef05 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 & 0xFF; + c = (unsigned char)*el->el_line.cursor; if (isupper(c)) *el->el_line.cursor++ = tolower(c); else if (islower(c)) |