From cab22f2dc3c5f41b5163f74cbb233e390edff6ff Mon Sep 17 00:00:00 2001 From: "B. Stack" Date: Tue, 11 Oct 2022 11:16:39 -0400 Subject: add upstream 11.26 --- zenXml/zenxml/dom.h | 2 +- zenXml/zenxml/xml.h | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'zenXml') diff --git a/zenXml/zenxml/dom.h b/zenXml/zenxml/dom.h index 427e89f2..5befdd7f 100644 --- a/zenXml/zenxml/dom.h +++ b/zenXml/zenxml/dom.h @@ -217,7 +217,7 @@ public: \code auto itPair = elem.getAttributes(); for (auto it = itPair.first; it != itPair.second; ++it) - std::cout << "name: " << it->name << " value: " << it->value << '\n'; + std::cout << std::string("name: ") + it->name + " value: " + it->value + '\n'; \endcode \return A pair of STL begin/end iterators to access all attributes sequentially as a list of name/value pairs of std::string. */ std::pair getAttributes() const { return {attributes_.begin(), attributes_.end()}; } diff --git a/zenXml/zenxml/xml.h b/zenXml/zenxml/xml.h index 829bb5f3..c87655ba 100644 --- a/zenXml/zenxml/xml.h +++ b/zenXml/zenxml/xml.h @@ -34,16 +34,17 @@ namespace { XmlDoc loadXml(const Zstring& filePath) //throw FileError { - FileInput fileIn(filePath, nullptr /*notifyUnbufferedIO*/); //throw FileError, ErrorFileLocked - const size_t blockSize = fileIn.getBlockSize(); + FileInputPlain fileIn(filePath); //throw FileError + const size_t blockSize = fileIn.getBlockSize(); //throw FileError const std::string xmlPrefix = " resize_and_overwrite") buffer.resize(buffer.size() + blockSize); - const size_t bytesRead = fileIn.read(&*(buffer.end() - blockSize), blockSize); //throw FileError, ErrorFileLocked, (X); return "bytesToRead" bytes unless end of stream! + const size_t bytesRead = fileIn.tryRead(&*(buffer.end() - blockSize), blockSize); //throw FileError; may return short, only 0 means EOF! CONTRACT: bytesToRead > 0! buffer.resize(buffer.size() - blockSize + bytesRead); //caveat: unsigned arithmetics //quick test whether input is an XML: avoid loading large binary files up front! @@ -55,7 +56,7 @@ XmlDoc loadXml(const Zstring& filePath) //throw FileError throw FileError(replaceCpy(_("File %x does not contain a valid configuration."), L"%x", fmtPath(filePath))); } - if (bytesRead < blockSize) //end of file + if (bytesRead == 0) //end of file break; } -- cgit