summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornjn <njn@a5019735-40e9-0310-863c-91ae7b9d1cf9>2005-03-26 04:14:01 +0000
committernjn <njn@a5019735-40e9-0310-863c-91ae7b9d1cf9>2005-03-26 04:14:01 +0000
commit0c0f32a31a69dbec390176988551a50ccee30f75 (patch)
treeea48651b8ab18a501f051365530a7c798ae80c1b
parentd13e5e636cb9f593b39a28b187ced8954ce1889f (diff)
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 a5019735-40e9-0310-863c-91ae7b9d1cf9
-rw-r--r--coregrind/vg_errcontext.c7
-rw-r--r--coregrind/vg_main.c12
-rw-r--r--coregrind/vg_mylibc.c20
3 files changed, 19 insertions, 20 deletions
diff --git a/coregrind/vg_errcontext.c b/coregrind/vg_errcontext.c
index 1f360b82..26ef33cd 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 31c465b3..0ce41328 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 32409929..65f43841 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;