From 562dea1820e51f7e87cdeef4024eb9e58c7800d0 Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Sat, 29 Jun 2013 11:19:14 +1000 Subject: [PATCH] etc: update etc/unicode.py for the changes made to std::unicode. --- src/etc/unicode.py | 34 ++++++++++++++++++++++++---------- 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 or the MIT license +// , 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 fn Zs(c: char) -> bool { } } - 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 fn XID_Continue(c: char) -> bool { pub fn XID_Start(c: char) -> bool { bsearch_range_table(c, XID_Start_table) } + } -- GitLab