Skip to content

Commit 4517f0f

Browse files
committed
---
yaml --- r: 66483 b: refs/heads/master c: 562dea1 h: refs/heads/master i: 66481: 25b2616 66479: 1ad0de5 v: v3
1 parent 617cf38 commit 4517f0f

File tree

3 files changed

+26
-13
lines changed

3 files changed

+26
-13
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: 9e83b2fe556aaf779261503c0910bf378e45dce4
2+
refs/heads/master: 562dea1820e51f7e87cdeef4024eb9e58c7800d0
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 18e3db7392d2d0697b7e27d6d986139960144d85
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9

trunk/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

trunk/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)