From owner-svn-src-all@FreeBSD.ORG Sun Jun 27 03:06:21 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0A3CF106564A; Sun, 27 Jun 2010 03:06:21 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id EBFFA8FC08; Sun, 27 Jun 2010 03:06:20 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o5R36KCV060004; Sun, 27 Jun 2010 03:06:20 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o5R36KCF060001; Sun, 27 Jun 2010 03:06:20 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201006270306.o5R36KCF060001@svn.freebsd.org> From: Xin LI Date: Sun, 27 Jun 2010 03:06:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r209547 - in stable/8: contrib/ee usr.bin/ee X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Jun 2010 03:06:21 -0000 Author: delphij Date: Sun Jun 27 03:06:20 2010 New Revision: 209547 URL: http://svn.freebsd.org/changeset/base/209547 Log: MFC 196750,196751,196818,196819 (ache@): 196750: 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. 196751: Move out of NO_CATGETS define too (as setlocale() in prev. commit) 196818: 1) Remove single occurance of HAS_CTYPE ifdef, ctype functions used here for a long time and needs their header in anycase. 2) Add (unsigned char) casts to more ctype macros. 3) Simplify menu input handling using ctype instead of range unguarded hardcoded tricks. 196819: Remove single occurance of HAS_CTYPE ifdef, ctype functions used here for a long time and needs their header in anycase. Requested by: Patrick Lamaiziere Ok'ed by: ache Modified: stable/8/contrib/ee/ee.c stable/8/usr.bin/ee/Makefile Directory Properties: stable/8/contrib/ee/ (props changed) stable/8/usr.bin/ee/ (props changed) Modified: stable/8/contrib/ee/ee.c ============================================================================== --- stable/8/contrib/ee/ee.c Sun Jun 27 02:30:19 2010 (r209546) +++ stable/8/contrib/ee/ee.c Sun Jun 27 03:06:20 2010 (r209547) @@ -72,10 +72,7 @@ char *version = "@(#) ee, version " EE_ #include #endif -#ifdef HAS_CTYPE #include -#endif - #include #include #include @@ -83,6 +80,7 @@ char *version = "@(#) ee, version " EE_ #include #include #include +#include #ifdef HAS_SYS_WAIT #include @@ -100,9 +98,7 @@ char *version = "@(#) ee, version " EE_ #include #endif - #ifndef NO_CATGETS -#include #include nl_catd catalog; @@ -726,7 +722,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 +730,7 @@ int character; /* new character */ } else { - waddch(text_win, character); + waddch(text_win, (unsigned char)character); scr_pos = ++scr_horz; point++; position ++; @@ -969,17 +965,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 +1040,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 +1919,13 @@ int advance; /* if true, skip leading s } *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++; } @@ -1974,7 +1970,7 @@ int sensitive; } else { - if (toupper(*strng1) != toupper(*strng2)) + if (toupper((unsigned char)*strng1) != toupper((unsigned char)*strng2)) equal = FALSE; } strng1++; @@ -2446,7 +2442,7 @@ int noverify; if ((text_changes) && (!noverify)) { ans = get_string(changes_made_prompt, TRUE); - if (toupper(*ans) == toupper(*yes_char)) + if (toupper((unsigned char)*ans) == toupper((unsigned char)*yes_char)) text_changes = FALSE; else return(0); @@ -2523,7 +2519,7 @@ int warn_if_exists; if ((temp_fp = fopen(file_name, "r"))) { tmp_point = get_string(file_exists_prompt, TRUE); - if (toupper(*tmp_point) == toupper(*yes_char)) + if (toupper((unsigned char)*tmp_point) == toupper((unsigned char)*yes_char)) write_flag = TRUE; else write_flag = FALSE; @@ -3438,14 +3434,13 @@ struct menu_entries menu_list[]; if (input == -1) exit(0); - if (((tolower(input) >= 'a') && (tolower(input) <= 'z')) || - ((input >= '0') && (input <= '9'))) + if (isascii(input) && isalnum(input)) { - if ((tolower(input) >= 'a') && (tolower(input) <= 'z')) + if (isalpha(input)) { temp = 1 + tolower(input) - 'a'; } - else if ((input >= '0') && (input <= '9')) + else if (isdigit(input)) { temp = (2 + 'z' - 'a') + (input - '0'); } @@ -5085,8 +5080,8 @@ strings_init() { int counter; -#ifndef NO_CATGETS setlocale(LC_ALL, ""); +#ifndef NO_CATGETS catalog = catopen("ee", NL_CAT_LOCALE); #endif /* NO_CATGETS */ Modified: stable/8/usr.bin/ee/Makefile ============================================================================== --- stable/8/usr.bin/ee/Makefile Sun Jun 27 02:30:19 2010 (r209546) +++ stable/8/usr.bin/ee/Makefile Sun Jun 27 03:06:20 2010 (r209547) @@ -3,7 +3,7 @@ .PATH: ${.CURDIR}/../../contrib/ee CFLAGS+= -DHAS_NCURSES -DHAS_UNISTD -DHAS_STDARG -DHAS_STDLIB \ - -DHAS_CTYPE -DHAS_SYS_WAIT + -DHAS_SYS_WAIT PROG= ee LINKS= ${BINDIR}/ee ${BINDIR}/ree ${BINDIR}/ee ${BINDIR}/edit