diff options
| author | Huon Wilson <dbau.pp+github@gmail.com> | 2013-06-29 11:19:14 +1000 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2013-06-30 21:15:25 +1000 |
| commit | 562dea1820e51f7e87cdeef4024eb9e58c7800d0 (patch) | |
| tree | c6a6ebdd572b9688b0d9a9a0e13578a948b4a52a | |
| parent | 9e83b2fe556aaf779261503c0910bf378e45dce4 (diff) | |
| download | rust-562dea1820e51f7e87cdeef4024eb9e58c7800d0.tar.gz rust-562dea1820e51f7e87cdeef4024eb9e58c7800d0.zip | |
etc: update etc/unicode.py for the changes made to std::unicode.
| -rwxr-xr-x | src/etc/unicode.py | 34 | ||||
| -rw-r--r-- | src/libstd/unicode.rs | 3 |
2 files changed, 25 insertions, 12 deletions
diff --git a/src/etc/unicode.py b/src/etc/unicode.py index afb3d168480..191338b3cb4 100755 --- a/src/etc/unicode.py +++ b/src/etc/unicode.py @@ -122,14 +122,14 @@ def ch_prefix(ix): def emit_bsearch_range_table(f): f.write(""" - pure fn bsearch_range_table(c: char, r: &[(char,char)]) -> bool { - use cmp::{EQ, LT, GT}; + fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool { + use cmp::{Equal, Less, Greater}; use vec::bsearch; use option::None; (do bsearch(r) |&(lo,hi)| { - if lo <= c && c <= hi { EQ } - else if hi < c { LT } - else { GT } + if lo <= c && c <= hi { Equal } + else if hi < c { Less } + else { Greater } }) != None }\n\n """); @@ -140,7 +140,7 @@ def emit_property_module(f, mod, tbl): keys.sort() emit_bsearch_range_table(f); for cat in keys: - f.write(" const %s_table : &[(char,char)] = &[\n" % cat) + f.write(" static %s_table : &'static [(char,char)] = &[\n" % cat) ix = 0 for pair in tbl[cat]: f.write(ch_prefix(ix)) @@ -148,7 +148,7 @@ def emit_property_module(f, mod, tbl): ix += 1 f.write("\n ];\n\n") - f.write(" pub pure fn %s(c: char) -> bool {\n" % cat) + f.write(" pub fn %s(c: char) -> bool {\n" % cat) f.write(" bsearch_range_table(c, %s_table)\n" % cat) f.write(" }\n\n") f.write("}\n") @@ -159,7 +159,7 @@ def emit_property_module_old(f, mod, tbl): keys = tbl.keys() keys.sort() for cat in keys: - f.write(" pure fn %s(c: char) -> bool {\n" % cat) + f.write(" fn %s(c: char) -> bool {\n" % cat) f.write(" ret alt c {\n") prefix = ' ' for pair in tbl[cat]: @@ -236,8 +236,22 @@ rf = open(r, "w") (canon_decomp, compat_decomp, gencats) = load_unicode_data("UnicodeData.txt") -# Explain that the source code was generated by this script. -rf.write('// The following code was generated by "src/etc/unicode.py"\n\n') +# Preamble +rf.write('''// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// The following code was generated by "src/etc/unicode.py" + +#[allow(missing_doc)]; + +''') emit_property_module(rf, "general_category", gencats) diff --git a/src/libstd/unicode.rs b/src/libstd/unicode.rs index f8f56c75a29..fd95588d712 100644 --- a/src/libstd/unicode.rs +++ b/src/libstd/unicode.rs @@ -1447,10 +1447,8 @@ pub mod general_category { } } - pub mod derived_property { - fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool { use cmp::{Equal, Less, Greater}; use vec::bsearch; @@ -2641,4 +2639,5 @@ pub mod derived_property { pub fn XID_Start(c: char) -> bool { bsearch_range_table(c, XID_Start_table) } + } |
