2013-06-20 14:11:47 -05:00
|
|
|
// Tests a tricky scenario involving string matching,
|
|
|
|
// copying, and moving to ensure that we don't segfault
|
|
|
|
// or double-free, as we were wont to do in the past.
|
|
|
|
|
|
|
|
use std::io;
|
2013-07-01 18:59:53 -05:00
|
|
|
use std::os;
|
2013-06-20 14:11:47 -05:00
|
|
|
|
|
|
|
fn parse_args() -> ~str {
|
2013-07-01 18:59:53 -05:00
|
|
|
let args = os::args();
|
2013-06-20 14:11:47 -05:00
|
|
|
let mut n = 0;
|
|
|
|
|
|
|
|
while n < args.len() {
|
|
|
|
match copy args[n] {
|
|
|
|
~"-v" => (),
|
|
|
|
s => {
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
n += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ~""
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
io::println(parse_args());
|
|
|
|
}
|