Skip to content

Commit

Permalink
std: Rename strbuf operations to string
Browse files Browse the repository at this point in the history
[breaking-change]
  • Loading branch information
richo committed May 27, 2014
1 parent 4348e23 commit 1f1b2e4
Show file tree
Hide file tree
Showing 304 changed files with 2,570 additions and 2,570 deletions.
42 changes: 21 additions & 21 deletions src/compiletest/compiletest.rs
Expand Up @@ -50,7 +50,7 @@ fn start(argc: int, argv: **u8) -> int {
pub fn main() {
let args = os::args();
let config = parse_config(args.move_iter()
.map(|x| x.to_strbuf())
.map(|x| x.to_string())
.collect());
log_config(&config);
run_tests(&config);
Expand Down Expand Up @@ -134,15 +134,15 @@ pub fn parse_config(args: Vec<String> ) -> Config {
Config {
compile_lib_path: matches.opt_str("compile-lib-path")
.unwrap()
.to_strbuf(),
run_lib_path: matches.opt_str("run-lib-path").unwrap().to_strbuf(),
.to_string(),
run_lib_path: matches.opt_str("run-lib-path").unwrap().to_string(),
rustc_path: opt_path(matches, "rustc-path"),
clang_path: matches.opt_str("clang-path").map(|s| Path::new(s)),
llvm_bin_path: matches.opt_str("llvm-bin-path").map(|s| Path::new(s)),
src_base: opt_path(matches, "src-base"),
build_base: opt_path(matches, "build-base"),
aux_base: opt_path(matches, "aux-base"),
stage_id: matches.opt_str("stage-id").unwrap().to_strbuf(),
stage_id: matches.opt_str("stage-id").unwrap().to_string(),
mode: FromStr::from_str(matches.opt_str("mode")
.unwrap()
.as_slice()).expect("invalid mode"),
Expand All @@ -156,32 +156,32 @@ pub fn parse_config(args: Vec<String> ) -> Config {
ratchet_noise_percent:
matches.opt_str("ratchet-noise-percent")
.and_then(|s| from_str::<f64>(s.as_slice())),
runtool: matches.opt_str("runtool").map(|x| x.to_strbuf()),
runtool: matches.opt_str("runtool").map(|x| x.to_string()),
host_rustcflags: matches.opt_str("host-rustcflags")
.map(|x| x.to_strbuf()),
.map(|x| x.to_string()),
target_rustcflags: matches.opt_str("target-rustcflags")
.map(|x| x.to_strbuf()),
.map(|x| x.to_string()),
jit: matches.opt_present("jit"),
target: opt_str2(matches.opt_str("target").map(|x| x.to_strbuf())),
host: opt_str2(matches.opt_str("host").map(|x| x.to_strbuf())),
target: opt_str2(matches.opt_str("target").map(|x| x.to_string())),
host: opt_str2(matches.opt_str("host").map(|x| x.to_string())),
android_cross_path: opt_path(matches, "android-cross-path"),
adb_path: opt_str2(matches.opt_str("adb-path")
.map(|x| x.to_strbuf())),
.map(|x| x.to_string())),
adb_test_dir: opt_str2(matches.opt_str("adb-test-dir")
.map(|x| x.to_strbuf())),
.map(|x| x.to_string())),
adb_device_status:
"arm-linux-androideabi" ==
opt_str2(matches.opt_str("target")
.map(|x| x.to_strbuf())).as_slice() &&
.map(|x| x.to_string())).as_slice() &&
"(none)" !=
opt_str2(matches.opt_str("adb-test-dir")
.map(|x| x.to_strbuf())).as_slice() &&
.map(|x| x.to_string())).as_slice() &&
!opt_str2(matches.opt_str("adb-test-dir")
.map(|x| x.to_strbuf())).is_empty(),
.map(|x| x.to_string())).is_empty(),
lldb_python_dir: matches.opt_str("lldb-python-dir")
.map(|x| x.to_strbuf()),
.map(|x| x.to_string()),
test_shard: test::opt_shard(matches.opt_str("test-shard")
.map(|x| x.to_strbuf())),
.map(|x| x.to_string())),
verbose: matches.opt_present("verbose")
}
}
Expand All @@ -201,7 +201,7 @@ pub fn log_config(config: &Config) {
opt_str(&config.filter
.as_ref()
.map(|re| {
re.to_str().into_strbuf()
re.to_str().into_string()
}))));
logv(c, format_strbuf!("runtool: {}", opt_str(&config.runtool)));
logv(c, format_strbuf!("host-rustcflags: {}",
Expand All @@ -218,7 +218,7 @@ pub fn log_config(config: &Config) {
logv(c, format_strbuf!("adb_device_status: {}",
config.adb_device_status));
match config.test_shard {
None => logv(c, "test_shard: (all)".to_strbuf()),
None => logv(c, "test_shard: (all)".to_string()),
Some((a,b)) => logv(c, format_strbuf!("test_shard: {}.{}", a, b))
}
logv(c, format_strbuf!("verbose: {}", config.verbose));
Expand All @@ -234,7 +234,7 @@ pub fn opt_str<'a>(maybestr: &'a Option<String>) -> &'a str {

pub fn opt_str2(maybestr: Option<String>) -> String {
match maybestr {
None => "(none)".to_strbuf(),
None => "(none)".to_string(),
Some(s) => s,
}
}
Expand Down Expand Up @@ -367,7 +367,7 @@ pub fn make_test_name(config: &Config, testfile: &Path) -> test::TestName {
pub fn make_test_closure(config: &Config, testfile: &Path) -> test::TestFn {
let config = (*config).clone();
// FIXME (#9639): This needs to handle non-utf8 paths
let testfile = testfile.as_str().unwrap().to_strbuf();
let testfile = testfile.as_str().unwrap().to_string();
test::DynTestFn(proc() {
runtest::run(config, testfile)
})
Expand All @@ -376,7 +376,7 @@ pub fn make_test_closure(config: &Config, testfile: &Path) -> test::TestFn {
pub fn make_metrics_test_closure(config: &Config, testfile: &Path) -> test::TestFn {
let config = (*config).clone();
// FIXME (#9639): This needs to handle non-utf8 paths
let testfile = testfile.as_str().unwrap().to_strbuf();
let testfile = testfile.as_str().unwrap().to_string();
test::DynMetricFn(proc(mm) {
runtest::run_metrics(config, testfile, mm)
})
Expand Down
4 changes: 2 additions & 2 deletions src/compiletest/errors.rs
Expand Up @@ -31,8 +31,8 @@ pub fn load_errors(re: &Regex, testfile: &Path) -> Vec<ExpectedError> {
fn parse_expected(line_num: uint, line: &str, re: &Regex) -> Option<ExpectedError> {
re.captures(line).and_then(|caps| {
let adjusts = caps.name("adjusts").len();
let kind = caps.name("kind").to_ascii().to_lower().into_str().to_strbuf();
let msg = caps.name("msg").trim().to_strbuf();
let kind = caps.name("kind").to_ascii().to_lower().into_str().to_string();
let msg = caps.name("msg").trim().to_string();

debug!("line={} kind={} msg={}", line_num, kind, msg);
Some(ExpectedError {
Expand Down
20 changes: 10 additions & 10 deletions src/compiletest/header.rs
Expand Up @@ -170,23 +170,23 @@ fn iter_header(testfile: &Path, it: |&str| -> bool) -> bool {
}

fn parse_error_pattern(line: &str) -> Option<String> {
parse_name_value_directive(line, "error-pattern".to_strbuf())
parse_name_value_directive(line, "error-pattern".to_string())
}

fn parse_aux_build(line: &str) -> Option<String> {
parse_name_value_directive(line, "aux-build".to_strbuf())
parse_name_value_directive(line, "aux-build".to_string())
}

fn parse_compile_flags(line: &str) -> Option<String> {
parse_name_value_directive(line, "compile-flags".to_strbuf())
parse_name_value_directive(line, "compile-flags".to_string())
}

fn parse_run_flags(line: &str) -> Option<String> {
parse_name_value_directive(line, "run-flags".to_strbuf())
parse_name_value_directive(line, "run-flags".to_string())
}

fn parse_check_line(line: &str) -> Option<String> {
parse_name_value_directive(line, "check".to_strbuf())
parse_name_value_directive(line, "check".to_string())
}

fn parse_force_host(line: &str) -> bool {
Expand All @@ -206,15 +206,15 @@ fn parse_no_pretty_expanded(line: &str) -> bool {
}

fn parse_exec_env(line: &str) -> Option<(String, String)> {
parse_name_value_directive(line, "exec-env".to_strbuf()).map(|nv| {
parse_name_value_directive(line, "exec-env".to_string()).map(|nv| {
// nv is either FOO or FOO=BAR
let mut strs: Vec<String> = nv.as_slice()
.splitn('=', 1)
.map(|s| s.to_strbuf())
.map(|s| s.to_string())
.collect();

match strs.len() {
1u => (strs.pop().unwrap(), "".to_strbuf()),
1u => (strs.pop().unwrap(), "".to_string()),
2u => {
let end = strs.pop().unwrap();
(strs.pop().unwrap(), end)
Expand All @@ -225,7 +225,7 @@ fn parse_exec_env(line: &str) -> Option<(String, String)> {
}

fn parse_pp_exact(line: &str, testfile: &Path) -> Option<Path> {
match parse_name_value_directive(line, "pp-exact".to_strbuf()) {
match parse_name_value_directive(line, "pp-exact".to_string()) {
Some(s) => Some(Path::new(s)),
None => {
if parse_name_directive(line, "pp-exact") {
Expand All @@ -247,7 +247,7 @@ pub fn parse_name_value_directive(line: &str, directive: String)
match line.find_str(keycolon.as_slice()) {
Some(colon) => {
let value = line.slice(colon + keycolon.len(),
line.len()).to_strbuf();
line.len()).to_string();
debug!("{}: {}", directive, value);
Some(value)
}
Expand Down
12 changes: 6 additions & 6 deletions src/compiletest/procsrv.rs
Expand Up @@ -15,7 +15,7 @@ use std::unstable::dynamic_lib::DynamicLibrary;

fn target_env(lib_path: &str, prog: &str) -> Vec<(String, String)> {
let prog = if cfg!(windows) {prog.slice_to(prog.len() - 4)} else {prog};
let mut aux_path = prog.to_strbuf();
let mut aux_path = prog.to_string();
aux_path.push_str(".libaux");

// Need to be sure to put both the lib_path and the aux path in the dylib
Expand All @@ -27,16 +27,16 @@ fn target_env(lib_path: &str, prog: &str) -> Vec<(String, String)> {
// Remove the previous dylib search path var
let var = DynamicLibrary::envvar();
let mut env: Vec<(String,String)> =
os::env().move_iter().map(|(a,b)|(a.to_strbuf(), b.to_strbuf())).collect();
os::env().move_iter().map(|(a,b)|(a.to_string(), b.to_string())).collect();
match env.iter().position(|&(ref k, _)| k.as_slice() == var) {
Some(i) => { env.remove(i); }
None => {}
}

// Add the new dylib search path var
let newpath = DynamicLibrary::create_path(path.as_slice());
env.push((var.to_strbuf(),
str::from_utf8(newpath.as_slice()).unwrap().to_strbuf()));
env.push((var.to_string(),
str::from_utf8(newpath.as_slice()).unwrap().to_string()));
return env;
}

Expand All @@ -59,8 +59,8 @@ pub fn run(lib_path: &str,

Some(Result {
status: status,
out: str::from_utf8(output.as_slice()).unwrap().to_strbuf(),
err: str::from_utf8(error.as_slice()).unwrap().to_strbuf()
out: str::from_utf8(output.as_slice()).unwrap().to_string(),
err: str::from_utf8(error.as_slice()).unwrap().to_string()
})
},
Err(..) => None
Expand Down

0 comments on commit 1f1b2e4

Please sign in to comment.