diff options
Diffstat (limited to 'src/lib/util/xmlfile.cpp')
-rw-r--r-- | src/lib/util/xmlfile.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/lib/util/xmlfile.cpp b/src/lib/util/xmlfile.cpp index 39604a29a87..db8d87930e2 100644 --- a/src/lib/util/xmlfile.cpp +++ b/src/lib/util/xmlfile.cpp @@ -41,14 +41,14 @@ constexpr unsigned TEMP_BUFFER_SIZE(4096U); void write_escaped(core_file &file, std::string const &str) { + // FIXME: check for errors std::string::size_type pos = 0; while ((str.size() > pos) && (std::string::npos != pos)) { std::string::size_type const found = str.find_first_of("\"&<>", pos); if (found != std::string::npos) { - std::size_t written; - file.write(&str[pos], found - pos, written); + write(file, &str[pos], found - pos); switch (str[found]) { case '"': file.puts("""); pos = found + 1; break; @@ -60,8 +60,7 @@ void write_escaped(core_file &file, std::string const &str) } else { - std::size_t written; - file.write(&str[pos], str.size() - pos, written); + write(file, &str[pos], str.size() - pos); pos = found; } } @@ -77,10 +76,12 @@ void write_escaped(core_file &file, std::string const &str) struct parse_info { + parse_info() { memset(&parser, 0, sizeof(parser)); } + XML_Parser parser; file::ptr rootnode; - data_node * curnode; - uint32_t flags; + data_node * curnode = nullptr; + uint32_t flags = 0; }; @@ -134,8 +135,7 @@ file::ptr file::read(read_stream &file, parse_options const *opts) char tempbuf[TEMP_BUFFER_SIZE]; // read as much as we can - size_t bytes; - file.read(tempbuf, sizeof(tempbuf), bytes); // TODO: better error handling + auto const [err, bytes] = util::read(file, tempbuf, sizeof(tempbuf)); // FIXME: better error handling done = !bytes; // parse the data @@ -815,7 +815,7 @@ std::string normalize_string(std::string_view string) static bool expat_setup_parser(parse_info &info, parse_options const *opts) { // setup info structure - memset(&info, 0, sizeof(info)); + info = parse_info(); if (opts != nullptr) { info.flags = opts->flags; |