VG_ISSPACE, replacing them with calls to VG_(isspace)().
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3439
/* 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;
/* 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;
}
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;
};
# undef FLEN
}
-#define ISSPACE(cc) ((cc) == ' ' || (cc) == '\t' || (cc) == '\n')
-
static Int count_args(char* s)
{
Int n = 0;
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;
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
}
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)
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 )
}
}
+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;
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;