Skip to content

Commit fa4ae96

Browse files
committed
Fixed asymmetric behavior for case-insensitive matches
1 parent 84237cb commit fa4ae96

3 files changed

Lines changed: 108 additions & 17 deletions

File tree

java/com/google/re2j/UnicodeTables.java

Lines changed: 99 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/*
2-
* Copyright (c) 2020 The Go Authors. All rights reserved.
2+
* Copyright (c) 2026 The Go Authors. All rights reserved.
33
*
44
* Use of this source code is governed by a BSD-style
55
* license that can be found in the LICENSE file.
66
*/
7-
// Generated at 2020-06-09T16:20:06.352Z by Java 1.8.0_181 using Unicode version 6.0.0.0.
7+
// Generated at 2026-04-09T23:48:18.149Z by Java 1.8.0_472 using Unicode version 6.0.0.0.
88
// Do not change this file, your edits will be lost. Instead change UnicodeTablesGenerator.java.
99
package com.google.re2j;
1010

@@ -4189,20 +4189,103 @@ private static int[][] make_foldLu() {
41894189

41904190
private static int[][] make_foldLl() {
41914191
return new int[][] {
4192-
{0x004B, 0x0053, 8},
4193-
{0x00C5, 0x01C4, 255},
4194-
{0x01C5, 0x01C7, 2},
4195-
{0x01C8, 0x01CA, 2},
4196-
{0x01CB, 0x01F1, 38},
4197-
{0x01F2, 0x0345, 339},
4198-
{0x0392, 0x0398, 3},
4199-
{0x0399, 0x039A, 1},
4200-
{0x039C, 0x03A0, 4},
4201-
{0x03A1, 0x03A3, 2},
4202-
{0x03A6, 0x03A9, 3},
4203-
{0x03F4, 0x1E60, 6764},
4204-
{0x1E9E, 0x2126, 648},
4205-
{0x212A, 0x212B, 1}
4192+
{0x0041, 0x005A, 1},
4193+
{0x00C0, 0x00D6, 1},
4194+
{0x00D8, 0x00DE, 1},
4195+
{0x0100, 0x012E, 2},
4196+
{0x0132, 0x0136, 2},
4197+
{0x0139, 0x0147, 2},
4198+
{0x014A, 0x0178, 2},
4199+
{0x0179, 0x017D, 2},
4200+
{0x0181, 0x0182, 1},
4201+
{0x0184, 0x0186, 2},
4202+
{0x0187, 0x0189, 2},
4203+
{0x018A, 0x018B, 1},
4204+
{0x018E, 0x0191, 1},
4205+
{0x0193, 0x0194, 1},
4206+
{0x0196, 0x0198, 1},
4207+
{0x019C, 0x019D, 1},
4208+
{0x019F, 0x01A0, 1},
4209+
{0x01A2, 0x01A6, 2},
4210+
{0x01A7, 0x01A9, 2},
4211+
{0x01AC, 0x01AE, 2},
4212+
{0x01AF, 0x01B1, 2},
4213+
{0x01B2, 0x01B3, 1},
4214+
{0x01B5, 0x01B7, 2},
4215+
{0x01B8, 0x01BC, 4},
4216+
{0x01C4, 0x01C5, 1},
4217+
{0x01C7, 0x01C8, 1},
4218+
{0x01CA, 0x01CB, 1},
4219+
{0x01CD, 0x01DB, 2},
4220+
{0x01DE, 0x01EE, 2},
4221+
{0x01F1, 0x01F2, 1},
4222+
{0x01F4, 0x01F6, 2},
4223+
{0x01F7, 0x01F8, 1},
4224+
{0x01FA, 0x0232, 2},
4225+
{0x023A, 0x023B, 1},
4226+
{0x023D, 0x023E, 1},
4227+
{0x0241, 0x0243, 2},
4228+
{0x0244, 0x0246, 1},
4229+
{0x0248, 0x024E, 2},
4230+
{0x0345, 0x0370, 43},
4231+
{0x0372, 0x0376, 4},
4232+
{0x0386, 0x0388, 2},
4233+
{0x0389, 0x038A, 1},
4234+
{0x038C, 0x038E, 2},
4235+
{0x038F, 0x0391, 2},
4236+
{0x0392, 0x03A1, 1},
4237+
{0x03A3, 0x03AB, 1},
4238+
{0x03CF, 0x03D8, 9},
4239+
{0x03DA, 0x03EE, 2},
4240+
{0x03F4, 0x03F7, 3},
4241+
{0x03F9, 0x03FA, 1},
4242+
{0x03FD, 0x042F, 1},
4243+
{0x0460, 0x0480, 2},
4244+
{0x048A, 0x04C0, 2},
4245+
{0x04C1, 0x04CD, 2},
4246+
{0x04D0, 0x0526, 2},
4247+
{0x0531, 0x0556, 1},
4248+
{0x10A0, 0x10C5, 1},
4249+
{0x1E00, 0x1E94, 2},
4250+
{0x1E9E, 0x1EFE, 2},
4251+
{0x1F08, 0x1F0F, 1},
4252+
{0x1F18, 0x1F1D, 1},
4253+
{0x1F28, 0x1F2F, 1},
4254+
{0x1F38, 0x1F3F, 1},
4255+
{0x1F48, 0x1F4D, 1},
4256+
{0x1F59, 0x1F5F, 2},
4257+
{0x1F68, 0x1F6F, 1},
4258+
{0x1F88, 0x1F8F, 1},
4259+
{0x1F98, 0x1F9F, 1},
4260+
{0x1FA8, 0x1FAF, 1},
4261+
{0x1FB8, 0x1FBC, 1},
4262+
{0x1FC8, 0x1FCC, 1},
4263+
{0x1FD8, 0x1FDB, 1},
4264+
{0x1FE8, 0x1FEC, 1},
4265+
{0x1FF8, 0x1FFC, 1},
4266+
{0x2126, 0x212A, 4},
4267+
{0x212B, 0x2132, 7},
4268+
{0x2183, 0x2C00, 2685},
4269+
{0x2C01, 0x2C2E, 1},
4270+
{0x2C60, 0x2C62, 2},
4271+
{0x2C63, 0x2C64, 1},
4272+
{0x2C67, 0x2C6D, 2},
4273+
{0x2C6E, 0x2C70, 1},
4274+
{0x2C72, 0x2C75, 3},
4275+
{0x2C7E, 0x2C80, 1},
4276+
{0x2C82, 0x2CE2, 2},
4277+
{0x2CEB, 0x2CED, 2},
4278+
{0xA640, 0xA66C, 2},
4279+
{0xA680, 0xA696, 2},
4280+
{0xA722, 0xA72E, 2},
4281+
{0xA732, 0xA76E, 2},
4282+
{0xA779, 0xA77D, 2},
4283+
{0xA77E, 0xA786, 2},
4284+
{0xA78B, 0xA78D, 2},
4285+
{0xA790, 0xA7A0, 16},
4286+
{0xA7A2, 0xA7A8, 2},
4287+
{0xFF21, 0xFF3A, 1},
4288+
{0x10400, 0x10427, 1}
42064289
};
42074290
}
42084291

javatests/com/google/re2j/MatcherTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,4 +524,12 @@ public void testPatternLongestMatch() {
524524
assertEquals("aaa bbb", text.substring(matcher.start(), matcher.end()));
525525
}
526526
}
527+
528+
@Test
529+
public void testMatchCategoryCaseInsensitive() {
530+
assertTrue(Pattern.compile("(?i)\\p{Ll}").matches("A"));
531+
assertTrue(Pattern.compile("(?i)\\p{Ll}").matches("a"));
532+
assertTrue(Pattern.compile("(?i)\\p{Lu}").matches("A"));
533+
assertTrue(Pattern.compile("(?i)\\p{Lu}").matches("a"));
534+
}
527535
}

unicode/src/main/java/com/google/re2j/UnicodeTablesGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ private boolean addFoldExceptions(String name, Set<Integer> codepointClass) {
363363
for (int codepoint : codepointClass) {
364364
if (!sortedOrbits.containsKey(codepoint)) {
365365
// Just uppercase and lowercase.
366-
int u = UCharacter.toLowerCase(codepoint);
366+
int u = UCharacter.toUpperCase(codepoint);
367367
if (u != codepoint) {
368368
exceptionCodepoints.add(u);
369369
}

0 commit comments

Comments
 (0)