Make it compile on platforms where char is unsigned
authorPetri Lehtinen <petri@digip.org>
Thu, 1 Oct 2009 18:52:12 +0000 (21:52 +0300)
committerPetri Lehtinen <petri@digip.org>
Thu, 1 Oct 2009 18:54:45 +0000 (21:54 +0300)
Linux on powerpc seems to be one such platform.

src/dump.c
src/load.c

index 4831873..28c00b9 100644 (file)
@@ -70,7 +70,7 @@ static int dump_string(const char *str, dump_func dump, void *data)
         char seq[7];
         int length;
 
-        while(*end && *end != '\\' && *end != '"' && (*end < 0 || *end > 0x1F))
+        while(*end && *end != '\\' && *end != '"' && (unsigned char)*end > 0x1F)
             end++;
 
         if(end != str) {
index 5175f35..4134182 100644 (file)
@@ -135,7 +135,7 @@ static char stream_get(stream_t *stream, json_error_t *error)
 
         c = stream->buffer[0];
 
-        if(c < 0 && c != EOF)
+        if((unsigned char)c >= 0x80 && c != (char)EOF)
         {
             /* multi-byte UTF-8 sequence */
             int i, count;
@@ -519,7 +519,7 @@ static int lex_scan(lex_t *lex, json_error_t *error)
         c = lex_get(lex, error);
     }
 
-    if(c == EOF) {
+    if(c == (char)EOF) {
         if(lex_eof(lex))
             lex->token = TOKEN_EOF;
         else