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.
|
|
|
|
|
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() {
|
2013-07-12 23:05:59 -05:00
|
|
|
match args[n].clone() {
|
2013-06-20 14:11:47 -05:00
|
|
|
~"-v" => (),
|
|
|
|
s => {
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
n += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ~""
|
|
|
|
}
|
|
|
|
|
2013-09-25 02:43:37 -05:00
|
|
|
pub fn main() {
|
2014-01-09 04:06:55 -06:00
|
|
|
println!("{}", parse_args());
|
2013-06-20 14:11:47 -05:00
|
|
|
}
|