Skip to content

Commit 562dea1

Browse files
committed
etc: update etc/unicode.py for the changes made to std::unicode.
1 parent 9e83b2f commit 562dea1

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

src/etc/unicode.py

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,14 @@ def ch_prefix(ix):
122122

123123
def emit_bsearch_range_table(f):
124124
f.write("""
125-
pure fn bsearch_range_table(c: char, r: &[(char,char)]) -> bool {
126-
use cmp::{EQ, LT, GT};
125+
fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool {
126+
use cmp::{Equal, Less, Greater};
127127
use vec::bsearch;
128128
use option::None;
129129
(do bsearch(r) |&(lo,hi)| {
130-
if lo <= c && c <= hi { EQ }
131-
else if hi < c { LT }
132-
else { GT }
130+
if lo <= c && c <= hi { Equal }
131+
else if hi < c { Less }
132+
else { Greater }
133133
}) != None
134134
}\n\n
135135
""");
@@ -140,15 +140,15 @@ def emit_property_module(f, mod, tbl):
140140
keys.sort()
141141
emit_bsearch_range_table(f);
142142
for cat in keys:
143-
f.write(" const %s_table : &[(char,char)] = &[\n" % cat)
143+
f.write(" static %s_table : &'static [(char,char)] = &[\n" % cat)
144144
ix = 0
145145
for pair in tbl[cat]:
146146
f.write(ch_prefix(ix))
147147
f.write("(%s, %s)" % (escape_char(pair[0]), escape_char(pair[1])))
148148
ix += 1
149149
f.write("\n ];\n\n")
150150

151-
f.write(" pub pure fn %s(c: char) -> bool {\n" % cat)
151+
f.write(" pub fn %s(c: char) -> bool {\n" % cat)
152152
f.write(" bsearch_range_table(c, %s_table)\n" % cat)
153153
f.write(" }\n\n")
154154
f.write("}\n")
@@ -159,7 +159,7 @@ def emit_property_module_old(f, mod, tbl):
159159
keys = tbl.keys()
160160
keys.sort()
161161
for cat in keys:
162-
f.write(" pure fn %s(c: char) -> bool {\n" % cat)
162+
f.write(" fn %s(c: char) -> bool {\n" % cat)
163163
f.write(" ret alt c {\n")
164164
prefix = ' '
165165
for pair in tbl[cat]:
@@ -236,8 +236,22 @@ def emit_decomp_module(f, canon, compat):
236236

237237
(canon_decomp, compat_decomp, gencats) = load_unicode_data("UnicodeData.txt")
238238

239-
# Explain that the source code was generated by this script.
240-
rf.write('// The following code was generated by "src/etc/unicode.py"\n\n')
239+
# Preamble
240+
rf.write('''// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
241+
// file at the top-level directory of this distribution and at
242+
// http://rust-lang.org/COPYRIGHT.
243+
//
244+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
245+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
246+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
247+
// option. This file may not be copied, modified, or distributed
248+
// except according to those terms.
249+
250+
// The following code was generated by "src/etc/unicode.py"
251+
252+
#[allow(missing_doc)];
253+
254+
''')
241255

242256
emit_property_module(rf, "general_category", gencats)
243257

src/libstd/unicode.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,10 +1447,8 @@ pub mod general_category {
14471447
}
14481448

14491449
}
1450-
14511450
pub mod derived_property {
14521451

1453-
14541452
fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool {
14551453
use cmp::{Equal, Less, Greater};
14561454
use vec::bsearch;
@@ -2641,4 +2639,5 @@ pub mod derived_property {
26412639
pub fn XID_Start(c: char) -> bool {
26422640
bsearch_range_table(c, XID_Start_table)
26432641
}
2642+
26442643
}

0 commit comments

Comments
 (0)