@@ -72,8 +72,8 @@ def is_surrogate(n):
72
72
def load_unicode_data (f ):
73
73
fetch (f )
74
74
gencats = {}
75
- upperlower = {}
76
- lowerupper = {}
75
+ to_lower = {}
76
+ to_upper = {}
77
77
combines = {}
78
78
canon_decomp = {}
79
79
compat_decomp = {}
@@ -103,12 +103,12 @@ def load_unicode_data(f):
103
103
104
104
# generate char to char direct common and simple conversions
105
105
# uppercase to lowercase
106
- if gencat == "Lu" and lowcase != "" and code_org != lowcase :
107
- upperlower [code ] = int (lowcase , 16 )
106
+ if lowcase != "" and code_org != lowcase :
107
+ to_lower [code ] = int (lowcase , 16 )
108
108
109
109
# lowercase to uppercase
110
- if gencat == "Ll" and upcase != "" and code_org != upcase :
111
- lowerupper [code ] = int (upcase , 16 )
110
+ if upcase != "" and code_org != upcase :
111
+ to_upper [code ] = int (upcase , 16 )
112
112
113
113
# store decomposition, if given
114
114
if decomp != "" :
@@ -144,7 +144,7 @@ def load_unicode_data(f):
144
144
gencats = group_cats (gencats )
145
145
combines = to_combines (group_cats (combines ))
146
146
147
- return (canon_decomp , compat_decomp , gencats , combines , lowerupper , upperlower )
147
+ return (canon_decomp , compat_decomp , gencats , combines , to_upper , to_lower )
148
148
149
149
def group_cats (cats ):
150
150
cats_out = {}
@@ -319,7 +319,7 @@ def emit_property_module(f, mod, tbl, emit):
319
319
f .write (" }\n \n " )
320
320
f .write ("}\n \n " )
321
321
322
- def emit_conversions_module (f , lowerupper , upperlower ):
322
+ def emit_conversions_module (f , to_upper , to_lower ):
323
323
f .write ("pub mod conversions {" )
324
324
f .write ("""
325
325
use core::cmp::Ordering::{Equal, Less, Greater};
@@ -329,16 +329,16 @@ def emit_conversions_module(f, lowerupper, upperlower):
329
329
use core::result::Result::{Ok, Err};
330
330
331
331
pub fn to_lower(c: char) -> char {
332
- match bsearch_case_table(c, LuLl_table ) {
332
+ match bsearch_case_table(c, to_lowercase_table ) {
333
333
None => c,
334
- Some(index) => LuLl_table [index].1
334
+ Some(index) => to_lowercase_table [index].1
335
335
}
336
336
}
337
337
338
338
pub fn to_upper(c: char) -> char {
339
- match bsearch_case_table(c, LlLu_table ) {
339
+ match bsearch_case_table(c, to_uppercase_table ) {
340
340
None => c,
341
- Some(index) => LlLu_table [index].1
341
+ Some(index) => to_uppercase_table [index].1
342
342
}
343
343
}
344
344
@@ -354,10 +354,10 @@ def emit_conversions_module(f, lowerupper, upperlower):
354
354
}
355
355
356
356
""" )
357
- emit_table (f , "LuLl_table " ,
358
- sorted (upperlower .iteritems (), key = operator .itemgetter (0 )), is_pub = False )
359
- emit_table (f , "LlLu_table " ,
360
- sorted (lowerupper .iteritems (), key = operator .itemgetter (0 )), is_pub = False )
357
+ emit_table (f , "to_lowercase_table " ,
358
+ sorted (to_lower .iteritems (), key = operator .itemgetter (0 )), is_pub = False )
359
+ emit_table (f , "to_uppercase_table " ,
360
+ sorted (to_upper .iteritems (), key = operator .itemgetter (0 )), is_pub = False )
361
361
f .write ("}\n \n " )
362
362
363
363
def emit_grapheme_module (f , grapheme_table , grapheme_cats ):
@@ -591,7 +591,7 @@ def optimize_width_table(wtable):
591
591
pub const UNICODE_VERSION: (u64, u64, u64) = (%s, %s, %s);
592
592
""" % unicode_version )
593
593
(canon_decomp , compat_decomp , gencats , combines ,
594
- lowerupper , upperlower ) = load_unicode_data ("UnicodeData.txt" )
594
+ to_upper , to_lower ) = load_unicode_data ("UnicodeData.txt" )
595
595
want_derived = ["XID_Start" , "XID_Continue" , "Alphabetic" , "Lowercase" , "Uppercase" ]
596
596
derived = load_properties ("DerivedCoreProperties.txt" , want_derived )
597
597
scripts = load_properties ("Scripts.txt" , [])
@@ -611,7 +611,7 @@ def optimize_width_table(wtable):
611
611
612
612
# normalizations and conversions module
613
613
emit_norm_module (rf , canon_decomp , compat_decomp , combines , norm_props )
614
- emit_conversions_module (rf , lowerupper , upperlower )
614
+ emit_conversions_module (rf , to_upper , to_lower )
615
615
616
616
### character width module
617
617
width_table = []
0 commit comments