am 371de969: am a1f5e82f: am a30063d8: am 25eb0464: Merge "Normalize output from aapt d"
* commit '371de9695508073fbbde8181eb230e99cb045206': Normalize output from aapt d
This commit is contained in:
commit
36373fcf15
@ -1985,6 +1985,7 @@ public:
|
|||||||
|
|
||||||
#ifndef HAVE_ANDROID_OS
|
#ifndef HAVE_ANDROID_OS
|
||||||
void print(bool inclValues) const;
|
void print(bool inclValues) const;
|
||||||
|
static String8 normalizeForOutput(const char* input);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -4141,6 +4141,38 @@ void print_complex(uint32_t complex, bool isFraction)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Normalize a string for output
|
||||||
|
String8 ResTable::normalizeForOutput( const char *input )
|
||||||
|
{
|
||||||
|
String8 ret;
|
||||||
|
char buff[2];
|
||||||
|
buff[1] = '\0';
|
||||||
|
|
||||||
|
while (*input != '\0') {
|
||||||
|
switch (*input) {
|
||||||
|
// All interesting characters are in the ASCII zone, so we are making our own lives
|
||||||
|
// easier by scanning the string one byte at a time.
|
||||||
|
case '\\':
|
||||||
|
ret += "\\\\";
|
||||||
|
break;
|
||||||
|
case '\n':
|
||||||
|
ret += "\\n";
|
||||||
|
break;
|
||||||
|
case '"':
|
||||||
|
ret += "\\\"";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
buff[0] = *input;
|
||||||
|
ret += buff;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
input++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void ResTable::print_value(const Package* pkg, const Res_value& value) const
|
void ResTable::print_value(const Package* pkg, const Res_value& value) const
|
||||||
{
|
{
|
||||||
if (value.dataType == Res_value::TYPE_NULL) {
|
if (value.dataType == Res_value::TYPE_NULL) {
|
||||||
@ -4154,13 +4186,13 @@ void ResTable::print_value(const Package* pkg, const Res_value& value) const
|
|||||||
const char* str8 = pkg->header->values.string8At(
|
const char* str8 = pkg->header->values.string8At(
|
||||||
value.data, &len);
|
value.data, &len);
|
||||||
if (str8 != NULL) {
|
if (str8 != NULL) {
|
||||||
printf("(string8) \"%s\"\n", str8);
|
printf("(string8) \"%s\"\n", normalizeForOutput(str8).string());
|
||||||
} else {
|
} else {
|
||||||
const char16_t* str16 = pkg->header->values.stringAt(
|
const char16_t* str16 = pkg->header->values.stringAt(
|
||||||
value.data, &len);
|
value.data, &len);
|
||||||
if (str16 != NULL) {
|
if (str16 != NULL) {
|
||||||
printf("(string16) \"%s\"\n",
|
printf("(string16) \"%s\"\n",
|
||||||
String8(str16, len).string());
|
normalizeForOutput(String8(str16, len).string()).string());
|
||||||
} else {
|
} else {
|
||||||
printf("(string) null\n");
|
printf("(string) null\n");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user