Fixed xml.c verbosity in debug builds. See [Issue 1](https://github.com/ooxi/xml.c/issues/1)master
@@ -4,5 +4,5 @@ compiler: | |||||
before_install: | before_install: | ||||
- sudo apt-get install cmake valgrind | - sudo apt-get install cmake valgrind | ||||
script: | 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 | |||||
@@ -10,6 +10,13 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR) | |||||
SET(CMAKE_C_FLAGS_DEBUG "-g -DDEBUG") | SET(CMAKE_C_FLAGS_DEBUG "-g -DDEBUG") | ||||
SET(CMAKE_C_FLAGS_RELEASE "-O2") | 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 | # Sources | ||||
SET(SOURCE_DIRECTORY src) | SET(SOURCE_DIRECTORY src) | ||||
@@ -196,7 +196,7 @@ static void xml_node_free(struct xml_node* node) { | |||||
* | * | ||||
* Echos the parsers call stack for debugging purposes | * 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) { | static void xml_parser_info(struct xml_parser* parser, char const* message) { | ||||
fprintf(stdout, "xml_parser_info %s\n", 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 | /* Debug information | ||||
*/ | */ | ||||
#ifdef DEBUG | |||||
#ifdef XML_PARSER_VERBOSE | |||||
#define min(X,Y) ((X) < (Y) ? (X) : (Y)) | #define min(X,Y) ((X) < (Y) ? (X) : (Y)) | ||||
char* consumed = alloca((n + 1) * sizeof(char)); | char* consumed = alloca((n + 1) * sizeof(char)); | ||||
memcpy(consumed, &parser->buffer[parser->position], min(n, parser->length - parser->position)); | memcpy(consumed, &parser->buffer[parser->position], min(n, parser->length - parser->position)); | ||||