8
8
9
9
#include "memcached.h"
10
10
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
+
11
14
bool safe_strtoull (const char * str , uint64_t * out ) {
12
15
assert (out != NULL );
13
16
errno = 0 ;
@@ -16,7 +19,7 @@ bool safe_strtoull(const char *str, uint64_t *out) {
16
19
unsigned long long ull = strtoull (str , & endptr , 10 );
17
20
if (errno == ERANGE )
18
21
return false;
19
- if (isspace (* endptr ) || (* endptr == '\0' && endptr != str )) {
22
+ if (xisspace (* endptr ) || (* endptr == '\0' && endptr != str )) {
20
23
if ((long long ) ull < 0 ) {
21
24
/* only check for negative signs in the uncommon case when
22
25
* 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) {
39
42
long long ll = strtoll (str , & endptr , 10 );
40
43
if (errno == ERANGE )
41
44
return false;
42
- if (isspace (* endptr ) || (* endptr == '\0' && endptr != str )) {
45
+ if (xisspace (* endptr ) || (* endptr == '\0' && endptr != str )) {
43
46
* out = ll ;
44
47
return true;
45
48
}
@@ -59,7 +62,7 @@ bool safe_strtoul(const char *str, uint32_t *out) {
59
62
return false;
60
63
}
61
64
62
- if (isspace (* endptr ) || (* endptr == '\0' && endptr != str )) {
65
+ if (xisspace (* endptr ) || (* endptr == '\0' && endptr != str )) {
63
66
if ((long ) l < 0 ) {
64
67
/* only check for negative signs in the uncommon case when
65
68
* 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) {
83
86
long l = strtol (str , & endptr , 10 );
84
87
if (errno == ERANGE )
85
88
return false;
86
- if (isspace (* endptr ) || (* endptr == '\0' && endptr != str )) {
89
+ if (xisspace (* endptr ) || (* endptr == '\0' && endptr != str )) {
87
90
* out = l ;
88
91
return true;
89
92
}
0 commit comments