Skip to content

Commit

Permalink
Fix compilation issue on Solaris 9 wrt isspace() macro - Resolves iss…
Browse files Browse the repository at this point in the history
…ue 111
  • Loading branch information
lindner authored and trondn committed Sep 14, 2010
1 parent b4936c4 commit 39f6eeb
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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;
}
Expand All @@ -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
Expand All @@ -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;
}
Expand Down

0 comments on commit 39f6eeb

Please sign in to comment.