Skip to content

Commit 74525c3

Browse files
committed
---
yaml --- r: 154065 b: refs/heads/try2 c: 1ae1461 h: refs/heads/master i: 154063: bb55b04 v: v3
1 parent ad158f7 commit 74525c3

File tree

24 files changed

+253
-679
lines changed

24 files changed

+253
-679
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 9de20198aedb3c3419ee503755e04bcc198d3a94
8+
refs/heads/try2: 1ae1461fbf59db8db5dd2fe11bbe22c6adeb1aed
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/etc/unicode.py

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -464,26 +464,13 @@ def emit_charwidth_module(f, width_table):
464464
pfun=lambda x: "(%s,%s,%s,%s)" % (escape_char(x[0]), escape_char(x[1]), x[2], x[3]))
465465
f.write("}\n\n")
466466

467-
def emit_norm_module(f, canon, compat, combine, norm_props):
467+
def emit_norm_module(f, canon, compat, combine):
468468
canon_keys = canon.keys()
469469
canon_keys.sort()
470470

471471
compat_keys = compat.keys()
472472
compat_keys.sort()
473473

474-
canon_comp = {}
475-
comp_exclusions = norm_props["Full_Composition_Exclusion"]
476-
for char in canon_keys:
477-
if True in map(lambda (lo, hi): lo <= char <= hi, comp_exclusions):
478-
continue
479-
decomp = canon[char]
480-
if len(decomp) == 2:
481-
if not canon_comp.has_key(decomp[0]):
482-
canon_comp[decomp[0]] = []
483-
canon_comp[decomp[0]].append( (decomp[1], char) )
484-
canon_comp_keys = canon_comp.keys()
485-
canon_comp_keys.sort()
486-
487474
f.write("pub mod normalization {\n")
488475

489476
def mkdata_fun(table):
@@ -507,22 +494,6 @@ def f(char):
507494
emit_table(f, "compatibility_table", compat_keys, "&'static [(char, &'static [char])]",
508495
pfun=mkdata_fun(compat))
509496

