]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Solaris CC freaks out if isspace and friends get anything other than an int. We...
authorNick Mathewson <nickm@torproject.org>
Wed, 8 Dec 2004 00:42:50 +0000 (00:42 +0000)
committerNick Mathewson <nickm@torproject.org>
Wed, 8 Dec 2004 00:42:50 +0000 (00:42 +0000)
svn:r3120

src/common/compat.h
src/common/container.c
src/common/crypto.c
src/common/util.c
src/or/config.c
src/or/directory.c

index 6b718c2f53d1b3e6aef026d550f60b5ac5da5634..20c243e500c3f4d4527f8d28953585118982b662 100644 (file)
@@ -82,6 +82,10 @@ int tor_snprintf(char *str, size_t size, const char *format, ...)
      CHECK_PRINTF(3,4);
 int tor_vsnprintf(char *str, size_t size, const char *format, va_list args);
 
+#define TOR_ISSPACE(c)   isspace((int)(unsigned char)(c))
+#define TOR_ISXDIGIT(c) isxdigit((int)(unsigned char)(c))
+#define TOR_ISDIGIT(c)   isdigit((int)(unsigned char)(c))
+
 /* ===== Time compatibility */
 #if !defined(HAVE_GETTIMEOFDAY) && !defined(HAVE_STRUCT_TIMEVAL_TV_SEC)
 struct timeval {
index 69d3d2731ef19e80cbab653498549a8c4cc2b034..0055fcb476b9d8ece4cae704fe50714df9b32a7d 100644 (file)
@@ -262,7 +262,7 @@ int smartlist_split_string(smartlist_t *sl, const char *str, const char *sep,
   cp = str;
   while (1) {
     if (flags&SPLIT_SKIP_SPACE) {
-      while (isspace((int)*cp)) ++cp;
+      while (TOR_ISSPACE(*cp)) ++cp;
     }
 
     if (max>0 && n == max-1) {
@@ -279,7 +279,7 @@ int smartlist_split_string(smartlist_t *sl, const char *str, const char *sep,
     }
 
     if (flags&SPLIT_SKIP_SPACE) {
-      while (end > cp && isspace((int)*(end-1)))
+      while (end > cp && TOR_ISSPACE(*(end-1)))
         --end;
     }
     if (end != cp || !(flags&SPLIT_IGNORE_BLANK)) {
index 6d4533b5da403c470f55de8836d850285c224c73..eaf438e83588fde22844df9626c4d58a279bd43f 100644 (file)
@@ -974,11 +974,12 @@ int
 crypto_pk_check_fingerprint_syntax(const char *s)
 {
   int i;
+  const unsigned char *cp = s;
   for (i = 0; i < FINGERPRINT_LEN; ++i) {
     if ((i%5) == 4) {
-      if (!isspace((int)s[i])) return 0;
+      if (!TOR_ISSPACE(cp[i])) return 0;
     } else {
-      if (!isxdigit((int)s[i])) return 0;
+      if (!TOR_ISXDIGIT(cp[i])) return 0;
     }
   }
   if (s[FINGERPRINT_LEN]) return 0;
index 7621452448603fa376ced58f70e826d6478fab4b..162fae680fd1b53d41bb529e38ed02098b028338 100644 (file)
@@ -331,8 +331,8 @@ int strcasecmpend(const char *s1, const char *s2)
 const char *eat_whitespace(const char *s) {
   tor_assert(s);
 
-  while (isspace((int)*s) || *s == '#') {
-    while (isspace((int)*s))
+  while (TOR_ISSPACE(*s) || *s == '#') {
+    while (TOR_ISSPACE(*s))
       s++;
     if (*s == '#') { /* read to a \n or \0 */
       while (*s && *s != '\n')
@@ -358,7 +358,7 @@ const char *eat_whitespace_no_nl(const char *s) {
 const char *find_whitespace(const char *s) {
   tor_assert(s);
 
-  while (*s && !isspace((int)*s) && *s != '#')
+  while (*s && !TOR_ISSPACE(*s) && *s != '#')
     s++;
 
   return s;
@@ -427,8 +427,8 @@ tor_parse_uint64(const char *s, int base, uint64_t min,
   tor_assert(base <= 10);
   r = (uint64_t)_atoi64(s);
   endptr = (char*)s;
-  while (isspace(*endptr)) endptr++;
-  while (isdigit(*endptr)) endptr++;
+  while (TOR_ISSPACE(*endptr)) endptr++;
+  while (TOR_ISDIGIT(*endptr)) endptr++;
 #else
   r = (uint64_t)_strtoui64(s, &endptr, base);
 #endif
@@ -936,7 +936,7 @@ parse_line_from_str(char *line, char **key_out, char **value_out)
   *key_out = *value_out = key = val = NULL;
   /* Skip until the first keyword. */
   while (1) {
-    while (isspace(*line))
+    while (TOR_ISSPACE(*line))
       ++line;
     if (*line == '#') {
       while (*line && *line != '\n')
@@ -953,7 +953,7 @@ parse_line_from_str(char *line, char **key_out, char **value_out)
 
   /* Skip until the next space. */
   key = line;
-  while (*line && !isspace(*line) && *line != '#')
+  while (*line && !TOR_ISSPACE(*line) && *line != '#')
     ++line;
 
   /* Skip until the value */
@@ -969,7 +969,7 @@ parse_line_from_str(char *line, char **key_out, char **value_out)
   else {
     cp = line-1;
   }
-  while (cp>=val && isspace(*cp))
+  while (cp>=val && TOR_ISSPACE(*cp))
     *cp-- = '\0';
 
   if (*line == '#') {
index 912ab8c83deadbbf6053cea6e5deca0131b29741..7210a5d7270ace81494183f831303c6cec0d6d7f 100644 (file)
@@ -2348,7 +2348,7 @@ config_parse_units(const char *val, struct unit_table_t *u, int *ok)
     *ok = 1;
     return v;
   }
-  while (isspace(*cp))
+  while (TOR_ISSPACE(*cp))
     ++cp;
   for ( ;u->unit;++u) {
     if (!strcasecmp(u->unit, cp)) {
index 66c30960abc7c00ae50a26c33c642bdad398e6ca..1408e15c44cd6162e9a75f993526a7b10ffa12c9 100644 (file)
@@ -472,7 +472,7 @@ parse_http_response(const char *headers, int *code, time_t *date,
   tor_assert(headers);
   tor_assert(code);
 
-  while (isspace((int)*headers)) headers++; /* tolerate leading whitespace */
+  while (TOR_ISSPACE(*headers)) headers++; /* tolerate leading whitespace */
 
   if (sscanf(headers, "HTTP/1.%d %d", &n1, &n2) < 2 ||
       (n1 != 0 && n1 != 1) ||