diff options
-rw-r--r-- | util.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -8,6 +8,9 @@ #include "memcached.h" +/* Avoid warnings on solaris, where isspace() is an index into an array, and gcc uses signed chars */ +#define xisspace(c) isspace((unsigned char)c) + bool safe_strtoull(const char *str, uint64_t *out) { assert(out != NULL); errno = 0; @@ -16,7 +19,7 @@ bool safe_strtoull(const char *str, uint64_t *out) { unsigned long long ull = strtoull(str, &endptr, 10); if (errno == ERANGE) return false; - if (isspace(*endptr) || (*endptr == '\0' && endptr != str)) { + if (xisspace(*endptr) || (*endptr == '\0' && endptr != str)) { if ((long long) ull < 0) { /* only check for negative signs in the uncommon case when * the unsigned number is so big that it's negative as a @@ -39,7 +42,7 @@ bool safe_strtoll(const char *str, int64_t *out) { long long ll = strtoll(str, &endptr, 10); if (errno == ERANGE) return false; - if (isspace(*endptr) || (*endptr == '\0' && endptr != str)) { + if (xisspace(*endptr) || (*endptr == '\0' && endptr != str)) { *out = ll; return true; } @@ -59,7 +62,7 @@ bool safe_strtoul(const char *str, uint32_t *out) { return false; } - if (isspace(*endptr) || (*endptr == '\0' && endptr != str)) { + if (xisspace(*endptr) || (*endptr == '\0' && endptr != str)) { if ((long) l < 0) { /* only check for negative signs in the uncommon case when * the unsigned number is so big that it's negative as a @@ -83,7 +86,7 @@ bool safe_strtol(const char *str, int32_t *out) { long l = strtol(str, &endptr, 10); if (errno == ERANGE) return false; - if (isspace(*endptr) || (*endptr == '\0' && endptr != str)) { + if (xisspace(*endptr) || (*endptr == '\0' && endptr != str)) { *out = l; return true; } |