Remove trailing whitespace
This commit is contained in:
parent
6db70f0301
commit
263fd0c9d3
@ -1,23 +1,23 @@
|
|||||||
# Notes:
|
# Notes:
|
||||||
#
|
#
|
||||||
# Author: Paul Harris, June 2012
|
# Author: Paul Harris, June 2012
|
||||||
# Additions: Joakim Soderberg, Febuary 2013
|
# Additions: Joakim Soderberg, Febuary 2013
|
||||||
#
|
#
|
||||||
# Supports: building static/shared, release/debug/etc, can also build html docs
|
# Supports: building static/shared, release/debug/etc, can also build html docs
|
||||||
# and some of the tests.
|
# and some of the tests.
|
||||||
# Note that its designed for out-of-tree builds, so it will not pollute your
|
# Note that its designed for out-of-tree builds, so it will not pollute your
|
||||||
# source tree.
|
# source tree.
|
||||||
#
|
#
|
||||||
# TODO 1: Finish implementing tests. api tests are working, but the valgrind
|
# TODO 1: Finish implementing tests. api tests are working, but the valgrind
|
||||||
# variants are not flagging problems.
|
# variants are not flagging problems.
|
||||||
#
|
#
|
||||||
# TODO 2: There is a check_exports script that would try and incorporate.
|
# TODO 2: There is a check_exports script that would try and incorporate.
|
||||||
#
|
#
|
||||||
# TODO 3: Consolidate version numbers, currently the version number is written
|
# TODO 3: Consolidate version numbers, currently the version number is written
|
||||||
# into: * cmake (here) * autotools (the configure) * source code header files.
|
# into: * cmake (here) * autotools (the configure) * source code header files.
|
||||||
# Should not be written directly into header files, autotools/cmake can do
|
# Should not be written directly into header files, autotools/cmake can do
|
||||||
# that job.
|
# that job.
|
||||||
#
|
#
|
||||||
# Brief intro on how to use cmake:
|
# Brief intro on how to use cmake:
|
||||||
# > mkdir build (somewhere - we do out-of-tree builds)
|
# > mkdir build (somewhere - we do out-of-tree builds)
|
||||||
# > use cmake, ccmake, or cmake-gui to configure the project. for linux, you
|
# > use cmake, ccmake, or cmake-gui to configure the project. for linux, you
|
||||||
@ -25,22 +25,22 @@
|
|||||||
# >> example:
|
# >> example:
|
||||||
# >> cd build
|
# >> cd build
|
||||||
# >> ccmake -i ../path_to_jansson_dir
|
# >> ccmake -i ../path_to_jansson_dir
|
||||||
# >> inside, configure your options. press C until there are no lines
|
# >> inside, configure your options. press C until there are no lines
|
||||||
# with * next to them.
|
# with * next to them.
|
||||||
# >> note, I like to configure the 'install' path to ../install, so I get
|
# >> note, I like to configure the 'install' path to ../install, so I get
|
||||||
# self-contained clean installs I can point other projects to.
|
# self-contained clean installs I can point other projects to.
|
||||||
# >> press G to 'generate' the project files.
|
# >> press G to 'generate' the project files.
|
||||||
# >> make (to build the project)
|
# >> make (to build the project)
|
||||||
# >> make install
|
# >> make install
|
||||||
# >> make test (to run the tests, if you enabled them)
|
# >> make test (to run the tests, if you enabled them)
|
||||||
#
|
#
|
||||||
# Brief description on how it works:
|
# Brief description on how it works:
|
||||||
# There is a small heirachy of CMakeLists.txt files which define how the
|
# There is a small heirachy of CMakeLists.txt files which define how the
|
||||||
# project is built.
|
# project is built.
|
||||||
# Header file detection etc is done, and the results are written into config.h
|
# Header file detection etc is done, and the results are written into config.h
|
||||||
# and jansson_config.h, which are generated from the corresponding
|
# and jansson_config.h, which are generated from the corresponding
|
||||||
# config.h.cmake and jansson_config.h.cmake template files.
|
# config.h.cmake and jansson_config.h.cmake template files.
|
||||||
# The generated header files end up in the build directory - not in
|
# The generated header files end up in the build directory - not in
|
||||||
# the source directory.
|
# the source directory.
|
||||||
# The rest is down to the usual make process.
|
# The rest is down to the usual make process.
|
||||||
|
|
||||||
@ -253,9 +253,9 @@ install (TARGETS jansson
|
|||||||
RUNTIME DESTINATION bin
|
RUNTIME DESTINATION bin
|
||||||
)
|
)
|
||||||
|
|
||||||
install (FILES
|
install (FILES
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/include/jansson_config.h
|
${CMAKE_CURRENT_BINARY_DIR}/include/jansson_config.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/jansson.h
|
${CMAKE_CURRENT_SOURCE_DIR}/src/jansson.h
|
||||||
DESTINATION include)
|
DESTINATION include)
|
||||||
|
|
||||||
# For building Documentation (uses Sphinx)
|
# For building Documentation (uses Sphinx)
|
||||||
@ -272,7 +272,7 @@ if (BUILD_DOCS)
|
|||||||
# HTML output directory
|
# HTML output directory
|
||||||
set(SPHINX_HTML_DIR "${CMAKE_CURRENT_BINARY_DIR}/html")
|
set(SPHINX_HTML_DIR "${CMAKE_CURRENT_BINARY_DIR}/html")
|
||||||
|
|
||||||
# CMake could be used to build the conf.py file too,
|
# CMake could be used to build the conf.py file too,
|
||||||
# eg it could automatically write the version of the program or change the theme.
|
# eg it could automatically write the version of the program or change the theme.
|
||||||
# if(NOT DEFINED SPHINX_THEME)
|
# if(NOT DEFINED SPHINX_THEME)
|
||||||
# set(SPHINX_THEME default)
|
# set(SPHINX_THEME default)
|
||||||
@ -310,13 +310,13 @@ if (NOT WITHOUT_TESTS)
|
|||||||
|
|
||||||
if (TEST_WITH_VALGRIND)
|
if (TEST_WITH_VALGRIND)
|
||||||
# TODO: Add FindValgrind.cmake instead of having a hardcoded path.
|
# TODO: Add FindValgrind.cmake instead of having a hardcoded path.
|
||||||
|
|
||||||
# enable valgrind
|
# enable valgrind
|
||||||
set(CMAKE_MEMORYCHECK_COMMAND valgrind)
|
set(CMAKE_MEMORYCHECK_COMMAND valgrind)
|
||||||
set(CMAKE_MEMORYCHECK_COMMAND_OPTIONS
|
set(CMAKE_MEMORYCHECK_COMMAND_OPTIONS
|
||||||
"--leak-check=full --show-reachable=yes --track-origins=yes -q")
|
"--leak-check=full --show-reachable=yes --track-origins=yes -q")
|
||||||
|
|
||||||
set(MEMCHECK_COMMAND
|
set(MEMCHECK_COMMAND
|
||||||
"${CMAKE_MEMORYCHECK_COMMAND} ${CMAKE_MEMORYCHECK_COMMAND_OPTIONS}")
|
"${CMAKE_MEMORYCHECK_COMMAND} ${CMAKE_MEMORYCHECK_COMMAND_OPTIONS}")
|
||||||
separate_arguments(MEMCHECK_COMMAND)
|
separate_arguments(MEMCHECK_COMMAND)
|
||||||
endif ()
|
endif ()
|
||||||
@ -328,7 +328,7 @@ if (NOT WITHOUT_TESTS)
|
|||||||
add_definitions(-Wall -Wextra -Wdeclaration-after-statement -Werror)
|
add_definitions(-Wall -Wextra -Wdeclaration-after-statement -Werror)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
set(api_tests
|
set(api_tests
|
||||||
test_array
|
test_array
|
||||||
test_copy
|
test_copy
|
||||||
test_dump
|
test_dump
|
||||||
@ -361,7 +361,7 @@ if (NOT WITHOUT_TESTS)
|
|||||||
add_test(${test} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${test})
|
add_test(${test} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${test})
|
||||||
|
|
||||||
if (TEST_WITH_VALGRIND)
|
if (TEST_WITH_VALGRIND)
|
||||||
add_test(memcheck_${test} ${MEMCHECK_COMMAND}
|
add_test(memcheck_${test} ${MEMCHECK_COMMAND}
|
||||||
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${test})
|
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${test})
|
||||||
endif ()
|
endif ()
|
||||||
endforeach ()
|
endforeach ()
|
||||||
@ -375,7 +375,7 @@ if (NOT WITHOUT_TESTS)
|
|||||||
foreach (TESTDIR ${TESTDIRS})
|
foreach (TESTDIR ${TESTDIRS})
|
||||||
if (IS_DIRECTORY ${TESTDIR})
|
if (IS_DIRECTORY ${TESTDIR})
|
||||||
get_filename_component(TNAME ${TESTDIR} NAME)
|
get_filename_component(TNAME ${TESTDIR} NAME)
|
||||||
add_test(${SUITE}__${TNAME}
|
add_test(${SUITE}__${TNAME}
|
||||||
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/json_process ${TESTDIR})
|
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/json_process ${TESTDIR})
|
||||||
if ((${SUITE} STREQUAL "valid" OR ${SUITE} STREQUAL "invalid") AND NOT EXISTS ${TESTDIR}/nostrip)
|
if ((${SUITE} STREQUAL "valid" OR ${SUITE} STREQUAL "invalid") AND NOT EXISTS ${TESTDIR}/nostrip)
|
||||||
add_test(${SUITE}__${TNAME}__strip
|
add_test(${SUITE}__${TNAME}__strip
|
||||||
|
@ -66,17 +66,17 @@ static char *loadfile(FILE *file)
|
|||||||
{
|
{
|
||||||
long fsize, ret;
|
long fsize, ret;
|
||||||
char *buf;
|
char *buf;
|
||||||
|
|
||||||
fseek(file, 0, SEEK_END);
|
fseek(file, 0, SEEK_END);
|
||||||
fsize = ftell(file);
|
fsize = ftell(file);
|
||||||
fseek(file, 0, SEEK_SET);
|
fseek(file, 0, SEEK_SET);
|
||||||
|
|
||||||
buf = malloc(fsize+1);
|
buf = malloc(fsize+1);
|
||||||
ret = fread(buf, 1, fsize, file);
|
ret = fread(buf, 1, fsize, file);
|
||||||
if (ret != fsize)
|
if (ret != fsize)
|
||||||
exit(1);
|
exit(1);
|
||||||
buf[fsize] = '\0';
|
buf[fsize] = '\0';
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ static char *loadfile(FILE *file)
|
|||||||
static void read_conf(FILE *conffile)
|
static void read_conf(FILE *conffile)
|
||||||
{
|
{
|
||||||
char *buffer, *line, *val;
|
char *buffer, *line, *val;
|
||||||
|
|
||||||
buffer = loadfile(conffile);
|
buffer = loadfile(conffile);
|
||||||
line = strtok(buffer, "\r\n");
|
line = strtok(buffer, "\r\n");
|
||||||
while (line) {
|
while (line) {
|
||||||
@ -94,7 +94,7 @@ static void read_conf(FILE *conffile)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*val++ = '\0';
|
*val++ = '\0';
|
||||||
|
|
||||||
if (!strcmp(line, "JSON_INDENT"))
|
if (!strcmp(line, "JSON_INDENT"))
|
||||||
conf.indent = atoi(val);
|
conf.indent = atoi(val);
|
||||||
if (!strcmp(line, "JSON_COMPACT"))
|
if (!strcmp(line, "JSON_COMPACT"))
|
||||||
@ -107,10 +107,10 @@ static void read_conf(FILE *conffile)
|
|||||||
conf.sort_keys = atoi(val);
|
conf.sort_keys = atoi(val);
|
||||||
if (!strcmp(line, "STRIP"))
|
if (!strcmp(line, "STRIP"))
|
||||||
conf.strip = atoi(val);
|
conf.strip = atoi(val);
|
||||||
|
|
||||||
line = strtok(NULL, "\r\n");
|
line = strtok(NULL, "\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
free(buffer);
|
free(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ static int cmpfile(const char *str, const char *path, const char *fname)
|
|||||||
char filename[1024], *buffer;
|
char filename[1024], *buffer;
|
||||||
int ret;
|
int ret;
|
||||||
FILE *file;
|
FILE *file;
|
||||||
|
|
||||||
sprintf(filename, "%s%c%s", path, dir_sep, fname);
|
sprintf(filename, "%s%c%s", path, dir_sep, fname);
|
||||||
file = fopen(filename, "rb");
|
file = fopen(filename, "rb");
|
||||||
if (!file) {
|
if (!file) {
|
||||||
@ -142,7 +142,7 @@ static int cmpfile(const char *str, const char *path, const char *fname)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
free(buffer);
|
free(buffer);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ int use_conf(char *test_path)
|
|||||||
fprintf(stderr, "Could not open \"%s\"\n", filename);
|
fprintf(stderr, "Could not open \"%s\"\n", filename);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
sprintf(filename, "%s%cenv", test_path, dir_sep);
|
sprintf(filename, "%s%cenv", test_path, dir_sep);
|
||||||
conffile = fopen(filename, "rb");
|
conffile = fopen(filename, "rb");
|
||||||
if (conffile) {
|
if (conffile) {
|
||||||
@ -199,12 +199,12 @@ int use_conf(char *test_path)
|
|||||||
json = json_loadf(infile, 0, &error);
|
json = json_loadf(infile, 0, &error);
|
||||||
|
|
||||||
fclose(infile);
|
fclose(infile);
|
||||||
|
|
||||||
if (!json) {
|
if (!json) {
|
||||||
sprintf(errstr, "%d %d %d\n%s\n",
|
sprintf(errstr, "%d %d %d\n%s\n",
|
||||||
error.line, error.column, error.position,
|
error.line, error.column, error.position,
|
||||||
error.text);
|
error.text);
|
||||||
|
|
||||||
ret = cmpfile(errstr, test_path, "error");
|
ret = cmpfile(errstr, test_path, "error");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -221,7 +221,7 @@ static int getenv_int(const char *name)
|
|||||||
{
|
{
|
||||||
char *value, *end;
|
char *value, *end;
|
||||||
long result;
|
long result;
|
||||||
|
|
||||||
value = getenv(name);
|
value = getenv(name);
|
||||||
if(!value)
|
if(!value)
|
||||||
return 0;
|
return 0;
|
||||||
@ -264,10 +264,10 @@ int use_env()
|
|||||||
|
|
||||||
if(getenv_int("JSON_PRESERVE_ORDER"))
|
if(getenv_int("JSON_PRESERVE_ORDER"))
|
||||||
flags |= JSON_PRESERVE_ORDER;
|
flags |= JSON_PRESERVE_ORDER;
|
||||||
|
|
||||||
if(getenv_int("JSON_SORT_KEYS"))
|
if(getenv_int("JSON_SORT_KEYS"))
|
||||||
flags |= JSON_SORT_KEYS;
|
flags |= JSON_SORT_KEYS;
|
||||||
|
|
||||||
if(getenv_int("STRIP")) {
|
if(getenv_int("STRIP")) {
|
||||||
/* Load to memory, strip leading and trailing whitespace */
|
/* Load to memory, strip leading and trailing whitespace */
|
||||||
size_t size = 0, used = 0;
|
size_t size = 0, used = 0;
|
||||||
@ -290,7 +290,7 @@ int use_env()
|
|||||||
}
|
}
|
||||||
used += count;
|
used += count;
|
||||||
}
|
}
|
||||||
|
|
||||||
json = json_loads(strip(buffer), 0, &error);
|
json = json_loads(strip(buffer), 0, &error);
|
||||||
free(buffer);
|
free(buffer);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user