summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNARUSE, Yui <naruse@airemix.jp>2013-05-08 13:55:11 +0900
committerNARUSE, Yui <naruse@airemix.jp>2013-05-08 13:55:11 +0900
commit855c63bdfb1051176c5f5cd36ff8b1cc1ff364a7 (patch)
treefce070c7d99d6c9ed1069a2ed5b34ec09d38d7fb
parenta7e69ec559caccae36f875ad035f034c7c491d8e (diff)
downloadjson-855c63bdfb1051176c5f5cd36ff8b1cc1ff364a7.tar.gz
Suppress warning: -Wchar-subscripts
On some platforms char is signed char and giving signed char to isspace(int c) can cause unexpected behavior. To avoid such situation, it should cast as unsigned char.
-rw-r--r--ext/json/ext/generator/generator.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/ext/json/ext/generator/generator.c b/ext/json/ext/generator/generator.c
index 8ceaa2b..ed7bb82 100644
--- a/ext/json/ext/generator/generator.c
+++ b/ext/json/ext/generator/generator.c
@@ -902,8 +902,8 @@ static int isArrayOrObject(VALUE string)
long string_len = RSTRING_LEN(string);
char *p = RSTRING_PTR(string), *q = p + string_len - 1;
if (string_len < 2) return 0;
- for (; p < q && isspace(*p); p++);
- for (; q > p && isspace(*q); q--);
+ for (; p < q && isspace((unsigned char)*p); p++);
+ for (; q > p && isspace((unsigned char)*q); q--);
return (*p == '[' && *q == ']') || (*p == '{' && *q == '}');
}