Skip to content

Commit 39f6eeb

Browse files
lindnertrondn
authored andcommitted
Fix compilation issue on Solaris 9 wrt isspace() macro - Resolves issue 111
1 parent b4936c4 commit 39f6eeb

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

util.c

+7-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
#include "memcached.h"
1010

11+
/* Avoid warnings on solaris, where isspace() is an index into an array, and gcc uses signed chars */
12+
#define xisspace(c) isspace((unsigned char)c)
13+
1114
bool safe_strtoull(const char *str, uint64_t *out) {
1215
assert(out != NULL);
1316
errno = 0;
@@ -16,7 +19,7 @@ bool safe_strtoull(const char *str, uint64_t *out) {
1619
unsigned long long ull = strtoull(str, &endptr, 10);
1720
if (errno == ERANGE)
1821
return false;
19-
if (isspace(*endptr) || (*endptr == '\0' && endptr != str)) {
22+
if (xisspace(*endptr) || (*endptr == '\0' && endptr != str)) {
2023
if ((long long) ull < 0) {
2124
/* only check for negative signs in the uncommon case when
2225
* 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) {
3942
long long ll = strtoll(str, &endptr, 10);
4043
if (errno == ERANGE)
4144
return false;
42-
if (isspace(*endptr) || (*endptr == '\0' && endptr != str)) {
45+
if (xisspace(*endptr) || (*endptr == '\0' && endptr != str)) {
4346
*out = ll;
4447
return true;
4548
}
@@ -59,7 +62,7 @@ bool safe_strtoul(const char *str, uint32_t *out) {
5962
return false;
6063
}
6164

62-
if (isspace(*endptr) || (*endptr == '\0' && endptr != str)) {
65+
if (xisspace(*endptr) || (*endptr == '\0' && endptr != str)) {
6366
if ((long) l < 0) {
6467
/* only check for negative signs in the uncommon case when
6568
* 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) {
8386
long l = strtol(str, &endptr, 10);
8487
if (errno == ERANGE)
8588
return false;
86-
if (isspace(*endptr) || (*endptr == '\0' && endptr != str)) {
89+
if (xisspace(*endptr) || (*endptr == '\0' && endptr != str)) {
8790
*out = l;
8891
return true;
8992
}

0 commit comments

Comments
 (0)