From: Nicholas Nethercote Date: Sat, 26 Mar 2005 04:14:01 +0000 (+0000) Subject: Make our VG_(isspace)() match libc's isspace(). And remove ISSPACE and X-Git-Tag: svn/VALGRIND_3_0_0~879 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ce81b52a840aa94d5db03e9d0ca34a0be41f695d;p=thirdparty%2Fvalgrind.git Make our VG_(isspace)() match libc's isspace(). And remove ISSPACE and VG_ISSPACE, replacing them with calls to VG_(isspace)(). git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3439 --- diff --git a/coregrind/vg_errcontext.c b/coregrind/vg_errcontext.c index 1f360b8240..26ef33cd86 100644 --- a/coregrind/vg_errcontext.c +++ b/coregrind/vg_errcontext.c @@ -713,9 +713,6 @@ void VG_(show_all_errors) ( void ) /* Get a non-blank, non-comment line of at most nBuf chars from fd. Skips leading spaces on the line. Return True if EOF was hit instead. */ - -#define VG_ISSPACE(ch) (((ch)==' ') || ((ch)=='\n') || ((ch)=='\t')) - Bool VG_(get_line) ( Int fd, Char* buf, Int nBuf ) { Char ch; @@ -724,7 +721,7 @@ Bool VG_(get_line) ( Int fd, Char* buf, Int nBuf ) /* First, read until a non-blank char appears. */ while (True) { n = VG_(read)(fd, &ch, 1); - if (n == 1 && !VG_ISSPACE(ch)) break; + if (n == 1 && !VG_(isspace)(ch)) break; if (n == 0) return True; } @@ -738,7 +735,7 @@ Bool VG_(get_line) ( Int fd, Char* buf, Int nBuf ) if (i > 0 && i == nBuf-1) i--; buf[i++] = ch; buf[i] = 0; } - while (i > 1 && VG_ISSPACE(buf[i-1])) { + while (i > 1 && VG_(isspace)(buf[i-1])) { i--; buf[i] = 0; }; diff --git a/coregrind/vg_main.c b/coregrind/vg_main.c index 31c465b32b..0ce41328f8 100644 --- a/coregrind/vg_main.c +++ b/coregrind/vg_main.c @@ -489,8 +489,6 @@ static char* get_file_clo(char* dir) # undef FLEN } -#define ISSPACE(cc) ((cc) == ' ' || (cc) == '\t' || (cc) == '\n') - static Int count_args(char* s) { Int n = 0; @@ -499,10 +497,10 @@ static Int count_args(char* s) while (True) { // We have alternating sequences: blanks, non-blanks, blanks... // count the non-blanks sequences. - while ( ISSPACE(*cp) ) cp++; + while ( VG_(isspace)(*cp) ) cp++; if ( !*cp ) break; n++; - while ( !ISSPACE(*cp) && *cp ) cp++; + while ( !VG_(isspace)(*cp) && *cp ) cp++; } } return n; @@ -516,10 +514,10 @@ static char** copy_args( char* s, char** to ) while (True) { // We have alternating sequences: blanks, non-blanks, blanks... // copy the non-blanks sequences, and add terminating '\0' - while ( ISSPACE(*cp) ) cp++; + while ( VG_(isspace)(*cp) ) cp++; if ( !*cp ) break; *to++ = cp; - while ( !ISSPACE(*cp) && *cp ) cp++; + while ( !VG_(isspace)(*cp) && *cp ) cp++; if ( *cp ) *cp++ = '\0'; // terminate if necessary if (VG_STREQ(to[-1], "--")) to--; // undo any '--' arg } @@ -527,8 +525,6 @@ static char** copy_args( char* s, char** to ) return to; } -#undef ISSPACE - // Augment command line with arguments from environment and .valgrindrc // files. static void augment_command_line(Int* vg_argc_inout, char*** vg_argv_inout) diff --git a/coregrind/vg_mylibc.c b/coregrind/vg_mylibc.c index 3240992931..65f4384123 100644 --- a/coregrind/vg_mylibc.c +++ b/coregrind/vg_mylibc.c @@ -717,7 +717,8 @@ UInt VG_(sprintf) ( Char* buf, Char *format, ... ) Bool VG_(isspace) ( Char c ) { - return (c == ' ' || c == '\n' || c == '\t' || c == 0); + return (c == ' ' || c == '\n' || c == '\t' || + c == '\f' || c == '\v' || c == '\r'); } Bool VG_(isdigit) ( Char c ) @@ -894,13 +895,18 @@ Int VG_(strcmp) ( const Char* s1, const Char* s2 ) } } +static Bool isterm ( Char c ) +{ + return ( VG_(isspace)(c) || 0 == c ); +} + Int VG_(strcmp_ws) ( const Char* s1, const Char* s2 ) { while (True) { - if (VG_(isspace)(*s1) && VG_(isspace)(*s2)) return 0; - if (VG_(isspace)(*s1)) return -1; - if (VG_(isspace)(*s2)) return 1; + if (isterm(*s1) && isterm(*s2)) return 0; + if (isterm(*s1)) return -1; + if (isterm(*s2)) return 1; if (*(UChar*)s1 < *(UChar*)s2) return -1; if (*(UChar*)s1 > *(UChar*)s2) return 1; @@ -932,9 +938,9 @@ Int VG_(strncmp_ws) ( const Char* s1, const Char* s2, Int nmax ) Int n = 0; while (True) { if (n >= nmax) return 0; - if (VG_(isspace)(*s1) && VG_(isspace)(*s2)) return 0; - if (VG_(isspace)(*s1)) return -1; - if (VG_(isspace)(*s2)) return 1; + if (isterm(*s1) && isterm(*s2)) return 0; + if (isterm(*s1)) return -1; + if (isterm(*s2)) return 1; if (*(UChar*)s1 < *(UChar*)s2) return -1; if (*(UChar*)s1 > *(UChar*)s2) return 1;