From 330e892ff645c4cb0956f32a6a28dfe7203b3390 Mon Sep 17 00:00:00 2001 From: Petri Lehtinen Date: Sun, 29 Nov 2009 13:00:47 +0200 Subject: Make parse_json static --- src/load.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/load.c b/src/load.c index 1ae62b3..005e03c 100644 --- a/src/load.c +++ b/src/load.c @@ -771,7 +771,7 @@ static json_t *parse_value(lex_t *lex, json_error_t *error) return json; } -json_t *parse_json(lex_t *lex, json_error_t *error) +static json_t *parse_json(lex_t *lex, json_error_t *error) { error_init(error); -- cgit v1.1 From 7c707a73a2251c20afaecc028267b99d0ee60184 Mon Sep 17 00:00:00 2001 From: Petri Lehtinen Date: Sun, 29 Nov 2009 13:04:00 +0200 Subject: Only export symbols starting with "json_" in libjansson.la This way we don't pollute the symbol namespace with internal symbols. --- src/Makefile.am | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 9e9ee6c..3ba8b8b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -13,6 +13,8 @@ libjansson_la_SOURCES = \ utf.h \ util.h \ value.c -libjansson_la_LDFLAGS = -version-info 1:1:1 +libjansson_la_LDFLAGS = \ + -export-symbols-regex '^json_' \ + -version-info 1:1:1 AM_CFLAGS = -Wall -Wextra -Werror -- cgit v1.1 From ec96cbf01693a90db15a13c3e77f68909036989e Mon Sep 17 00:00:00 2001 From: Petri Lehtinen Date: Thu, 17 Dec 2009 23:42:13 +0200 Subject: Encode reals correctly This patch changes the sprintf format from "%0.17f" to "%.17g", as the f format specifier doesn't print the exponent at all. This caused losing precision in all but the most simple cases. Because the g specifier doesn't print the decimal fraction or exponent if they're not needed, a ".0" has to be appended by hand in these cases. Otherwise the value's type changes from real to integer when decoding again. Thanks to Philip Grandinetti for reporting this issue. --- src/dump.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/dump.c b/src/dump.c index 7dbc9f2..bd12a7b 100644 --- a/src/dump.c +++ b/src/dump.c @@ -145,10 +145,25 @@ static int do_dump(const json_t *json, unsigned long flags, int depth, char buffer[MAX_REAL_STR_LENGTH]; int size; - size = snprintf(buffer, MAX_REAL_STR_LENGTH, "%0.17f", json_real_value(json)); + size = snprintf(buffer, MAX_REAL_STR_LENGTH, "%.17g", + json_real_value(json)); if(size >= MAX_REAL_STR_LENGTH) return -1; + /* Make sure there's a dot or 'e' in the output. Otherwise + a real is converted to an integer when decoding */ + if(strchr(buffer, '.') == NULL && + strchr(buffer, 'e') == NULL) + { + if(size + 2 >= MAX_REAL_STR_LENGTH) { + /* No space to append ".0" */ + return -1; + } + buffer[size] = '.'; + buffer[size + 1] = '0'; + size += 2; + } + return dump(buffer, size, data); } -- cgit v1.1 From 34fb97998cfeb4ae6f4bc9450c9144bd7572c1f6 Mon Sep 17 00:00:00 2001 From: Petri Lehtinen Date: Fri, 18 Dec 2009 21:43:12 +0200 Subject: jansson 1.1.3 --- src/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 3ba8b8b..87123a0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,6 +15,6 @@ libjansson_la_SOURCES = \ value.c libjansson_la_LDFLAGS = \ -export-symbols-regex '^json_' \ - -version-info 1:1:1 + -version-info 1:2:1 AM_CFLAGS = -Wall -Wextra -Werror -- cgit v1.1