commit c7208eae258b304fe2822f9be6c07cfd843cc6d3 Author: Daniel Swanson Date: Tue Jun 1 18:16:18 2021 -0500 lt-comp seems to be working now diff --git a/lttoolbox/compiler.cc b/lttoolbox/compiler.cc index b498c5d..d4186f2 100644 --- a/lttoolbox/compiler.cc +++ b/lttoolbox/compiler.cc @@ -202,7 +202,7 @@ Compiler::procAlphabet() void Compiler::procSDef() { - alphabet.includeSymbol("<"_u+attrib(COMPILER_N_ATTR)+">"_u); + alphabet.includeSymbol("<"_u + attrib(COMPILER_N_ATTR) + ">"_u); } void diff --git a/lttoolbox/xml_parse_util.cc b/lttoolbox/xml_parse_util.cc index 7c8161a..4b507a6 100644 --- a/lttoolbox/xml_parse_util.cc +++ b/lttoolbox/xml_parse_util.cc @@ -18,32 +18,31 @@ #include #include +#include using namespace std; UString XMLParseUtil::attrib(xmlTextReaderPtr reader, UString const &name) { - xmlChar *attrname = xmlCharStrdup(to_char(name)); - xmlChar *myattr = xmlTextReaderGetAttribute(reader, attrname); - UString result = to_ustring(reinterpret_cast(myattr)); - xmlFree(myattr); - xmlFree(attrname); - return result; + return attrib(reader, name, ""_u); } UString XMLParseUtil::attrib(xmlTextReaderPtr reader, UString const &name, const UString fallback) { - xmlChar *attrname = xmlCharStrdup(to_char(name)); + std::string temp; + temp.reserve(name.size()); + utf8::utf16to8(name.begin(), name.end(), std::back_inserter(temp)); + xmlChar *attrname = xmlCharStrdup(temp.c_str()); xmlChar *myattr = xmlTextReaderGetAttribute(reader, attrname); - UString result = to_ustring(reinterpret_cast(myattr)); - xmlFree(myattr); xmlFree(attrname); if(myattr == NULL) { + xmlFree(myattr); return fallback; - } - else { + } else { + UString result = to_ustring(reinterpret_cast(myattr)); + xmlFree(myattr); return result; } }