diff options
author | deva <deva> | 2008-05-20 14:03:10 +0000 |
---|---|---|
committer | deva <deva> | 2008-05-20 14:03:10 +0000 |
commit | 556f00e4af55e78836c45f47b0662ab44bbb8b48 (patch) | |
tree | a5c315b35d400a397a35a86b86fe656d3a829af9 /server/src/saxparser.cc | |
parent | 91d56787bec83a3a7c2ad6afd84d2b82c5d869b9 (diff) |
Made fixes pointed out by GCC 4.2 and -D_FORTIFY_SOURCES=2
Diffstat (limited to 'server/src/saxparser.cc')
-rw-r--r-- | server/src/saxparser.cc | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/server/src/saxparser.cc b/server/src/saxparser.cc index e8e9eb4..5580e5b 100644 --- a/server/src/saxparser.cc +++ b/server/src/saxparser.cc @@ -90,10 +90,8 @@ int SAXParser::parse() do { len = readData(buf, sizeof(buf) - 1); if (! XML_Parse(p, buf, len, len == 0)) { - fprintf(stderr, "Parse error at line %d:\n%s\n", - (int)XML_GetCurrentLineNumber(p), - XML_ErrorString(XML_GetErrorCode(p))); - return -1; + parseError(buf, len, XML_ErrorString(XML_GetErrorCode(p)), (int)XML_GetCurrentLineNumber(p)); + return 1; } memset(buf, 0, sizeof(buf)); @@ -102,6 +100,16 @@ int SAXParser::parse() return 0; } +void SAXParser::parseError(char *buf, size_t len, std::string error, int lineno) +{ + fprintf(stderr, "SAXParser error at line %d: %s\n", lineno, error.c_str()); + fprintf(stderr, "\tBuffer %u bytes: [", len); + if(fwrite(buf, len, 1, stderr) != len) {} + fprintf(stderr, "]\n"); + fflush(stderr); +} + + #ifdef TEST_SAXPARSER /** * Compile with: g++ -DTEST_SAXPARSER sax_parser.cc -lexpat -otext_saxparser |