510-
def comp_pfun(char):
511-
data = "(%s,&[" % escape_char(char)
512-
canon_comp[char].sort(lambda x, y: x[0] - y[0])
513-
first = True
514-
for pair in canon_comp[char]:
515-
if not first:
516-
data += ","
517-
first = False
518-
data += "(%s,%s)" % (escape_char(pair[0]), escape_char(pair[1]))
519-
data += "])"
520-
return data
521-
522-
f.write(" // Canonical compositions\n")
523-
emit_table(f, "composition_table", canon_comp_keys,
524-
"&'static [(char, &'static [(char, char)])]", pfun=comp_pfun)
525-
526497
f.write("""
527498
fn bsearch_range_value_table(c: char, r: &'static [(char, char, u8)]) -> u8 {
528499
use core::option::{Some, None};
@@ -608,8 +579,6 @@ def optimize_width_table(wtable):
608579
scripts = load_properties("Scripts.txt", [])
609580
props = load_properties("PropList.txt",
610581
["White_Space", "Join_Control", "Noncharacter_Code_Point"])
611-
norm_props = load_properties("DerivedNormalizationProps.txt",
612-
["Full_Composition_Exclusion"])
613582

614583
# grapheme cluster category from DerivedCoreProperties
615584
# the rest are defined below
@@ -643,7 +612,7 @@ def optimize_width_table(wtable):
643612
emit_regex_module(rf, allcats, perl_words)
644613

645614
# normalizations and conversions module
646-
emit_norm_module(rf, canon_decomp, compat_decomp, combines, norm_props)
615+
emit_norm_module(rf, canon_decomp, compat_decomp, combines)
647616
emit_conversions_module(rf, lowerupper, upperlower)
648617

649618
### character width module

branches/try2/src/liballoc/heap.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ mod imp {
136136
use libc::{c_char, c_int, c_void, size_t};
137137

138138
#[link(name = "jemalloc", kind = "static")]
139+
#[cfg(not(test))]
140+
extern {}
141+
139142
extern {
140143
fn je_mallocx(size: size_t, flags: c_int) -> *mut c_void;
141144
fn je_rallocx(ptr: *mut c_void, size: size_t,

branches/try2/src/libcollections/str.rs

Lines changed: 30 additions & 198 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,8 @@ use core::cmp;
7777
use core::iter::AdditiveIterator;
7878
use core::mem;
7979

80-
use {Collection, Deque, MutableSeq};
80+
use {Collection, MutableSeq};
8181
use hash;
82-
use ringbuf::RingBuf;
8382
use string::String;
8483
use unicode;
8584
use vec::Vec;
@@ -303,106 +302,6 @@ impl<'a> Iterator<char> for Decompositions<'a> {
303302
}
304303
}
305304

306-
#[deriving(Clone)]
307-
enum RecompositionState {
308-
Composing,
309-
Purging,
310-
Finished
311-
}
312-
313-
/// External iterator for a string's recomposition's characters.
314-
/// Use with the `std::iter` module.
315-
#[deriving(Clone)]
316-
pub struct Recompositions<'a> {
317-
iter: Decompositions<'a>,
318-
state: RecompositionState,
319-
buffer: RingBuf<char>,
320-
composee: Option<char>,
321-
last_ccc: Option<u8>
322-
}
323-
324-
impl<'a> Iterator<char> for Recompositions<'a> {
325-
#[inline]
326-
fn next(&mut self) -> Option<char> {
327-
loop {
328-
match self.state {
329-
Composing => {
330-
for ch in self.iter {
331-
let ch_class = unicode::char::canonical_combining_class(ch);
332-
if self.composee.is_none() {
333-
if ch_class != 0 {
334-
return Some(ch);
335-
}
336-
self.composee = Some(ch);
337-
continue;
338-
}
339-
let k = self.composee.clone().unwrap();
340-
341-
match self.last_ccc {
342-
None => {
343-
match unicode::char::compose(k, ch) {
344-
Some(r) => {
345-
self.composee = Some(r);
346-
continue;
347-
}
348-
None => {
349-
if ch_class == 0 {
350-
self.composee = Some(ch);
351-
return Some(k);
352-
}
353-
self.buffer.push(ch);
354-
self.last_ccc = Some(ch_class);
355-
}
356-
}
357-
}
358-
Some(l_class) => {
359-
if l_class >= ch_class {
360-
// `ch` is blocked from `composee`
361-
if ch_class == 0 {
362-
self.composee = Some(ch);
363-
self.last_ccc = None;
364-
self.state = Purging;
365-
return Some(k);
366-
}
367-
self.buffer.push(ch);
368-
self.last_ccc = Some(ch_class);
369-
continue;
370-
}
371-
match unicode::char::compose(k, ch) {
372-
Some(r) => {
373-
self.composee = Some(r);
374-
continue;
375-
}
376-
None => {
377-
self.buffer.push(ch);
378-
self.last_ccc = Some(ch_class);
379-
}
380-
}
381-
}
382-
}
383-
}
384-
self.state = Finished;
385-
if self.composee.is_some() {
386-
return self.composee.take();
387-
}
388-
}
389-
Purging => {
390-
match self.buffer.pop_front() {
391-
None => self.state = Composing,
392-
s => return s
393-
}
394-
}
395-
Finished => {
396-
match self.buffer.pop_front() {
397-
None => return self.composee.take(),
398-
s => return s
399-
}
400-
}
401-
}
402-
}
403-
}
404-
}
405-
406305
/// Replace all occurrences of one string with another
407306
///
408307
/// # Arguments
@@ -845,32 +744,6 @@ pub trait StrAllocating: Str {
845744
kind: Compatible
846745
}
847746
}
848-
849-
/// An Iterator over the string in Unicode Normalization Form C
850-
/// (canonical decomposition followed by canonical composition).
851-
#[inline]
852-
fn nfc_chars<'a>(&'a self) -> Recompositions<'a> {
853-
Recompositions {
854-
iter: self.nfd_chars(),
855-
state: Composing,
856-
buffer: RingBuf::new(),
857-
composee: None,
858-
last_ccc: None
859-
}
860-
}
861-
862-
/// An Iterator over the string in Unicode Normalization Form KC
863-
/// (compatibility decomposition followed by canonical composition).
864-
#[inline]
865-
fn nfkc_chars<'a>(&'a self) -> Recompositions<'a> {
866-
Recompositions {
867-
iter: self.nfkd_chars(),
868-
state: Composing,
869-
buffer: RingBuf::new(),
870-
composee: None,
871-
last_ccc: None
872-
}
873-
}
874747
}
875748

876749
impl<'a> StrAllocating for &'a str {
@@ -1881,80 +1754,39 @@ mod tests {
18811754

18821755
#[test]
18831756
fn test_nfd_chars() {
1884-
macro_rules! t {
1885-
($input: expr, $expected: expr) => {
1886-
assert_eq!($input.nfd_chars().collect::<String>(), $expected.into_string());
1887-
}
1888-
}
1889-
t!("abc", "abc");
1890-
t!("\u1e0b\u01c4", "d\u0307\u01c4");
1891-
t!("\u2026", "\u2026");
1892-
t!("\u2126", "\u03a9");
1893-
t!("\u1e0b\u0323", "d\u0323\u0307");
1894-
t!("\u1e0d\u0307", "d\u0323\u0307");
1895-
t!("a\u0301", "a\u0301");
1896-
t!("\u0301a", "\u0301a");
1897-
t!("\ud4db", "\u1111\u1171\u11b6");
1898-
t!("\uac1c", "\u1100\u1162");
1757+
assert_eq!("abc".nfd_chars().collect::<String>(), String::from_str("abc"));
1758+
assert_eq!("\u1e0b\u01c4".nfd_chars().collect::<String>(),
1759+
String::from_str("d\u0307\u01c4"));
1760+
assert_eq!("\u2026".nfd_chars().collect::<String>(), String::from_str("\u2026"));
1761+
assert_eq!("\u2126".nfd_chars().collect::<String>(), String::from_str("\u03a9"));
1762+
assert_eq!("\u1e0b\u0323".nfd_chars().collect::<String>(),
1763+
String::from_str("d\u0323\u0307"));
1764+
assert_eq!("\u1e0d\u0307".nfd_chars().collect::<String>(),
1765+
String::from_str("d\u0323\u0307"));
1766+
assert_eq!("a\u0301".nfd_chars().collect::<String>(), String::from_str("a\u0301"));
1767+
assert_eq!("\u0301a".nfd_chars().collect::<String>(), String::from_str("\u0301a"));
1768+
assert_eq!("\ud4db".nfd_chars().collect::<String>(),
1769+
String::from_str("\u1111\u1171\u11b6"));
1770+
assert_eq!("\uac1c".nfd_chars().collect::<String>(), String::from_str("\u1100\u1162"));
18991771
}
19001772

19011773
#[test]
19021774
fn test_nfkd_chars() {
1903-
macro_rules! t {
1904-
($input: expr, $expected: expr) => {
1905-
assert_eq!($input.nfkd_chars().collect::<String>(), $expected.into_string());
1906-
}
1907-
}
1908-
t!("abc", "abc");
1909-
t!("\u1e0b\u01c4", "d\u0307DZ\u030c");
1910-
t!("\u2026", "...");
1911-
t!("\u2126", "\u03a9");
1912-
t!("\u1e0b\u0323", "d\u0323\u0307");
1913-
t!("\u1e0d\u0307", "d\u0323\u0307");
1914-
t!("a\u0301", "a\u0301");
1915-
t!("\u0301a", "\u0301a");
1916-
t!("\ud4db", "\u1111\u1171\u11b6");
1917-
t!("\uac1c", "\u1100\u1162");
1918-
}
1919-
1920-
#[test]
1921-
fn test_nfc_chars() {
1922-
macro_rules! t {
1923-
($input: expr, $expected: expr) => {
1924-
assert_eq!($input.nfc_chars().collect::<String>(), $expected.into_string());
1925-
}
1926-
}
1927-
t!("abc", "abc");
1928-
t!("\u1e0b\u01c4", "\u1e0b\u01c4");
1929-
t!("\u2026", "\u2026");
1930-
t!("\u2126", "\u03a9");
1931-
t!("\u1e0b\u0323", "\u1e0d\u0307");
1932-
t!("\u1e0d\u0307", "\u1e0d\u0307");
1933-
t!("a\u0301", "\xe1");
1934-
t!("\u0301a", "\u0301a");
1935-
t!("\ud4db", "\ud4db");
1936-
t!("\uac1c", "\uac1c");
1937-
t!("a\u0300\u0305\u0315\u05aeb", "\xe0\u05ae\u0305\u0315b");
1938-
}
1939-
1940-
#[test]
1941-
fn test_nfkc_chars() {
1942-
macro_rules! t {
1943-
($input: expr, $expected: expr) => {
1944-
assert_eq!($input.nfkc_chars().collect::<String>(), $expected.into_string());
1945-
}
1946-
}
1947-
t!("abc", "abc");
1948-
t!("\u1e0b\u01c4", "\u1e0bD\u017d");
1949-
t!("\u2026", "...");
1950-
t!("\u2126", "\u03a9");
1951-
t!("\u1e0b\u0323", "\u1e0d\u0307");
1952-
t!("\u1e0d\u0307", "\u1e0d\u0307");
1953-
t!("a\u0301", "\xe1");
1954-
t!("\u0301a", "\u0301a");
1955-
t!("\ud4db", "\ud4db");
1956-
t!("\uac1c", "\uac1c");
1957-
t!("a\u0300\u0305\u0315\u05aeb", "\xe0\u05ae\u0305\u0315b");
1775+
assert_eq!("abc".nfkd_chars().collect::<String>(), String::from_str("abc"));
1776+
assert_eq!("\u1e0b\u01c4".nfkd_chars().collect::<String>(),
1777+
String::from_str("d\u0307DZ\u030c"));
1778+
assert_eq!("\u2026".nfkd_chars().collect::<String>(), String::from_str("..."));
1779+
assert_eq!("\u2126".nfkd_chars().collect::<String>(), String::from_str("\u03a9"));
1780+
assert_eq!("\u1e0b\u0323".nfkd_chars().collect::<String>(),
1781+
String::from_str("d\u0323\u0307"));
1782+
assert_eq!("\u1e0d\u0307".nfkd_chars().collect::<String>(),
1783+
String::from_str("d\u0323\u0307"));
1784+
assert_eq!("a\u0301".nfkd_chars().collect::<String>(), String::from_str("a\u0301"));
1785+
assert_eq!("\u0301a".nfkd_chars().collect::<String>(),
1786+
String::from_str("\u0301a"));
1787+
assert_eq!("\ud4db".nfkd_chars().collect::<String>(),
1788+
String::from_str("\u1111\u1171\u11b6"));
1789+
assert_eq!("\uac1c".nfkd_chars().collect::<String>(), String::from_str("\u1100\u1162"));
19581790
}
19591791

19601792
#[test]

0 commit comments

Comments
 (0)