diff --git a/src/main.rs b/src/main.rs index 0b41e5c..2158bfc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -153,7 +153,7 @@ impl Makefile { panic!("error: makefile contains one mgen guard but not the other. cannot continue."); } - if ! contains_start && contains_end { + if !(contains_start && contains_end) { let include_dirs = Makefile::get_include_dirs(&contents); return Makefile { path: String::from(path), prologue: contents, mgen_zone: String::from(""), epilogue: String::from(""), include_dirs }; @@ -176,11 +176,14 @@ impl Makefile { } fn get_include_dirs(search: &String) -> Vec { + let mut include_dirs: Vec = Vec::new(); + let makefile_regex = Regex::new(r"^INCS\s*=\s*(.*?)$").unwrap(); let caps = makefile_regex.captures_iter(search); - let (_, [dirlist]) = caps.map(|c| c.extract()).last().unwrap(); - - let mut include_dirs: Vec = Vec::new(); + let dirlist = match caps.map(|c| c.extract()).last() { + Some((_, [v])) => v, + None => return include_dirs, + }; let incdir_regex = Regex::new(r"-s*-I\s*(.*?)\s*").unwrap(); let caps = incdir_regex.captures_iter(&dirlist);