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 {
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) {
}
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)) {
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;
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')
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;
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
*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')
/* Skip until the next space. */
key = line;
- while (*line && !isspace(*line) && *line != '#')
+ while (*line && !TOR_ISSPACE(*line) && *line != '#')
++line;
/* Skip until the value */
else {
cp = line-1;
}
- while (cp>=val && isspace(*cp))
+ while (cp>=val && TOR_ISSPACE(*cp))
*cp-- = '\0';
if (*line == '#') {
*ok = 1;
return v;
}
- while (isspace(*cp))
+ while (TOR_ISSPACE(*cp))
++cp;
for ( ;u->unit;++u) {
if (!strcasecmp(u->unit, cp)) {
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) ||