diff --git a/.travis.yml b/.travis.yml index e4ddee9..3ef8261 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,5 +4,5 @@ compiler: before_install: - sudo apt-get install cmake valgrind script: - - mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Debug .. && make && ./test-xml && valgrind --tool=memcheck --leak-check=full --track-origins=yes -v ./test-xml + - mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Debug -DXML_PARSER_VERBOSE=On .. && make && ./test-xml && valgrind --tool=memcheck --leak-check=full --track-origins=yes -v ./test-xml diff --git a/CMakeLists.txt b/CMakeLists.txt index b4a1c10..640b9f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,13 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR) SET(CMAKE_C_FLAGS_DEBUG "-g -DDEBUG") SET(CMAKE_C_FLAGS_RELEASE "-O2") +# Options +OPTION(XML_PARSER_VERBOSE "Enable to be told everything the xml parser does" OFF) + +IF(XML_PARSER_VERBOSE) + ADD_DEFINITIONS(-DXML_PARSER_VERBOSE) +ENDIF(XML_PARSER_VERBOSE) + # Sources SET(SOURCE_DIRECTORY src) diff --git a/src/xml.c b/src/xml.c index 9e78b4b..42496ab 100644 --- a/src/xml.c +++ b/src/xml.c @@ -196,7 +196,7 @@ static void xml_node_free(struct xml_node* node) { * * Echos the parsers call stack for debugging purposes */ -#ifdef DEBUG +#ifdef XML_PARSER_VERBOSE static void xml_parser_info(struct xml_parser* parser, char const* message) { fprintf(stdout, "xml_parser_info %s\n", message); } @@ -279,7 +279,7 @@ static void xml_parser_consume(struct xml_parser* parser, size_t n) { /* Debug information */ - #ifdef DEBUG + #ifdef XML_PARSER_VERBOSE #define min(X,Y) ((X) < (Y) ? (X) : (Y)) char* consumed = alloca((n + 1) * sizeof(char)); memcpy(consumed, &parser->buffer[parser->position], min(n, parser->length - parser->position));