ctype: portability, sign extension and cleanup fixes
This commit is contained in:
parent
189c9c5d47
commit
21e75aae31
@ -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;
|
||||
|
@ -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++ = '\\';
|
||||
|
@ -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():
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user