From 435fc71d68d4a4365311c1edf0d04c234263f3ed Mon Sep 17 00:00:00 2001 From: Aleksey Kuznetsov Date: Fri, 17 Jan 2020 22:40:56 +0500 Subject: [PATCH] Allow 'clif-util run' to read stdin as intended, closes #1004 (#1335) --- cranelift/src/run.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cranelift/src/run.rs b/cranelift/src/run.rs index 701104fcf5..7825b1852d 100644 --- a/cranelift/src/run.rs +++ b/cranelift/src/run.rs @@ -10,9 +10,19 @@ use target_lexicon::Triple; use walkdir::WalkDir; pub fn run(files: Vec, flag_print: bool) -> Result<(), String> { + let stdin_exist = files.iter().find(|file| *file == "-").is_some(); + let filtered_files = files + .iter() + .filter(|file| *file != "-") + .map(|file| file.to_string()) + .collect::>(); let mut total = 0; let mut errors = 0; - for file in iterate_files(files) { + let mut special_files: Vec = vec![]; + if stdin_exist { + special_files.push("-".into()); + } + for file in iterate_files(filtered_files).chain(special_files) { total += 1; match run_single_file(&file) { Ok(_) => {