Skip to content

Commit 7c9ccfb

Browse files
committed
---
yaml --- r: 64899 b: refs/heads/snap-stage3 c: 8a737b5 h: refs/heads/master i: 64897: f82bcf9 64895: 1479eb7 v: v3
1 parent 09edfa5 commit 7c9ccfb

File tree

4 files changed

+71
-27
lines changed

4 files changed

+71
-27
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: fac18c1cb869c5b2125091ffd5b68b9c04a94e93
4+
refs/heads/snap-stage3: 8a737b502067b1896686bd1f9df7a1446296d80b
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libextra/getopts.rs

Lines changed: 47 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ pub fn optflag(name: &str) -> Opt {
140140
return Opt {name: mkname(name), hasarg: No, occur: Optional};
141141
}
142142

143-
/// Create an option that is optional and does not take an argument
143+
/** Create an option that is optional, does not take an argument,
144+
* and may occur multiple times.
145+
*/
144146
pub fn optflagmulti(name: &str) -> Opt {
145147
return Opt {name: mkname(name), hasarg: No, occur: Multi};
146148
}
@@ -369,7 +371,14 @@ fn opt_vals(mm: &Matches, nm: &str) -> ~[Optval] {
369371
};
370372
}
371373

372-
fn opt_val(mm: &Matches, nm: &str) -> Optval { opt_vals(mm, nm)[0].clone() }
374+
fn opt_val(mm: &Matches, nm: &str) -> Option<Optval> {
375+
let vals = opt_vals(mm, nm);
376+
if (vals.is_empty()) {
377+
None
378+
} else {
379+
Some(opt_vals(mm, nm)[0].clone())
380+
}
381+
}
373382

374383
/// Returns true if an option was matched
375384
pub fn opt_present(mm: &Matches, nm: &str) -> bool {
@@ -400,7 +409,10 @@ pub fn opts_present(mm: &Matches, names: &[~str]) -> bool {
400409
* argument
401410
*/
402411
pub fn opt_str(mm: &Matches, nm: &str) -> ~str {
403-
return match opt_val(mm, nm) { Val(s) => s, _ => fail!() };
412+
return match opt_val(mm, nm) {
413+
Some(Val(s)) => s,
414+
_ => fail!()
415+
};
404416
}
405417

406418
/**
@@ -412,7 +424,7 @@ pub fn opt_str(mm: &Matches, nm: &str) -> ~str {
412424
pub fn opts_str(mm: &Matches, names: &[~str]) -> ~str {
413425
for names.iter().advance |nm| {
414426
match opt_val(mm, *nm) {
415-
Val(ref s) => return (*s).clone(),
427+
Some(Val(ref s)) => return (*s).clone(),
416428
_ => ()
417429
}
418430
}
@@ -1318,24 +1330,41 @@ mod tests {
13181330
13191331
#[test]
13201332
fn test_multi() {
1321-
let args = ~[~"-e", ~"foo", ~"--encrypt", ~"foo"];
13221333
let opts = ~[optopt("e"), optopt("encrypt"), optopt("f")];
1323-
let matches = &match getopts(args, opts) {
1334+
1335+
let args_single = ~[~"-e", ~"foo"];
1336+
let matches_single = &match getopts(args_single, opts) {
1337+
result::Ok(m) => m,
1338+
result::Err(_) => fail!()
1339+
};
1340+
assert!(opts_present(matches_single, [~"e"]));
1341+
assert!(opts_present(matches_single, [~"encrypt", ~"e"]));
1342+
assert!(opts_present(matches_single, [~"e", ~"encrypt"]));
1343+
assert!(!opts_present(matches_single, [~"encrypt"]));
1344+
assert!(!opts_present(matches_single, [~"thing"]));
1345+
assert!(!opts_present(matches_single, []));
1346+
1347+
assert_eq!(opts_str(matches_single, [~"e"]), ~"foo");
1348+
assert_eq!(opts_str(matches_single, [~"e", ~"encrypt"]), ~"foo");
1349+
assert_eq!(opts_str(matches_single, [~"encrypt", ~"e"]), ~"foo");
1350+
1351+
let args_both = ~[~"-e", ~"foo", ~"--encrypt", ~"foo"];
1352+
let matches_both = &match getopts(args_both, opts) {
13241353
result::Ok(m) => m,
13251354
result::Err(_) => fail!()
13261355
};
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, []));
1334-
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");
1356+
assert!(opts_present(matches_both, [~"e"]));
1357+
assert!(opts_present(matches_both, [~"encrypt"]));
1358+
assert!(opts_present(matches_both, [~"encrypt", ~"e"]));
1359+
assert!(opts_present(matches_both, [~"e", ~"encrypt"]));
1360+
assert!(!opts_present(matches_both, [~"f"]));
1361+
assert!(!opts_present(matches_both, [~"thing"]));
1362+
assert!(!opts_present(matches_both, []));
1363+
1364+
assert_eq!(opts_str(matches_both, [~"e"]), ~"foo");
1365+
assert_eq!(opts_str(matches_both, [~"encrypt"]), ~"foo");
1366+
assert_eq!(opts_str(matches_both, [~"e", ~"encrypt"]), ~"foo");
1367+
assert_eq!(opts_str(matches_both, [~"encrypt", ~"e"]), ~"foo");
13391368
}
13401369
13411370
#[test]

branches/snap-stage3/src/librustc/middle/trans/glue.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,7 @@ pub fn simplified_glue_type(tcx: ty::ctxt, field: uint, t: ty::t) -> ty::t {
136136

137137
if field == abi::tydesc_field_take_glue {
138138
match ty::get(t).sty {
139-
ty::ty_unboxed_vec(*) |
140-
ty::ty_uniq(*) |
141-
ty::ty_estr(ty::vstore_uniq) |
142-
ty::ty_evec(_, ty::vstore_uniq) => { return ty::mk_u32(); }
139+
ty::ty_unboxed_vec(*) => { return ty::mk_u32(); }
143140
_ => ()
144141
}
145142
}

branches/snap-stage3/src/libstd/path.rs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ impl GenericPath for PosixPath {
587587
}
588588

589589
fn with_filename(&self, f: &str) -> PosixPath {
590-
assert!(! f.iter().all(windows::is_sep));
590+
assert!(!f.iter().all(posix::is_sep));
591591
self.dir_path().push(f)
592592
}
593593

@@ -648,7 +648,7 @@ impl GenericPath for PosixPath {
648648
fn push_many<S: Str>(&self, cs: &[S]) -> PosixPath {
649649
let mut v = self.components.clone();
650650
for cs.iter().advance |e| {
651-
for e.as_slice().split_iter(windows::is_sep).advance |s| {
651+
for e.as_slice().split_iter(posix::is_sep).advance |s| {
652652
if !s.is_empty() {
653653
v.push(s.to_owned())
654654
}
@@ -662,7 +662,7 @@ impl GenericPath for PosixPath {
662662

663663
fn push(&self, s: &str) -> PosixPath {
664664
let mut v = self.components.clone();
665-
for s.split_iter(windows::is_sep).advance |s| {
665+
for s.split_iter(posix::is_sep).advance |s| {
666666
if !s.is_empty() {
667667
v.push(s.to_owned())
668668
}
@@ -1001,7 +1001,17 @@ pub fn normalize(components: &[~str]) -> ~[~str] {
10011001
cs
10021002
}
10031003

1004-
// Various windows helpers, and tests for the impl.
1004+
// Various posix helpers.
1005+
pub mod posix {
1006+
1007+
#[inline]
1008+
pub fn is_sep(u: char) -> bool {
1009+
u == '/'
1010+
}
1011+
1012+
}
1013+
1014+
// Various windows helpers.
10051015
pub mod windows {
10061016
use libc;
10071017
use option::{None, Option, Some};
@@ -1139,6 +1149,14 @@ mod tests {
11391149

11401150
}
11411151

1152+
#[test]
1153+
fn test_posix_push_with_backslash() {
1154+
let a = PosixPath("/aaa/bbb");
1155+
let b = a.push("x\\y"); // \ is not a file separator for posix paths
1156+
assert_eq!(a.components.len(), 2);
1157+
assert_eq!(b.components.len(), 3);
1158+
}
1159+
11421160
#[test]
11431161
fn test_normalize() {
11441162
fn t(wp: &PosixPath, s: &str) {

0 commit comments

Comments
 (0)