Permalink
Browse files

Fix compilation issue on Solaris 9 wrt isspace() macro - Resolves iss…

…ue 111
  • Loading branch information...
lindner authored and trondn committed Jan 2, 2010
1 parent b4936c4 commit 39f6eeb3f50a25241da389b18f89a54daa659d50
Showing with 7 additions and 4 deletions.
  1. +7 −4 util.c
View
11 util.c
@@ -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;
}

0 comments on commit 39f6eeb

Please sign in to comment.