MCPcopy Create free account
hub / github.com/google/re2j / parseInt

Method parseInt

java/com/google/re2j/Parser.java:1166–1180  ·  view source on GitHub ↗
(StringIterator t)

Source from the content-addressed store, hash-verified

1164 // parseInt parses a nonnegative decimal integer.
1165 // -1 => bad format. -2 => format ok, but integer overflow.
1166 private static int parseInt(StringIterator t) {
1167 int start = t.pos();
1168 int c;
1169 while (t.more() && (c = t.peek()) >= '0' && c <= '9') {
1170 t.skip(1); // digit
1171 }
1172 String n = t.from(start);
1173 if (n.isEmpty() || (n.length() > 1 && n.charAt(0) == '0')) { // disallow leading zeros
1174 return -1; // bad format
1175 }
1176 if (n.length() > 8) {
1177 return -2; // overflow
1178 }
1179 return Integer.valueOf(n, 10); // can't fail
1180 }
1181
1182 // can this be represented as a character class?
1183 // single-rune literal string, char class, ., and .|\n.

Callers 3

parseRepeatMethod · 0.95
parseResultMethod · 0.80
RE2TestNumSubexpsMethod · 0.80

Calls 7

posMethod · 0.80
moreMethod · 0.80
peekMethod · 0.80
fromMethod · 0.80
isEmptyMethod · 0.80
skipMethod · 0.45
lengthMethod · 0.45

Tested by 2

parseResultMethod · 0.64
RE2TestNumSubexpsMethod · 0.64