aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPetri Lehtinen <petri@digip.org>2009-12-20 21:18:27 +0200
committerPetri Lehtinen <petri@digip.org>2009-12-21 12:52:25 +0200
commite7a5dc58e630aa079f402b46a65d218e656dd489 (patch)
treea4b36a00e6f569c8630d7ff2b7071ef640d3d7e5 /src
parent3889af476ba52e98de210e8e0b3b4a44a26b3a60 (diff)
parent34fb97998cfeb4ae6f4bc9450c9144bd7572c1f6 (diff)
downloadjansson-e7a5dc58e630aa079f402b46a65d218e656dd489.zip
jansson-e7a5dc58e630aa079f402b46a65d218e656dd489.tar.gz
jansson-e7a5dc58e630aa079f402b46a65d218e656dd489.tar.bz2
Merge branch '1.1'
Conflicts: configure.ac doc/conf.py
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am4
-rw-r--r--src/dump.c17
-rw-r--r--src/load.c2
3 files changed, 20 insertions, 3 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 9e9ee6c..87123a0 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:2:1
AM_CFLAGS = -Wall -Wextra -Werror
diff --git a/src/dump.c b/src/dump.c
index 328e93b..ba70f8d 100644
--- a/src/dump.c
+++ b/src/dump.c
@@ -191,10 +191,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);
}
diff --git a/src/load.c b/src/load.c
index 278f35e..4d08139 100644
--- a/src/load.c
+++ b/src/load.c
@@ -772,7 +772,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);