Skip to content

Commit 06e45fc

Browse files
committed
---
yaml --- r: 69497 b: refs/heads/auto c: 0ed8713 h: refs/heads/master i: 69495: 2e88115 v: v3
1 parent f42e2d8 commit 06e45fc

File tree

5 files changed

+52
-76
lines changed

5 files changed

+52
-76
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: 436d9fa45d7df98f49bc036de4254d5946478c5c
17+
refs/heads/auto: 0ed8713d79048ef865f8cbdcd2d2939190c75c2a
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1919
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c

branches/auto/src/compiletest/compiletest.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ pub fn parse_config(args: ~[~str]) -> config {
8585
if args[1] == ~"-h" || args[1] == ~"--help" {
8686
let message = fmt!("Usage: %s [OPTIONS] [TESTNAME...]", argv0);
8787
println(getopts::groups::usage(message, groups));
88-
println("");
8988
fail!()
9089
}
9190

@@ -98,7 +97,6 @@ pub fn parse_config(args: ~[~str]) -> config {
9897
if getopts::opt_present(matches, "h") || getopts::opt_present(matches, "help") {
9998
let message = fmt!("Usage: %s [OPTIONS] [TESTNAME...]", argv0);
10099
println(getopts::groups::usage(message, groups));
101-
println("");
102100
fail!()
103101
}
104102

branches/auto/src/libextra/getopts.rs

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ pub mod groups {
680680
return brief.to_owned() +
681681
"\n\nOptions:\n" +
682682
rows.collect::<~[~str]>().connect("\n") +
683-
"\n";
683+
"\n\n";
684684
}
685685

686686
/** Splits a string into substrings with possibly internal whitespace,
@@ -1318,24 +1318,41 @@ mod tests {
13181318
13191319
#[test]
13201320
fn test_multi() {
1321-
let args = ~[~"-e", ~"foo", ~"--encrypt", ~"foo"];
13221321
let opts = ~[optopt("e"), optopt("encrypt"), optopt("f")];
1323-
let matches = &match getopts(args, opts) {
1322+
1323+
let args_single = ~[~"-e", ~"foo"];
1324+
let matches_single = &match getopts(args_single, opts) {
13241325
result::Ok(m) => m,
13251326
result::Err(_) => fail!()
13261327
};
1327-
assert!(opts_present(matches, [~"e"]));
1328-
assert!(opts_present(matches, [~"encrypt"]));
1329-
assert!(opts_present(matches, [~"encrypt", ~"e"]));
1330-
assert!(opts_present(matches, [~"e", ~"encrypt"]));
1331-
assert!(!opts_present(matches, [~"f"]));
1332-
assert!(!opts_present(matches, [~"thing"]));
1333-
assert!(!opts_present(matches, []));
1328+
assert!(opts_present(matches_single, [~"e"]));
1329+
assert!(opts_present(matches_single, [~"encrypt", ~"e"]));
1330+
assert!(opts_present(matches_single, [~"e", ~"encrypt"]));
1331+
assert!(!opts_present(matches_single, [~"encrypt"]));
1332+
assert!(!opts_present(matches_single, [~"thing"]));
1333+
assert!(!opts_present(matches_single, []));
1334+
1335+
assert_eq!(opts_str(matches_single, [~"e"]), ~"foo");
1336+
assert_eq!(opts_str(matches_single, [~"e", ~"encrypt"]), ~"foo");
1337+
assert_eq!(opts_str(matches_single, [~"encrypt", ~"e"]), ~"foo");
1338+
1339+
let args_both = ~[~"-e", ~"foo", ~"--encrypt", ~"foo"];
1340+
let matches_both = &match getopts(args_both, opts) {
1341+
result::Ok(m) => m,
1342+
result::Err(_) => fail!()
1343+
};
1344+
assert!(opts_present(matches_both, [~"e"]));
1345+
assert!(opts_present(matches_both, [~"encrypt"]));
1346+
assert!(opts_present(matches_both, [~"encrypt", ~"e"]));
1347+
assert!(opts_present(matches_both, [~"e", ~"encrypt"]));
1348+
assert!(!opts_present(matches_both, [~"f"]));
1349+
assert!(!opts_present(matches_both, [~"thing"]));
1350+
assert!(!opts_present(matches_both, []));
13341351
1335-
assert_eq!(opts_str(matches, [~"e"]), ~"foo");
1336-
assert_eq!(opts_str(matches, [~"encrypt"]), ~"foo");
1337-
assert_eq!(opts_str(matches, [~"e", ~"encrypt"]), ~"foo");
1338-
assert_eq!(opts_str(matches, [~"encrypt", ~"e"]), ~"foo");
1352+
assert_eq!(opts_str(matches_both, [~"e"]), ~"foo");
1353+
assert_eq!(opts_str(matches_both, [~"encrypt"]), ~"foo");
1354+
assert_eq!(opts_str(matches_both, [~"e", ~"encrypt"]), ~"foo");
1355+
assert_eq!(opts_str(matches_both, [~"encrypt", ~"e"]), ~"foo");
13391356
}
13401357
13411358
#[test]
@@ -1463,6 +1480,7 @@ Options:
14631480
-k --kiwi Desc
14641481
-p [VAL] Desc
14651482
-l VAL Desc
1483+
14661484
";
14671485
14681486
let generated_usage = groups::usage("Usage: fruits", optgroups);
@@ -1491,6 +1509,7 @@ Options:
14911509
-k --kiwi This is a long description which won't be wrapped..+..
14921510
-a --apple This is a long description which _will_ be
14931511
wrapped..+..
1512+
14941513
";
14951514
14961515
let usage = groups::usage("Usage: fruits", optgroups);

branches/auto/src/libextra/test.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ fn optgroups() -> ~[getopts::groups::OptGroup] {
191191
fn usage(binary: &str, helpstr: &str) -> ! {
192192
let message = fmt!("Usage: %s [OPTIONS] [FILTER]", binary);
193193
println(groups::usage(message, optgroups()));
194-
println("");
195194
if helpstr == "help" {
196195
println("\
197196
The FILTER is matched against the name of all tests to run, and if any tests

branches/auto/src/libstd/str.rs

Lines changed: 18 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -564,18 +564,6 @@ fn match_at<'a,'b>(haystack: &'a str, needle: &'b str, at: uint) -> bool {
564564
Section: Misc
565565
*/
566566

567-
// Return the initial codepoint accumulator for the first byte.
568-
// The first byte is special, only want bottom 5 bits for width 2, 4 bits
569-
// for width 3, and 3 bits for width 4
570-
macro_rules! utf8_first_byte(
571-
($byte:expr, $width:expr) => (($byte & (0x7F >> $width)) as uint)
572-
)
573-
574-
// return the value of $ch updated with continuation byte $byte
575-
macro_rules! utf8_acc_cont_byte(
576-
($ch:expr, $byte:expr) => (($ch << 6) | ($byte & 63u8) as uint)
577-
)
578-
579567
/// Determines if a vector of bytes contains valid UTF-8
580568
pub fn is_utf8(v: &[u8]) -> bool {
581569
let mut i = 0u;
@@ -589,26 +577,11 @@ pub fn is_utf8(v: &[u8]) -> bool {
589577

590578
let nexti = i + w;
591579
if nexti > total { return false; }
592-
// 1. Make sure the correct number of continuation bytes are present
593-
// 2. Check codepoint ranges (deny overlong encodings)
594-
// 2-byte encoding is for codepoints \u0080 to \u07ff
595-
// 3-byte encoding is for codepoints \u0800 to \uffff
596-
// 4-byte encoding is for codepoints \u10000 to \u10ffff
597580

598-
// 2-byte encodings are correct if the width and continuation match up
599581
if v[i + 1] & 192u8 != TAG_CONT_U8 { return false; }
600582
if w > 2 {
601-
let mut ch;
602-
ch = utf8_first_byte!(v[i], w);
603-
ch = utf8_acc_cont_byte!(ch, v[i + 1]);
604583
if v[i + 2] & 192u8 != TAG_CONT_U8 { return false; }
605-
ch = utf8_acc_cont_byte!(ch, v[i + 2]);
606-
if w == 3 && ch < MAX_TWO_B { return false; }
607-
if w > 3 {
608-
if v[i + 3] & 192u8 != TAG_CONT_U8 { return false; }
609-
ch = utf8_acc_cont_byte!(ch, v[i + 3]);
610-
if ch < MAX_THREE_B || ch >= MAX_UNICODE { return false; }
611-
}
584+
if w > 3 && (v[i + 3] & 192u8 != TAG_CONT_U8) { return false; }
612585
}
613586

614587
i = nexti;
@@ -726,7 +699,7 @@ pub fn count_bytes<'b>(s: &'b str, start: uint, n: uint) -> uint {
726699
}
727700

728701
// https://tools.ietf.org/html/rfc3629
729-
priv static UTF8_CHAR_WIDTH: [u8, ..256] = [
702+
static UTF8_CHAR_WIDTH: [u8, ..256] = [
730703
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
731704
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, // 0x1F
732705
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
@@ -739,7 +712,7 @@ priv static UTF8_CHAR_WIDTH: [u8, ..256] = [
739712
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 0x9F
740713
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
741714
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 0xBF
742-
0,0,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
715+
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
743716
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, // 0xDF
744717
3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, // 0xEF
745718
4,4,4,4,4,0,0,0,0,0,0,0,0,0,0,0, // 0xFF
@@ -757,15 +730,14 @@ pub struct CharRange {
757730
}
758731

759732
// UTF-8 tags and ranges
760-
priv static TAG_CONT_U8: u8 = 128u8;
761-
priv static TAG_CONT: uint = 128u;
762-
priv static MAX_ONE_B: uint = 128u;
763-
priv static TAG_TWO_B: uint = 192u;
764-
priv static MAX_TWO_B: uint = 2048u;
765-
priv static TAG_THREE_B: uint = 224u;
766-
priv static MAX_THREE_B: uint = 65536u;
767-
priv static TAG_FOUR_B: uint = 240u;
768-
priv static MAX_UNICODE: uint = 1114112u;
733+
static TAG_CONT_U8: u8 = 128u8;
734+
static TAG_CONT: uint = 128u;
735+
static MAX_ONE_B: uint = 128u;
736+
static TAG_TWO_B: uint = 192u;
737+
static MAX_TWO_B: uint = 2048u;
738+
static TAG_THREE_B: uint = 224u;
739+
static MAX_THREE_B: uint = 65536u;
740+
static TAG_FOUR_B: uint = 240u;
769741

770742
/// Unsafe operations
771743
pub mod raw {
@@ -1693,10 +1665,12 @@ impl<'self> StrSlice<'self> for &'self str {
16931665
let w = UTF8_CHAR_WIDTH[val] as uint;
16941666
assert!((w != 0));
16951667
1696-
val = utf8_first_byte!(val, w);
1697-
val = utf8_acc_cont_byte!(val, s[i + 1]);
1698-
if w > 2 { val = utf8_acc_cont_byte!(val, s[i + 2]); }
1699-
if w > 3 { val = utf8_acc_cont_byte!(val, s[i + 3]); }
1668+
// First byte is special, only want bottom 5 bits for width 2, 4 bits
1669+
// for width 3, and 3 bits for width 4
1670+
val &= 0x7Fu >> w;
1671+
val = (val << 6) | (s[i + 1] & 63u8) as uint;
1672+
if w > 2 { val = (val << 6) | (s[i + 2] & 63u8) as uint; }
1673+
if w > 3 { val = (val << 6) | (s[i + 3] & 63u8) as uint; }
17001674
17011675
return CharRange {ch: val as char, next: i + w};
17021676
}
@@ -2061,7 +2035,7 @@ impl OwnedStr for ~str {
20612035
/// Appends a character to the back of a string
20622036
#[inline]
20632037
fn push_char(&mut self, c: char) {
2064-
assert!((c as uint) < MAX_UNICODE); // FIXME: #7609: should be enforced on all `char`
2038+
assert!(c as uint <= 0x10ffff); // FIXME: #7609: should be enforced on all `char`
20652039
unsafe {
20662040
let code = c as uint;
20672041
let nb = if code < MAX_ONE_B { 1u }
@@ -2825,23 +2799,9 @@ mod tests {
28252799
0x20_u8, 0x4e_u8, 0x61_u8,
28262800
0x6d_u8];
28272801
2828-
28292802
assert_eq!(ss, from_bytes(bb));
2830-
assert_eq!(~"𐌀𐌖𐌋𐌄𐌑𐌉ปรدولة الكويتทศไทย中华𐍅𐌿𐌻𐍆𐌹𐌻𐌰",
2831-
from_bytes(bytes!("𐌀𐌖𐌋𐌄𐌑𐌉ปรدولة الكويتทศไทย中华𐍅𐌿𐌻𐍆𐌹𐌻𐌰")));
28322803
}
28332804
2834-
#[test]
2835-
fn test_is_utf8_deny_overlong() {
2836-
assert!(!is_utf8([0xc0, 0x80]));
2837-
assert!(!is_utf8([0xc0, 0xae]));
2838-
assert!(!is_utf8([0xe0, 0x80, 0x80]));
2839-
assert!(!is_utf8([0xe0, 0x80, 0xaf]));
2840-
assert!(!is_utf8([0xe0, 0x81, 0x81]));
2841-
assert!(!is_utf8([0xf0, 0x82, 0x82, 0xac]));
2842-
}
2843-
2844-
28452805
#[test]
28462806
#[ignore(cfg(windows))]
28472807
fn test_from_bytes_fail() {

0 commit comments

Comments
 (0)