Skip to content

Commit d21f282

Browse files
Florobalexcrichton
authored andcommitted
---
yaml --- r: 114079 b: refs/heads/master c: 74ad023 h: refs/heads/master i: 114077: cd911de 114075: 7114d2a 114071: d65ef3d 114063: df3aa77 114047: 9c09d6a v: v3
1 parent add8914 commit d21f282

File tree

4 files changed

+86
-62
lines changed

4 files changed

+86
-62
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 21867fa1279c38189faccfb430c8bd6bffe0ef9e
2+
refs/heads/master: 74ad0236747469f9646916d1916dee2598076161
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ec0258a381b88b5574e3f8ce72ae553ac3a574b7
55
refs/heads/try: 7c6c492fb2af9a85f21ff952942df3523b22fd17

trunk/src/etc/unicode.py

Lines changed: 76 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def emit_bsearch_range_table(f):
169169
else if hi < c { Less }
170170
else { Greater }
171171
}) != None
172-
}\n\n
172+
}\n
173173
""");
174174

175175
def emit_property_module(f, mod, tbl):
@@ -193,11 +193,11 @@ def emit_property_module(f, mod, tbl):
193193
f.write(" pub fn %s(c: char) -> bool {\n" % cat)
194194
f.write(" super::bsearch_range_table(c, %s_table)\n" % cat)
195195
f.write(" }\n\n")
196-
f.write("}\n")
196+
f.write("}\n\n")
197197

198198

199199
def emit_conversions_module(f, lowerupper, upperlower):
200-
f.write("pub mod conversions {\n")
200+
f.write("pub mod conversions {")
201201
f.write("""
202202
use cmp::{Equal, Less, Greater};
203203
use slice::ImmutableVector;
@@ -225,13 +225,14 @@ def emit_conversions_module(f, lowerupper, upperlower):
225225
else { Greater }
226226
})
227227
}
228+
228229
""");
229230
emit_caseconversion_table(f, "LuLl", upperlower)
230231
emit_caseconversion_table(f, "LlLu", lowerupper)
231232
f.write("}\n")
232233

233234
def emit_caseconversion_table(f, name, table):
234-
f.write(" static %s_table : &'static [(char, char)] = &[\n" % name)
235+
f.write(" static %s_table : &'static [(char, char)] = &[\n" % name)
235236
sorted_table = sorted(table.iteritems(), key=operator.itemgetter(0))
236237
ix = 0
237238
for key, value in sorted_table:
@@ -255,7 +256,7 @@ def format_table_content(f, content, indent):
255256
line = " "*indent + chunk
256257
f.write(line)
257258

258-
def emit_decomp_module(f, canon, compat, combine):
259+
def emit_core_decomp_module(f, canon, compat):
259260
canon_keys = canon.keys()
260261
canon_keys.sort()
261262

@@ -279,23 +280,6 @@ def emit_decomp_module(f, canon, compat, combine):
279280
}
280281
None => None
281282
}
282-
}\n
283-
""")
284-
285-
f.write("""
286-
fn bsearch_range_value_table(c: char, r: &'static [(char, char, u8)]) -> u8 {
287-
use cmp::{Equal, Less, Greater};
288-
match r.bsearch(|&(lo, hi, _)| {
289-
if lo <= c && c <= hi { Equal }
290-
else if hi < c { Less }
291-
else { Greater }
292-
}) {
293-
Some(idx) => {
294-
let (_, _, result) = r[idx];
295-
result
296-
}
297-
None => 0
298-
}
299283
}\n\n
300284
""")
301285

@@ -337,21 +321,10 @@ def emit_decomp_module(f, canon, compat, combine):
337321
format_table_content(f, data, 8)
338322
f.write("\n ];\n\n")
339323

