@@ -72,8 +72,8 @@ def is_surrogate(n):
7272def load_unicode_data (f ):
7373 fetch (f )
7474 gencats = {}
75- upperlower = {}
76- lowerupper = {}
75+ to_lower = {}
76+ to_upper = {}
7777 combines = {}
7878 canon_decomp = {}
7979 compat_decomp = {}
@@ -103,12 +103,12 @@ def load_unicode_data(f):
103103
104104 # generate char to char direct common and simple conversions
105105 # 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 )
108108
109109 # 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 )
112112
113113 # store decomposition, if given
114114 if decomp != "" :
@@ -144,7 +144,7 @@ def load_unicode_data(f):
144144 gencats = group_cats (gencats )
145145 combines = to_combines (group_cats (combines ))
146146
147- return (canon_decomp , compat_decomp , gencats , combines , lowerupper , upperlower )
147+ return (canon_decomp , compat_decomp , gencats , combines , to_upper , to_lower )
148148
149149def group_cats (cats ):
150150 cats_out = {}
@@ -319,7 +319,7 @@ def emit_property_module(f, mod, tbl, emit):
319319 f .write (" }\n \n " )
320320 f .write ("}\n \n " )
321321
322- def emit_conversions_module (f , lowerupper , upperlower ):
322+ def emit_conversions_module (f , to_upper , to_lower ):
323323 f .write ("pub mod conversions {" )
324324 f .write ("""
325325 use core::cmp::Ordering::{Equal, Less, Greater};
@@ -329,16 +329,16 @@ def emit_conversions_module(f, lowerupper, upperlower):
329329 use core::result::Result::{Ok, Err};
330330
331331 pub fn to_lower(c: char) -> char {
332- match bsearch_case_table(c, LuLl_table ) {
332+ match bsearch_case_table(c, to_lowercase_table ) {
333333 None => c,
334- Some(index) => LuLl_table [index].1
334+ Some(index) => to_lowercase_table [index].1
335335 }
336336 }
337337
338338 pub fn to_upper(c: char) -> char {
339- match bsearch_case_table(c, LlLu_table ) {
339+ match bsearch_case_table(c, to_uppercase_table ) {
340340 None => c,
341- Some(index) => LlLu_table [index].1
341+ Some(index) => to_uppercase_table [index].1
342342 }
343343 }
344344
@@ -354,10 +354,10 @@ def emit_conversions_module(f, lowerupper, upperlower):
354354 }
355355
356356""" )
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 )
361361 f .write ("}\n \n " )
362362
363363def emit_grapheme_module (f , grapheme_table , grapheme_cats ):
@@ -591,7 +591,7 @@ def optimize_width_table(wtable):
591591pub const UNICODE_VERSION: (u64, u64, u64) = (%s, %s, %s);
592592""" % unicode_version )
593593 (canon_decomp , compat_decomp , gencats , combines ,
594- lowerupper , upperlower ) = load_unicode_data ("UnicodeData.txt" )
594+ to_upper , to_lower ) = load_unicode_data ("UnicodeData.txt" )
595595 want_derived = ["XID_Start" , "XID_Continue" , "Alphabetic" , "Lowercase" , "Uppercase" ]
596596 derived = load_properties ("DerivedCoreProperties.txt" , want_derived )
597597 scripts = load_properties ("Scripts.txt" , [])
@@ -611,7 +611,7 @@ def optimize_width_table(wtable):
611611
612612 # normalizations and conversions module
613613 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 )
615615
616616 ### character width module
617617 width_table = []
0 commit comments