AAPT2: Fix windows unicode path issues
Mingw64 was being difficult, so instead of defining a wmain entrypoint,
the command line parameters are parsed manually using built-in Windows
methods that support Unicode. The results are converted to UTF8 and
handled just like the rest of the linux/mac version of the code.
This also removes dependencies on std::istream in favour of a
FileInputStream which calls the appropriate unicode version of
open to read a file.
No speed regressions found on Linux or MacOS.
Bug: 62336414
Bug: 63830502
Test: manual
Change-Id: I597da51e33729ed1b98bf246e7e773337fd3fee8
diff --git a/tools/aapt2/xml/XmlPullParser.h b/tools/aapt2/xml/XmlPullParser.h
index cdeeefd..a00caa1 100644
--- a/tools/aapt2/xml/XmlPullParser.h
+++ b/tools/aapt2/xml/XmlPullParser.h
@@ -31,6 +31,7 @@
#include "androidfw/StringPiece.h"
#include "Resource.h"
+#include "io/Io.h"
#include "process/IResourceTableConsumer.h"
#include "util/Maybe.h"
#include "xml/XmlUtil.h"
@@ -64,7 +65,7 @@
static bool SkipCurrentElement(XmlPullParser* parser);
static bool IsGoodEvent(Event event);
- explicit XmlPullParser(std::istream& in);
+ explicit XmlPullParser(io::InputStream* in);
~XmlPullParser();
/**
@@ -169,9 +170,8 @@
std::vector<Attribute> attributes;
};
- std::istream& in_;
+ io::InputStream* in_;
XML_Parser parser_;
- char buffer_[16384];
std::queue<EventData> event_queue_;
std::string error_;
const std::string empty_;
@@ -228,18 +228,15 @@
return out;
}
-inline bool XmlPullParser::NextChildNode(XmlPullParser* parser,
- size_t start_depth) {
+inline bool XmlPullParser::NextChildNode(XmlPullParser* parser, size_t start_depth) {
Event event;
// First get back to the start depth.
- while (IsGoodEvent(event = parser->Next()) &&
- parser->depth() > start_depth + 1) {
+ while (IsGoodEvent(event = parser->Next()) && parser->depth() > start_depth + 1) {
}
// Now look for the first good node.
- while ((event != Event::kEndElement || parser->depth() > start_depth) &&
- IsGoodEvent(event)) {
+ while ((event != Event::kEndElement || parser->depth() > start_depth) && IsGoodEvent(event)) {
switch (event) {
case Event::kText:
case Event::kComment: