Remove trailing whitespace

This commit is contained in:
Petri Lehtinen 2013-03-14 22:18:21 +02:00
parent 6db70f0301
commit 263fd0c9d3
2 changed files with 44 additions and 44 deletions

View File

@ -1,23 +1,23 @@
# Notes:
#
#
# Author: Paul Harris, June 2012
# 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.
# 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.
#
# 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.
#
#
# TODO 2: There is a check_exports script that would try and incorporate.
#
# TODO 3: Consolidate version numbers, currently the version number is written
# into: * cmake (here) * autotools (the configure) * source code header files.
#
# TODO 3: Consolidate version numbers, currently the version number is written
# into: * cmake (here) * autotools (the configure) * source code header files.
# Should not be written directly into header files, autotools/cmake can do
# that job.
#
#
# Brief intro on how to use cmake:
# > mkdir build (somewhere - we do out-of-tree builds)
# > use cmake, ccmake, or cmake-gui to configure the project. for linux, you
@ -25,22 +25,22 @@
# >> example:
# >> cd build
# >> 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.
# >> 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.
# >> press G to 'generate' the project files.
# >> make (to build the project)
# >> make install
# >> make test (to run the tests, if you enabled them)
#
#
# 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.
# Header file detection etc is done, and the results are written into config.h
# and jansson_config.h, which are generated from the corresponding
# Header file detection etc is done, and the results are written into config.h
# and jansson_config.h, which are generated from the corresponding
# 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 rest is down to the usual make process.
@ -253,9 +253,9 @@ install (TARGETS jansson
RUNTIME DESTINATION bin
)
install (FILES
${CMAKE_CURRENT_BINARY_DIR}/include/jansson_config.h
${CMAKE_CURRENT_SOURCE_DIR}/src/jansson.h
install (FILES
${CMAKE_CURRENT_BINARY_DIR}/include/jansson_config.h
${CMAKE_CURRENT_SOURCE_DIR}/src/jansson.h
DESTINATION include)
# For building Documentation (uses Sphinx)
@ -272,7 +272,7 @@ if (BUILD_DOCS)
# HTML output directory
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.
# if(NOT DEFINED SPHINX_THEME)
# set(SPHINX_THEME default)
@ -310,13 +310,13 @@ if (NOT WITHOUT_TESTS)
if (TEST_WITH_VALGRIND)
# TODO: Add FindValgrind.cmake instead of having a hardcoded path.
# enable 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")
set(MEMCHECK_COMMAND
set(MEMCHECK_COMMAND
"${CMAKE_MEMORYCHECK_COMMAND} ${CMAKE_MEMORYCHECK_COMMAND_OPTIONS}")
separate_arguments(MEMCHECK_COMMAND)
endif ()
@ -328,7 +328,7 @@ if (NOT WITHOUT_TESTS)
add_definitions(-Wall -Wextra -Wdeclaration-after-statement -Werror)
endif ()
set(api_tests
set(api_tests
test_array
test_copy
test_dump
@ -361,7 +361,7 @@ if (NOT WITHOUT_TESTS)
add_test(${test} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${test})
if (TEST_WITH_VALGRIND)
add_test(memcheck_${test} ${MEMCHECK_COMMAND}
add_test(memcheck_${test} ${MEMCHECK_COMMAND}
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${test})
endif ()
endforeach ()
@ -375,7 +375,7 @@ if (NOT WITHOUT_TESTS)
foreach (TESTDIR ${TESTDIRS})
if (IS_DIRECTORY ${TESTDIR})
get_filename_component(TNAME ${TESTDIR} NAME)
add_test(${SUITE}__${TNAME}
add_test(${SUITE}__${TNAME}
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/json_process ${TESTDIR})
if ((${SUITE} STREQUAL "valid" OR ${SUITE} STREQUAL "invalid") AND NOT EXISTS ${TESTDIR}/nostrip)
add_test(${SUITE}__${TNAME}__strip

View File

@ -66,17 +66,17 @@ static char *loadfile(FILE *file)
{
long fsize, ret;
char *buf;
fseek(file, 0, SEEK_END);
fsize = ftell(file);
fseek(file, 0, SEEK_SET);
buf = malloc(fsize+1);
ret = fread(buf, 1, fsize, file);
if (ret != fsize)
exit(1);
buf[fsize] = '\0';
return buf;
}
@ -84,7 +84,7 @@ static char *loadfile(FILE *file)
static void read_conf(FILE *conffile)
{
char *buffer, *line, *val;
buffer = loadfile(conffile);
line = strtok(buffer, "\r\n");
while (line) {
@ -94,7 +94,7 @@ static void read_conf(FILE *conffile)
break;
}
*val++ = '\0';
if (!strcmp(line, "JSON_INDENT"))
conf.indent = atoi(val);
if (!strcmp(line, "JSON_COMPACT"))
@ -107,10 +107,10 @@ static void read_conf(FILE *conffile)
conf.sort_keys = atoi(val);
if (!strcmp(line, "STRIP"))
conf.strip = atoi(val);
line = strtok(NULL, "\r\n");
}
free(buffer);
}
@ -120,7 +120,7 @@ static int cmpfile(const char *str, const char *path, const char *fname)
char filename[1024], *buffer;
int ret;
FILE *file;
sprintf(filename, "%s%c%s", path, dir_sep, fname);
file = fopen(filename, "rb");
if (!file) {
@ -142,7 +142,7 @@ static int cmpfile(const char *str, const char *path, const char *fname)
ret = 0;
free(buffer);
fclose(file);
return ret;
}
@ -161,7 +161,7 @@ int use_conf(char *test_path)
fprintf(stderr, "Could not open \"%s\"\n", filename);
return 2;
}
sprintf(filename, "%s%cenv", test_path, dir_sep);
conffile = fopen(filename, "rb");
if (conffile) {
@ -199,12 +199,12 @@ int use_conf(char *test_path)
json = json_loadf(infile, 0, &error);
fclose(infile);
if (!json) {
sprintf(errstr, "%d %d %d\n%s\n",
error.line, error.column, error.position,
error.text);
ret = cmpfile(errstr, test_path, "error");
return ret;
}
@ -221,7 +221,7 @@ static int getenv_int(const char *name)
{
char *value, *end;
long result;
value = getenv(name);
if(!value)
return 0;
@ -264,10 +264,10 @@ int use_env()
if(getenv_int("JSON_PRESERVE_ORDER"))
flags |= JSON_PRESERVE_ORDER;
if(getenv_int("JSON_SORT_KEYS"))
flags |= JSON_SORT_KEYS;
if(getenv_int("STRIP")) {
/* Load to memory, strip leading and trailing whitespace */
size_t size = 0, used = 0;
@ -290,7 +290,7 @@ int use_env()
}
used += count;
}
json = json_loads(strip(buffer), 0, &error);
free(buffer);
}