Update jansson subtree to latest revision

This commit is contained in:
jp9000 2014-01-20 08:47:51 -07:00
parent a3867aecde
commit b404fb7c75
11 changed files with 28 additions and 13 deletions

View file

@ -102,7 +102,7 @@ if (MSVC)
endif()
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
if (NOT WIN32 AND (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX))
set(CMAKE_C_FLAGS "-fPIC")
endif()
@ -415,7 +415,7 @@ if (NOT WITHOUT_TESTS)
# Test suites.
#
if (CMAKE_COMPILER_IS_GNUCC)
add_definitions(-Wall -Wextra -Wdeclaration-after-statement -Werror)
add_definitions(-Wall -Wextra -Wdeclaration-after-statement)
endif ()
set(api_tests

View file

@ -1,4 +1,4 @@
EXTRA_DIST = CHANGES LICENSE README.rst win32
EXTRA_DIST = CHANGES LICENSE README.rst win32 CMakeLists.txt cmake
SUBDIRS = doc src test
# "make distcheck" builds the dvi target, so use it to check that the

View file

@ -150,6 +150,11 @@ functions:
Returns true for types ``JSON_TRUE`` and ``JSON_FALSE``, and false
for values of other types and for *NULL*.
.. function:: json_boolean_value(const json_t *json)
Alias of :func:`json_is_true()`, i.e. returns 1 for ``JSON_TRUE``
and 0 otherwise.
.. _apiref-reference-count:

View file

@ -53,6 +53,7 @@ static char *request(const char *url)
{
CURL *curl = NULL;
CURLcode status;
struct curl_slist *headers = NULL;
char *data = NULL;
long code;
@ -71,6 +72,11 @@ static char *request(const char *url)
};
curl_easy_setopt(curl, CURLOPT_URL, url);
/* GitHub commits API v3 requires a User-Agent header */
headers = curl_slist_append(headers, "User-Agent: Jansson-Tutorial");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_response);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &write_result);
@ -90,6 +96,7 @@ static char *request(const char *url)
}
curl_easy_cleanup(curl);
curl_slist_free_all(headers);
curl_global_cleanup();
/* zero-terminate the result */
@ -102,6 +109,8 @@ error:
free(data);
if(curl)
curl_easy_cleanup(curl);
if(headers)
curl_slist_free_all(headers);
curl_global_cleanup();
return NULL;
}

View file

@ -230,7 +230,7 @@ static int do_dump(const json_t *json, size_t flags, int depth,
goto array_error;
array->visited = 1;
n = (int)json_array_size(json);
n = json_array_size(json);
if(dump("[", 1, data))
goto array_error;

View file

@ -56,7 +56,7 @@ void jsonp_error_vset(json_error_t *error, int line, int column,
error->line = line;
error->column = column;
error->position = (int)position;
error->position = position;
vsnprintf(error->text, JSON_ERROR_TEXT_LENGTH, msg, ap);
error->text[JSON_ERROR_TEXT_LENGTH - 1] = '\0';

View file

@ -75,6 +75,7 @@ typedef long json_int_t;
#define json_is_number(json) (json_is_integer(json) || json_is_real(json))
#define json_is_true(json) ((json) && json_typeof(json) == JSON_TRUE)
#define json_is_false(json) ((json) && json_typeof(json) == JSON_FALSE)
#define json_boolean_value json_is_true
#define json_is_boolean(json) (json_is_true(json) || json_is_false(json))
#define json_is_null(json) ((json) && json_typeof(json) == JSON_NULL)

View file

@ -171,7 +171,7 @@ static int stream_get(stream_t *stream, json_error_t *error)
/* multi-byte UTF-8 sequence */
int i, count;
count = (int)utf8_check_first(c);
count = utf8_check_first(c);
if(!count)
goto out;
@ -900,7 +900,7 @@ static json_t *parse_json(lex_t *lex, size_t flags, json_error_t *error)
if(error) {
/* Save the position even though there was no error */
error->position = (int)lex->stream.position;
error->position = lex->stream.position;
}
return result;

View file

@ -76,7 +76,7 @@ json_t *json_object_get(const json_t *json, const char *key)
{
json_object_t *object;
if(!json_is_object(json))
if(!key || !json_is_object(json))
return NULL;
object = json_to_object(json);
@ -121,7 +121,7 @@ int json_object_del(json_t *json, const char *key)
{
json_object_t *object;
if(!json_is_object(json))
if(!key || !json_is_object(json))
return -1;
object = json_to_object(json);

View file

@ -27,6 +27,8 @@ static void run_tests()
value = json_boolean(0);
if(!json_is_false(value))
fail("json_boolean(0) failed");
if(json_boolean_value(value) != 0)
fail("json_boolean_value failed");
json_decref(value);

View file

@ -119,12 +119,10 @@ Global
{C6CD0240-5A92-43F6-B0EE-FF3ACE10742F}.Release|x64.Build.0 = Release|x64
{76226D20-1972-4789-A595-EDACC7A76DC3}.Debug|Win32.ActiveCfg = Debug|Win32
{76226D20-1972-4789-A595-EDACC7A76DC3}.Debug|Win32.Build.0 = Debug|Win32
{76226D20-1972-4789-A595-EDACC7A76DC3}.Debug|x64.ActiveCfg = Debug|x64
{76226D20-1972-4789-A595-EDACC7A76DC3}.Debug|x64.Build.0 = Debug|x64
{76226D20-1972-4789-A595-EDACC7A76DC3}.Debug|x64.ActiveCfg = Debug|Win32
{76226D20-1972-4789-A595-EDACC7A76DC3}.Release|Win32.ActiveCfg = Release|Win32
{76226D20-1972-4789-A595-EDACC7A76DC3}.Release|Win32.Build.0 = Release|Win32
{76226D20-1972-4789-A595-EDACC7A76DC3}.Release|x64.ActiveCfg = Release|x64
{76226D20-1972-4789-A595-EDACC7A76DC3}.Release|x64.Build.0 = Release|x64
{76226D20-1972-4789-A595-EDACC7A76DC3}.Release|x64.ActiveCfg = Release|Win32
{36970254-B1E5-4BE6-A561-301B6E7CDCE3}.Debug|Win32.ActiveCfg = Debug|Win32
{36970254-B1E5-4BE6-A561-301B6E7CDCE3}.Debug|Win32.Build.0 = Debug|Win32
{36970254-B1E5-4BE6-A561-301B6E7CDCE3}.Debug|x64.ActiveCfg = Debug|x64