64
64
import org .unicode .cldr .util .Factory ;
65
65
import org .unicode .cldr .util .FileProcessor ;
66
66
import org .unicode .cldr .util .GlossonymConstructor ;
67
+ import org .unicode .cldr .util .Joiners ;
67
68
import org .unicode .cldr .util .LanguageTagParser ;
68
69
import org .unicode .cldr .util .Level ;
69
70
import org .unicode .cldr .util .LocaleIDParser ;
@@ -131,6 +132,8 @@ static final class ConfigMatch {
131
132
final ConfigAction action ;
132
133
final boolean hexPath ;
133
134
135
+ static UnicodeSet SUSPICIOUS_NON_REGEX = new UnicodeSet ("[*|]" ).freeze ();
136
+
134
137
public ConfigMatch (ConfigKeys key , String match ) {
135
138
if (key == ConfigKeys .action ) {
136
139
exactMatch = null ;
@@ -139,7 +142,8 @@ public ConfigMatch(ConfigKeys key, String match) {
139
142
hexPath = false ;
140
143
} else if (match .startsWith ("/" ) && match .endsWith ("/" )) {
141
144
if (key != ConfigKeys .locale && key != ConfigKeys .path && key != ConfigKeys .value ) {
142
- throw new IllegalArgumentException ("Regex only allowed for old path/value." );
145
+ throw new IllegalArgumentException (
146
+ "Regex only allowed for locale=, path=, or value'." );
143
147
}
144
148
exactMatch = null ;
145
149
regexMatch =
@@ -156,6 +160,17 @@ public ConfigMatch(ConfigKeys key, String match) {
156
160
hexPath =
157
161
(key == ConfigKeys .new_path || key == ConfigKeys .path )
158
162
&& HEX .containsAll (match );
163
+ if (key == ConfigKeys .locale || key == ConfigKeys .path ) {
164
+ if (SUSPICIOUS_NON_REGEX .containsSome (match )) {
165
+ System .out .println (
166
+ Joiners .ES .join (
167
+ "The value " ,
168
+ match ,
169
+ " is being matched literally, but contains regex charcters. Did you mean /" ,
170
+ match ,
171
+ "/ ?" ));
172
+ }
173
+ }
159
174
}
160
175
}
161
176
@@ -2366,7 +2381,8 @@ public void handleStart() {
2366
2381
keyValues .addAll (localeMatcher .getValue ());
2367
2382
}
2368
2383
}
2369
- System .out .println ("# Checking entries & changing:\t " + keyValues .size ());
2384
+ // System.out.println("# Checking entries & changing:\t" +
2385
+ // keyValues.size());
2370
2386
for (Map <ConfigKeys , ConfigMatch > entry : keyValues ) {
2371
2387
ConfigMatch action = entry .get (ConfigKeys .action );
2372
2388
ConfigMatch pathMatch = entry .get (ConfigKeys .path );
@@ -2479,9 +2495,12 @@ protected boolean handleLine(int lineCount, String line) {
2479
2495
myReader .process (CLDRModify .class , configFileName );
2480
2496
}
2481
2497
2482
- static final String DEBUG_PATH =
2483
- "//ldml/personNames/personName[@order=\" givenFirst\" ][@length=\" long\" ][@usage=\" referring\" ][@formality=\" formal\" ]/namePattern" ;
2498
+ final String DEBUG_PATH = null ;
2499
+
2500
+ // example:
2501
+ // "//ldml/personNames/personName[@order=\"givenFirst\"][@length=\"long\"][@usage=\"referring\"][@formality=\"formal\"]/namePattern";
2484
2502
2503
+ @ SuppressWarnings ("incomplete-switch" )
2485
2504
@ Override
2486
2505
public void handlePath (String xpath ) {
2487
2506
// slow method; could optimize
0 commit comments