while (p < limit) {
int32_t d = u_digit(rule.charAt(p++), radix); if (d < 0) {
--p; break;
}
++count;
int32_t v = (value * radix) + d; if (v <= value) { // If there are too many input digits, at some point // the value will go negative, e.g., if we have seen // "0x8000000" already and there is another '0', when // we parse the next 0 the value will go negative. return0;
}
value = v;
} if (count > 0) {
pos = p;
} return value;
}
/** *Parseapatternstringstartingatoffsetpos.Keywordsare *matchedcase-insensitively.Spacesmaybeskippedandmaybe *optionalorrequired.Integervaluesmaybeparsed,andif *theyare,theywillbereturnedinthegivenarray.If *successful,theoffsetofthenextnon-spacecharacteris *returned.Onfailure,-1isreturned. *@parampatternmustonlycontainlowercasecharacters,which *willmatchtheiruppercaseequivalentsaswell.Aspace *charactermatchesoneormorerequiredspaces.A'~'character *matcheszeroormoreoptionalspaces.A'#'charactermatches *anintegerandstoresitinparsedInts,whichthecallermust *ensurehasenoughcapacity. *@paramparsedIntsarraytoreceiveparsedintegers.Caller *mustensurethatparsedInts.lengthis>=thenumberof'#' *signsin'pattern'. *@returnthepositionafterthelastcharacterparsed,or-1if *theparsefailed
*/
int32_t ICU_Utility::parsePattern(const UnicodeString& rule, int32_t pos, int32_t limit, const UnicodeString& pattern, int32_t* parsedInts) { // TODO Update this to handle surrogates
int32_t p;
int32_t intCount = 0; // number of integers parsed for (int32_t i=0; i<pattern.length(); ++i) {
char16_t cpat = pattern.charAt(i);
char16_t c; switch (cpat) { case32/*' '*/: if (pos >= limit) { return -1;
}
c = rule.charAt(pos++); if (!PatternProps::isWhiteSpace(c)) { return -1;
} // FALL THROUGH to skipWhitespace
U_FALLTHROUGH; case126/*'~'*/:
pos = skipWhitespace(rule, pos); break; case35/*'#'*/:
p = pos;
parsedInts[intCount++] = parseInteger(rule, p, limit); if (p == pos) { // Syntax error; failed to parse integer return -1;
}
pos = p; break; default: if (pos >= limit) { return -1;
}
c = static_cast<char16_t>(u_tolower(rule.charAt(pos++))); if (c != cpat) { return -1;
} break;
}
} return pos;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.