diff options
author | ache <ache@FreeBSD.org> | 2009-09-02 04:26:34 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 2009-09-02 04:26:34 +0000 |
commit | bbd87e6bfdf20fe240a7ed65fa828ec7d64c0e7d (patch) | |
tree | e4d499752076fd36461f41a1d8a9f84878b3d95f /contrib/ee | |
parent | 0c6bbf27ef4317844d6905d37adbcadcf4f392cc (diff) | |
download | FreeBSD-src-bbd87e6bfdf20fe240a7ed65fa828ec7d64c0e7d.zip FreeBSD-src-bbd87e6bfdf20fe240a7ed65fa828ec7d64c0e7d.tar.gz |
1) Use isprint() instead of hardcoded values to detect non-printable.
2) Use (unsigned char) cast in waddch() calls.
It fix highlighting bug: sign extension of 8bit to the attributes area.
3) Use setlocale() in any case.
Diffstat (limited to 'contrib/ee')
-rwxr-xr-x | contrib/ee/ee.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/contrib/ee/ee.c b/contrib/ee/ee.c index 070bb97..bd392a7 100755 --- a/contrib/ee/ee.c +++ b/contrib/ee/ee.c @@ -726,7 +726,7 @@ int character; /* new character */ } *point = character; /* insert new character */ wclrtoeol(text_win); - if (((character >= 0) && (character < ' ')) || (character >= 127)) /* check for TAB character*/ + if (!isprint((unsigned char)character)) /* check for TAB character*/ { scr_pos = scr_horz += out_char(text_win, character, scr_horz); point++; @@ -734,7 +734,7 @@ int character; /* new character */ } else { - waddch(text_win, character); + waddch(text_win, (unsigned char)character); scr_pos = ++scr_horz; point++; position ++; @@ -969,17 +969,17 @@ int column; } else { - waddch(window, (char)character ); + waddch(window, (unsigned char)character ); return(1); } } else { - waddch(window, (char)character); + waddch(window, (unsigned char)character); return(1); } for (i2 = 0; (string[i2] != '\0') && (((column+i2+1)-horiz_offset) < last_col); i2++) - waddch(window, string[i2]); + waddch(window, (unsigned char)string[i2]); return(strlen(string)); } @@ -1044,7 +1044,7 @@ int length; /* length (in bytes) of line */ wclrtoeol(text_win); while ((posit < length) && (column <= last_col)) { - if ((*temp < 32) || (*temp >= 127)) + if (!isprint(*temp)) { column += len_char(*temp, abs_column); abs_column += out_char(text_win, *temp, abs_column); @@ -1923,13 +1923,13 @@ int advance; /* if true, skip leading spaces and tabs */ } *nam_str = in; g_pos++; - if (((in < ' ') || (in > 126)) && (g_horz < (last_col - 1))) + if (!isprint((unsigned char)in) && (g_horz < (last_col - 1))) g_horz += out_char(com_win, in, g_horz); else { g_horz++; if (g_horz < (last_col - 1)) - waddch(com_win, in); + waddch(com_win, (unsigned char)in); } nam_str++; } @@ -5085,8 +5085,8 @@ strings_init() { int counter; -#ifndef NO_CATGETS setlocale(LC_ALL, ""); +#ifndef NO_CATGETS catalog = catopen("ee", NL_CAT_LOCALE); #endif /* NO_CATGETS */ |