MCPcopy Create free account
hub / github.com/CyanogenMod/android_frameworks_base / hasSubstitutionErrors

Function hasSubstitutionErrors

tools/aapt/XMLNode.cpp:79–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77}
78
79status_t hasSubstitutionErrors(const char* fileName,
80 ResXMLTree* inXml,
81 String16 str16)
82{
83 const char16_t* str = str16.string();
84 const char16_t* p = str;
85 const char16_t* end = str + str16.size();
86
87 bool nonpositional = false;
88 int argCount = 0;
89
90 while (p < end) {
91 /*
92 * Look for the start of a Java-style substitution sequence.
93 */
94 if (*p == '%' && p + 1 < end) {
95 p++;
96
97 // A literal percent sign represented by %%
98 if (*p == '%') {
99 p++;
100 continue;
101 }
102
103 argCount++;
104
105 if (*p >= '0' && *p <= '9') {
106 do {
107 p++;
108 } while (*p >= '0' && *p <= '9');
109 if (*p != '$') {
110 // This must be a size specification instead of position.
111 nonpositional = true;
112 }
113 } else if (*p == '<') {
114 // Reusing last argument; bad idea since it can be re-arranged.
115 nonpositional = true;
116 p++;
117
118 // Optionally '$' can be specified at the end.
119 if (p < end && *p == '$') {
120 p++;
121 }
122 } else {
123 nonpositional = true;
124 }
125
126 // Ignore flags and widths
127 while (p < end && (*p == '-' ||
128 *p == '#' ||
129 *p == '+' ||
130 *p == ' ' ||
131 *p == ',' ||
132 *p == '(' ||
133 (*p >= '0' && *p <= '9'))) {
134 p++;
135 }
136

Callers 1

parseStyledStringFunction · 0.85

Calls 5

SourcePosClass · 0.85
stringMethod · 0.80
sizeMethod · 0.65
errorMethod · 0.65
getLineNumberMethod · 0.45

Tested by

no test coverage detected