]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Make our VG_(isspace)() match libc's isspace(). And remove ISSPACE and
authorNicholas Nethercote <njn@valgrind.org>
Sat, 26 Mar 2005 04:14:01 +0000 (04:14 +0000)
committerNicholas Nethercote <njn@valgrind.org>
Sat, 26 Mar 2005 04:14:01 +0000 (04:14 +0000)
VG_ISSPACE, replacing them with calls to VG_(isspace)().

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3439

coregrind/vg_errcontext.c
coregrind/vg_main.c
coregrind/vg_mylibc.c

index 1f360b8240558b2a31230a64a40ec412efff6177..26ef33cd86b5769e73e3e16b0f98229e99f199be 100644 (file)
@@ -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; 
       };
 
index 31c465b32bd2fc8c0935b66a4cfa0fa2ffe28c7e..0ce41328f806bd28f799407d57b8ecf721206d37 100644 (file)
@@ -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)
index 3240992931199e5f964068e3fe578d5597fce303..65f4384123ce973d5230b48ff9e22391db8d9185 100644 (file)
@@ -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;