Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
34fb97998c | ||
|
|
ec96cbf016 | ||
|
|
7c707a73a2 | ||
|
|
330e892ff6 | ||
|
|
d857fd08a5 | ||
|
|
842bc2128b | ||
|
|
ca6d26a1c2 | ||
|
|
d3959a8ce7 | ||
|
|
f243930b68 | ||
|
|
15d992cb6a | ||
|
|
59c58ea26c | ||
|
|
f95bb423a3 | ||
|
|
9448ed3ef7 | ||
|
|
7c7a1ed01e |
25
CHANGES
25
CHANGES
@@ -1,4 +1,27 @@
|
||||
Version 1.1, released 2009-10-XX
|
||||
Version 1.1.3, released 2009-12-18
|
||||
|
||||
* Encode reals correctly, so that first encoding and then decoding a
|
||||
real always produces the same value
|
||||
* Don't export private symbols in libjansson.so
|
||||
|
||||
|
||||
Version 1.1.2, released 2009-11-08
|
||||
|
||||
* Fix a bug where an error message was not produced if the input file
|
||||
could not be opened in json_load_file()
|
||||
* Fix an assertion failure in decoder caused by a minus sign without a
|
||||
digit after it
|
||||
* Remove an unneeded include for stdint.h in jansson.h
|
||||
|
||||
|
||||
Version 1.1.1, released 2009-10-26
|
||||
|
||||
* All documentation files were not distributed with v1.1; build
|
||||
documentation in make distcheck to prevent this in the future
|
||||
* Fix v1.1 release date in CHANGES
|
||||
|
||||
|
||||
Version 1.1, released 2009-10-20
|
||||
|
||||
* API additions and improvements:
|
||||
- Extend array and object APIs
|
||||
|
||||
@@ -1,2 +1,7 @@
|
||||
EXTRA_DIST = CHANGES LICENSE README.rst
|
||||
SUBDIRS = doc src test
|
||||
|
||||
distcheck-hook:
|
||||
sphinx-build -b html -W \
|
||||
$(distdir)/doc \
|
||||
$(distdir)/_build/doc/.build/html
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
AC_PREREQ([2.59])
|
||||
AC_INIT([jansson], [1.1], [petri@digip.org])
|
||||
AC_INIT([jansson], [1.1.3], [petri@digip.org])
|
||||
|
||||
AM_INIT_AUTOMAKE([1.10 foreign])
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
EXTRA_DIST = conf.py apiref.rst index.rst ext/refcounting.py
|
||||
EXTRA_DIST = \
|
||||
conf.py apiref.rst gettingstarted.rst github_commits.c index.rst \
|
||||
tutorial.rst ext/refcounting.py
|
||||
|
||||
clean-local:
|
||||
rm -rf .build
|
||||
|
||||
@@ -52,7 +52,7 @@ copyright = u'2009, Petri Lehtinen'
|
||||
# The short X.Y version.
|
||||
version = '1.1'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '1.1'
|
||||
release = '1.1.3'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
/*
|
||||
* Copyright (c) 2009 Petri Lehtinen <petri@digip.org>
|
||||
*
|
||||
* Jansson is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ libjansson_la_SOURCES = \
|
||||
utf.h \
|
||||
util.h \
|
||||
value.c
|
||||
libjansson_la_LDFLAGS = -version-info 1:0:1
|
||||
libjansson_la_LDFLAGS = \
|
||||
-export-symbols-regex '^json_' \
|
||||
-version-info 1:2:1
|
||||
|
||||
AM_CFLAGS = -Wall -Wextra -Werror
|
||||
|
||||
17
src/dump.c
17
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#define JANSSON_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
||||
10
src/load.c
10
src/load.c
@@ -418,11 +418,15 @@ static int lex_scan_number(lex_t *lex, char c, json_error_t *error)
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
else /* c != '0' */ {
|
||||
else if(isdigit(c)) {
|
||||
c = lex_get_save(lex, error);
|
||||
while(isdigit(c))
|
||||
c = lex_get_save(lex, error);
|
||||
}
|
||||
else {
|
||||
lex_unget_unsave(lex, c);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if(c != '.' && c != 'E' && c != 'e') {
|
||||
long value;
|
||||
@@ -767,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);
|
||||
|
||||
@@ -864,6 +868,8 @@ json_t *json_load_file(const char *path, json_error_t *error)
|
||||
json_t *result;
|
||||
FILE *fp;
|
||||
|
||||
error_init(error);
|
||||
|
||||
fp = fopen(path, "r");
|
||||
if(!fp)
|
||||
{
|
||||
|
||||
1
test/.gitignore
vendored
1
test/.gitignore
vendored
@@ -3,6 +3,7 @@ loads_dumps
|
||||
load_file_dump_file
|
||||
testlogs
|
||||
testprogs/test_array
|
||||
testprogs/test_load
|
||||
testprogs/test_number
|
||||
testprogs/test_object
|
||||
testprogs/test_simple
|
||||
|
||||
17
test/testdata/invalid
vendored
17
test/testdata/invalid
vendored
@@ -167,7 +167,22 @@ too big negative integer near '-123123123123123'
|
||||
====
|
||||
1
|
||||
invalid token near 'troo'
|
||||
==== invalid-escap ====
|
||||
==== minus-sign-without-number ====
|
||||
[-foo]
|
||||
====
|
||||
1
|
||||
invalid token near '-'
|
||||
==== invalid-negative-integerr ====
|
||||
[-123foo]
|
||||
====
|
||||
1
|
||||
']' expected near 'foo'
|
||||
==== invalid-negative-real ====
|
||||
[-123.123foo]
|
||||
====
|
||||
1
|
||||
']' expected near 'foo'
|
||||
==== invalid-escape ====
|
||||
["\a <-- invalid escape"]
|
||||
====
|
||||
1
|
||||
|
||||
17
test/testdata/invalid-strip
vendored
17
test/testdata/invalid-strip
vendored
@@ -167,7 +167,22 @@ too big negative integer near '-123123123123123'
|
||||
====
|
||||
1
|
||||
invalid token near 'troo'
|
||||
==== invalid-escap ====
|
||||
==== minus-sign-without-number ====
|
||||
[-foo]
|
||||
====
|
||||
1
|
||||
invalid token near '-'
|
||||
==== invalid-negative-integerr ====
|
||||
[-123foo]
|
||||
====
|
||||
1
|
||||
']' expected near 'foo'
|
||||
==== invalid-negative-real ====
|
||||
[-123.123foo]
|
||||
====
|
||||
1
|
||||
']' expected near 'foo'
|
||||
==== invalid-escape ====
|
||||
["\a <-- invalid escape"]
|
||||
====
|
||||
1
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
check_PROGRAMS = test_array test_simple test_number test_object
|
||||
check_PROGRAMS = test_array test_load test_simple test_number test_object
|
||||
|
||||
test_array_SOURCES = test_array.c util.h
|
||||
test_load_SOURCES = test_load.c util.h
|
||||
test_simple_SOURCES = test_simple.c util.h
|
||||
test_number_SOURCES = test_number.c util.h
|
||||
test_object_SOURCES = test_object.c util.h
|
||||
|
||||
24
test/testprogs/test_load.c
Normal file
24
test/testprogs/test_load.c
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (c) 2009 Petri Lehtinen <petri@digip.org>
|
||||
*
|
||||
* Jansson is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the MIT license. See LICENSE for details.
|
||||
*/
|
||||
|
||||
#include <jansson.h>
|
||||
#include <string.h>
|
||||
#include "util.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
json_t *json;
|
||||
json_error_t error;
|
||||
|
||||
json = json_load_file("/path/to/nonexistent/file.json", &error);
|
||||
if(error.line != -1)
|
||||
fail("json_load_file returned an invalid line number");
|
||||
if(strcmp(error.text, "unable to open /path/to/nonexistent/file.json: No such file or directory") != 0)
|
||||
fail("json_load_file returned an invalid error message");
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user