340-
f.write(" static combining_class_table : &'static [(char, char, u8)] = &[\n")
341-
ix = 0
342-
for pair in combine:
343-
f.write(ch_prefix(ix))
344-
f.write("(%s, %s, %s)" % (escape_char(pair[0]), escape_char(pair[1]), pair[2]))
345-
ix += 1
346-
f.write("\n ];\n")
347-
348324
f.write(" pub fn canonical(c: char, i: |char|) "
349325
+ "{ d(c, i, false); }\n\n")
350326
f.write(" pub fn compatibility(c: char, i: |char|) "
351327
+"{ d(c, i, true); }\n\n")
352-
f.write(" pub fn canonical_combining_class(c: char) -> u8 {\n"
353-
+ " bsearch_range_value_table(c, combining_class_table)\n"
354-
+ " }\n\n")
355328
f.write(" fn d(c: char, i: |char|, k: bool) {\n")
356329
f.write(" use iter::Iterator;\n");
357330

@@ -389,17 +362,43 @@ def emit_decomp_module(f, canon, compat, combine):
389362
f.write(" }\n")
390363
f.write("}\n\n")
391364

392-
r = "unicode.rs"
393-
for i in [r]:
394-
if os.path.exists(i):
395-
os.remove(i);
396-
rf = open(r, "w")
365+
def emit_std_decomp_module(f, combine):
366+
f.write("pub mod decompose {\n");
367+
f.write(" use option::{Some, None};\n");
368+
f.write(" use slice::ImmutableVector;\n");
397369

398-
(canon_decomp, compat_decomp, gencats,
399-
combines, lowerupper, upperlower) = load_unicode_data("UnicodeData.txt")
370+
f.write("""
371+
fn bsearch_range_value_table(c: char, r: &'static [(char, char, u8)]) -> u8 {
372+
use cmp::{Equal, Less, Greater};
373+
match r.bsearch(|&(lo, hi, _)| {
374+
if lo <= c && c <= hi { Equal }
375+
else if hi < c { Less }
376+
else { Greater }
377+
}) {
378+
Some(idx) => {
379+
let (_, _, result) = r[idx];
380+
result
381+
}
382+
None => 0
383+
}
384+
}\n\n
385+
""")
386+
387+
f.write(" static combining_class_table : &'static [(char, char, u8)] = &[\n")
388+
ix = 0
389+
for pair in combine:
390+
f.write(ch_prefix(ix))
391+
f.write("(%s, %s, %s)" % (escape_char(pair[0]), escape_char(pair[1]), pair[2]))
392+
ix += 1
393+
f.write("\n ];\n\n")
400394

401-
# Preamble
402-
rf.write('''// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
395+
f.write(" pub fn canonical_combining_class(c: char) -> u8 {\n"
396+
+ " bsearch_range_value_table(c, combining_class_table)\n"
397+
+ " }\n")
398+
f.write("}\n")
399+
400+
401+
preamble = '''// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
403402
// file at the top-level directory of this distribution and at
404403
// http://rust-lang.org/COPYRIGHT.
405404
//
@@ -409,23 +408,45 @@ def emit_decomp_module(f, canon, compat, combine):
409408
// option. This file may not be copied, modified, or distributed
410409
// except according to those terms.
411410
412-
// The following code was generated by "src/etc/unicode.py"
411+
// NOTE: The following code was generated by "src/etc/unicode.py", do not edit directly
412+
413+
#![allow(missing_doc, non_uppercase_statics)]
414+
415+
'''
416+
417+
(canon_decomp, compat_decomp, gencats,
418+
combines, lowerupper, upperlower) = load_unicode_data("UnicodeData.txt")
419+
420+
def gen_core_unicode():
421+
r = "core_unicode.rs"
422+
if os.path.exists(r):
423+
os.remove(r);
424+
with open(r, "w") as rf:
425+
# Preamble
426+
rf.write(preamble)
413427

414-
#![allow(missing_doc)]
415-
#![allow(non_uppercase_statics)]
428+
emit_bsearch_range_table(rf);
429+
emit_property_module(rf, "general_category", gencats)
416430

417-
''')
431+
emit_core_decomp_module(rf, canon_decomp, compat_decomp)
418432

