diff options
author | Lloyd Hilaiel <lloyd@hilaiel.com> | 2010-08-10 13:15:20 -0600 |
---|---|---|
committer | Lloyd Hilaiel <lloyd@hilaiel.com> | 2010-08-10 13:44:49 -0600 |
commit | d564f36928cb340094fe3609bc9fb457063589ab (patch) | |
tree | b18c096e6f3ff9a4e24e0163465bd404086c122d | |
parent | 1165091129de52851f5e5c6718568aefcf647b66 (diff) | |
download | yajl-d564f36928cb340094fe3609bc9fb457063589ab.tar.gz |
re-introduce long long type for integer representation now that we require C99
-rw-r--r-- | src/api/yajl_gen.h | 2 | ||||
-rw-r--r-- | src/api/yajl_parse.h | 6 | ||||
-rw-r--r-- | src/yajl_gen.c | 4 | ||||
-rw-r--r-- | src/yajl_parser.c | 4 | ||||
-rw-r--r-- | test/yajl_test.c | 4 |
5 files changed, 10 insertions, 10 deletions
diff --git a/src/api/yajl_gen.h b/src/api/yajl_gen.h index a3fbd4c..cd1b9fa 100644 --- a/src/api/yajl_gen.h +++ b/src/api/yajl_gen.h @@ -122,7 +122,7 @@ extern "C" { /** free a generator handle */ YAJL_API void yajl_gen_free(yajl_gen handle); - YAJL_API yajl_gen_status yajl_gen_integer(yajl_gen hand, long int number); + YAJL_API yajl_gen_status yajl_gen_integer(yajl_gen hand, long long int number); /** generate a floating point number. number may not be infinity or * NaN, as these have no representation in JSON. In these cases the * generator will return 'yajl_gen_invalid_number' */ diff --git a/src/api/yajl_parse.h b/src/api/yajl_parse.h index 1cbd930..76177dd 100644 --- a/src/api/yajl_parse.h +++ b/src/api/yajl_parse.h @@ -77,18 +77,18 @@ extern "C" { * * Note about handling of numbers: * yajl will only convert numbers that can be represented in a double - * or a long int. All other numbers will be passed to the client + * or a 64 bit (long long) int. All other numbers will be passed to the client * in string form using the yajl_number callback. Furthermore, if * yajl_number is not NULL, it will always be used to return numbers, * that is yajl_integer and yajl_double will be ignored. If * yajl_number is NULL but one of yajl_integer or yajl_double are * defined, parsing of a number larger than is representable - * in a double or long int will result in a parse error. + * in a double or 64 bit integer will result in a parse error. */ typedef struct { int (* yajl_null)(void * ctx); int (* yajl_boolean)(void * ctx, int boolVal); - int (* yajl_integer)(void * ctx, long integerVal); + int (* yajl_integer)(void * ctx, long long integerVal); int (* yajl_double)(void * ctx, double doubleVal); /** A callback which passes the string representation of the number * back to the client. Will be used for all numbers when present */ diff --git a/src/yajl_gen.c b/src/yajl_gen.c index 548d948..97e19d8 100644 --- a/src/yajl_gen.c +++ b/src/yajl_gen.c @@ -178,11 +178,11 @@ yajl_gen_free(yajl_gen g) g->print(g->ctx, "\n", 1); yajl_gen_status -yajl_gen_integer(yajl_gen g, long int number) +yajl_gen_integer(yajl_gen g, long long int number) { char i[32]; ENSURE_VALID_STATE; ENSURE_NOT_KEY; INSERT_SEP; INSERT_WHITESPACE; - sprintf(i, "%ld", number); + sprintf(i, "%lld", number); g->print(g->ctx, i, strlen(i)); APPENDED_ATOM; FINAL_NEWLINE; diff --git a/src/yajl_parser.c b/src/yajl_parser.c index 7fae6c6..8eafded 100644 --- a/src/yajl_parser.c +++ b/src/yajl_parser.c @@ -231,11 +231,11 @@ yajl_do_parse(yajl_handle hand, const unsigned char * jsonText, _CC_CHK(hand->callbacks->yajl_number( hand->ctx,(const char *) buf, bufLen)); } else if (hand->callbacks->yajl_integer) { - long int i = 0; + long long int i = 0; yajl_buf_clear(hand->decodeBuf); yajl_buf_append(hand->decodeBuf, buf, bufLen); buf = yajl_buf_data(hand->decodeBuf); - i = strtol((const char *) buf, NULL, 10); + i = strtoll((const char *) buf, NULL, 10); if ((i == LONG_MIN || i == LONG_MAX) && errno == ERANGE) { diff --git a/test/yajl_test.c b/test/yajl_test.c index 0f07a94..07c9f17 100644 --- a/test/yajl_test.c +++ b/test/yajl_test.c @@ -93,9 +93,9 @@ static int test_yajl_boolean(void * ctx, int boolVal) return 1; } -static int test_yajl_integer(void *ctx, long integerVal) +static int test_yajl_integer(void *ctx, long long integerVal) { - printf("integer: %ld\n", integerVal); + printf("integer: %lld\n", integerVal); return 1; } |