瀏覽代碼

Merge pull request #4 from ooxi/verbose

Fixed xml.c verbosity in debug builds. See [Issue 1](https://github.com/ooxi/xml.c/issues/1)
master
ooxi 11 年之前
父節點
當前提交
86c7895077
共有 3 個檔案被更改,包括 10 行新增3 行删除
  1. +1
    -1
      .travis.yml
  2. +7
    -0
      CMakeLists.txt
  3. +2
    -2
      src/xml.c

+ 1
- 1
.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


+ 7
- 0
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)


+ 2
- 2
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));


Loading…
取消
儲存