419-
emit_bsearch_range_table(rf);
420-
emit_property_module(rf, "general_category", gencats)
433+
derived = load_properties("DerivedCoreProperties.txt",
434+
["XID_Start", "XID_Continue", "Alphabetic", "Lowercase", "Uppercase"])
421435

422-
emit_decomp_module(rf, canon_decomp, compat_decomp, combines)
436+
emit_property_module(rf, "derived_property", derived)
423437

424-
derived = load_properties("DerivedCoreProperties.txt",
425-
["XID_Start", "XID_Continue", "Alphabetic", "Lowercase", "Uppercase"])
438+
props = load_properties("PropList.txt", ["White_Space"])
439+
emit_property_module(rf, "property", props)
440+
emit_conversions_module(rf, lowerupper, upperlower)
426441

427-
emit_property_module(rf, "derived_property", derived)
442+
def gen_std_unicode():
443+
r = "std_unicode.rs"
444+
if os.path.exists(r):
445+
os.remove(r);
446+
with open(r, "w") as rf:
447+
# Preamble
448+
rf.write(preamble)
449+
emit_std_decomp_module(rf, combines)
428450

429-
props = load_properties("PropList.txt", ["White_Space"])
430-
emit_property_module(rf, "property", props)
431-
emit_conversions_module(rf, lowerupper, upperlower)
451+
gen_core_unicode()
452+
gen_std_unicode()

trunk/src/libcore/unicode.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -8,10 +8,11 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// The following code was generated by "src/etc/unicode.py"
11+
// NOTE: The following code was generated by "src/etc/unicode.py", do not edit directly
1212

1313
#![allow(missing_doc, non_uppercase_statics)]
1414

15+
1516
fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool {
1617
use cmp::{Equal, Less, Greater};
1718
use slice::ImmutableVector;
@@ -102,6 +103,7 @@ pub mod general_category {
102103
}
103104

104105
}
106+
105107
pub mod decompose {
106108
use option::Option;
107109
use option::{Some, None};
@@ -123,7 +125,6 @@ pub mod decompose {
123125
}
124126

125127

126-
127128
// Canonical decompositions
128129
static canonical_table : &'static [(char, &'static [char])] = &[
129130
('\xc0', &['\x41', '\u0300']), ('\xc1', &['\x41', '\u0301']), ('\xc2', &['\x41', '\u0302']),
@@ -3968,6 +3969,7 @@ pub mod derived_property {
39683969
pub fn XID_Start(c: char) -> bool {
39693970
super::bsearch_range_table(c, XID_Start_table)
39703971
}
3972+
39713973
}
39723974

39733975
pub mod property {
@@ -3983,6 +3985,7 @@ pub mod property {
39833985
pub fn White_Space(c: char) -> bool {
39843986
super::bsearch_range_table(c, White_Space_table)
39853987
}
3988+
39863989
}
39873990

39883991
pub mod conversions {
@@ -4501,7 +4504,7 @@ pub mod conversions {
45014504
('\U00010426', '\U0001044e'), ('\U00010427', '\U0001044f')
45024505
];
45034506

4504-
static LlLu_table : &'static [(char, char)] = &[
4507+
static LlLu_table : &'static [(char, char)] = &[
45054508
('\x61', '\x41'), ('\x62', '\x42'),
45064509
('\x63', '\x43'), ('\x64', '\x44'),
45074510
('\x65', '\x45'), ('\x66', '\x46'),

trunk/src/libstd/unicode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// The following code was generated by "src/etc/unicode.py"
11+
// NOTE: The following code was generated by "src/etc/unicode.py", do not edit directly
1212

1313
#![allow(missing_doc, non_uppercase_statics)]
1414

0 commit comments

Comments
 (0)