Skip to content

Commit 98470d3

Browse files
hansonrhansonr
authored andcommitted
Scanner - POSIX javaWhiteSpace and whiteSpace; more efficient numbers
1 parent c2239a7 commit 98470d3

File tree

7 files changed

+6
-7
lines changed

7 files changed

+6
-7
lines changed
31 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20201205151557
1+
20201205180144
31 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20201205151557
1+
20201205180144
31 Bytes
Binary file not shown.

sources/net.sf.j2s.java.core/src/java/util/Scanner.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,12 +447,12 @@ private static Pattern boolPattern() {
447447
private String non0Digit = "[1-9]";//"[\\p{javaDigit}&&[^0]]";
448448
private int SIMPLE_GROUP_INDEX = 12; // SwingJS - moved simple to later
449449
private String buildIntegerPatternString() {
450-
String radixDigits = (radix == 10 ? "0-9" : digits.substring(0, radix) + digits.substring(10, radix).toUpperCase());
450+
String radixDigits = (radix == 10 ? "\\d" : radix < 10 ? "[" + digits.substring(0, radix) + "]" : "[0-9a-" + digits.charAt(radix - 1) + "A-" + digits.substring(radix-1, radix).toUpperCase() + "]");
451451
// \\p{javaDigit} is not guaranteed to be appropriate
452452
// here but what can we do? The final authority will be
453453
// whatever parse method is invoked, so ultimately the
454454
// Scanner will do the right thing
455-
String digit = "(["+radixDigits+"])";//\\p{javaDigit})";
455+
String digit = "("+radixDigits+")";//\\p{javaDigit})";
456456
String groupedNumeral = "("+non0Digit+digit+"?"+digit+"?("+
457457
groupSeparator+digit+digit+digit+")+)";
458458
// digit++ is the possessive form which is necessary for reducing

sources/net.sf.j2s.java.core/src/java/util/regex/Pattern.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,8 +1794,8 @@ private Pattern(String p, int f) {
17941794
}
17951795

17961796
private final static String[] posixes = {
1797-
"\\p{javaWhitespace}","\\W",
1798-
"\\p{javaDigit}","[0-9]",
1797+
"\\p{javaWhitespace}","\\s",
1798+
"\\p{javaDigit}","\\d",
17991799
"\\p{Lower}", "[a-z]",
18001800
"\\p{Upper}", "[A-Z]",
18011801
"\\p{ASCII}", "[\u0000-\u007F]",
@@ -1811,7 +1811,6 @@ private Pattern(String p, int f) {
18111811
"\\p{Space}", "[ \t\n\u000B\f\r]",
18121812
"\\p{javaLowerCase}", "[a-z]",
18131813
"\\p{javaUpperCase}", "[A-Z]",
1814-
"\\p{javaWhitespace}", "\\W",
18151814
"\\p{Sc}", "[\u0024\u00A2\u00A3\u00A4\u00A5\u058F\u060B\u07FE\u07FF\u09F2\u09F3\u09FB\u0AF1\u0BF9\u0E3F\u20A0\u20A1\u20A2\u20A3\u20A4\u20A5\u20A6\u20A7\u20A8\u20A9\u20AA\u20AB\u20AC\u20AD\u20AE\u20AF\u20B0\u20B1\u20B2\u20B3\u20B4\u20B5\u20B6\u20B7\u20B8\u20B9\u20BA\u20BB\u20BC\u20BD\u20BE\u20BF\uA838\uFDFC\uFE69\uFF04\uFFE0\uFFE1\uFFE5\uFFE6]"
18161815

18171816
// more currency: \u11FDD\u11FDE\u11FDF\u11FE0\u17DB\u1E2FF\u1ECB0

0 commit comments

Comments
 (0)