From c82cea9d321a8e2242feb0f9c0c0f61334ad15be Mon Sep 17 00:00:00 2001 From: Attie Grande Date: Thu, 6 Dec 2012 18:56:58 +0000 Subject: [PATCH 1/3] fixed l_isxdigit() macro Closes #97. --- src/load.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/load.c b/src/load.c index d88a704..bf6ee30 100644 --- a/src/load.c +++ b/src/load.c @@ -37,7 +37,7 @@ #define l_isalpha(c) (l_isupper(c) || l_islower(c)) #define l_isdigit(c) ('0' <= (c) && (c) <= '9') #define l_isxdigit(c) \ - (l_isdigit(c) || 'A' <= (c) || (c) <= 'F' || 'a' <= (c) || (c) <= 'f') + (l_isdigit(c) || ('A' <= (c) && (c) <= 'F') || ('a' <= (c) && (c) <= 'f')) /* Read one byte from stream, convert to unsigned char, then int, and return. return EOF on end of file. This corresponds to the From f86bb0377fb942a71e4852e00a42e89e1af1eee1 Mon Sep 17 00:00:00 2001 From: Jacob Potter Date: Wed, 5 Dec 2012 16:46:14 -0800 Subject: [PATCH 2/3] Mark some constant data as const. Issue #95. --- src/dump.c | 2 +- src/hashtable.c | 2 +- src/pack_unpack.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dump.c b/src/dump.c index 2c7dee9..bbf87d0 100644 --- a/src/dump.c +++ b/src/dump.c @@ -38,7 +38,7 @@ static int dump_to_file(const char *buffer, size_t size, void *data) } /* 32 spaces (the maximum indentation size) */ -static char whitespace[] = " "; +static const char whitespace[] = " "; static int dump_indent(size_t flags, int depth, int space, json_dump_callback_t dump, void *data) { diff --git a/src/hashtable.c b/src/hashtable.c index 76cf69b..bcbaa8c 100644 --- a/src/hashtable.c +++ b/src/hashtable.c @@ -74,7 +74,7 @@ static void insert_to_bucket(hashtable_t *hashtable, bucket_t *bucket, } } -static size_t primes[] = { +static const size_t primes[] = { 5, 13, 23, 53, 97, 193, 389, 769, 1543, 3079, 6151, 12289, 24593, 49157, 98317, 196613, 393241, 786433, 1572869, 3145739, 6291469, 12582917, 25165843, 50331653, 100663319, 201326611, 402653189, diff --git a/src/pack_unpack.c b/src/pack_unpack.c index 39db9b8..cdce28c 100644 --- a/src/pack_unpack.c +++ b/src/pack_unpack.c @@ -21,7 +21,7 @@ typedef struct { int column; } scanner_t; -static const char *type_names[] = { +static const char * const type_names[] = { "object", "array", "string", @@ -34,7 +34,7 @@ static const char *type_names[] = { #define type_name(x) type_names[json_typeof(x)] -static const char *unpack_value_starters = "{[siIbfFOon"; +static const char * const unpack_value_starters = "{[siIbfFOon"; static void scanner_init(scanner_t *s, json_error_t *error, From 872f847655225f9b3febc9afde203808beca94c4 Mon Sep 17 00:00:00 2001 From: Jacob Potter Date: Wed, 5 Dec 2012 16:50:08 -0800 Subject: [PATCH 3/3] Change const pointer to array Closes #95. --- src/pack_unpack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pack_unpack.c b/src/pack_unpack.c index cdce28c..18f9ccb 100644 --- a/src/pack_unpack.c +++ b/src/pack_unpack.c @@ -34,7 +34,7 @@ static const char * const type_names[] = { #define type_name(x) type_names[json_typeof(x)] -static const char * const unpack_value_starters = "{[siIbfFOon"; +static const char unpack_value_starters[] = "{[siIbfFOon"; static void scanner_init(scanner_t *s, json_error_t *error,