diff options
author | Melody Horn <melody@boringcactus.com> | 2024-12-16 23:33:22 -0700 |
---|---|---|
committer | Melody Horn <melody@boringcactus.com> | 2024-12-16 23:34:45 -0700 |
commit | 5411a125821c67db5cff29142ff39b207a2637f7 (patch) | |
tree | 2cdf0f5bcd499c6d0fdba005d935cfe75b6a26b3 /src | |
parent | 35ebe14f47d692f17ec04b7d94f4ac490b297e3e (diff) | |
download | makers-5411a125821c67db5cff29142ff39b207a2637f7.tar.gz makers-5411a125821c67db5cff29142ff39b207a2637f7.zip |
don't strip comments in continued lines
i'm not actually sure if this is how GNU make works
but it appears to be the behavior GNU make exhibits
Diffstat (limited to 'src')
-rw-r--r-- | src/makefile/input.rs | 46 |
1 files changed, 35 insertions, 11 deletions
diff --git a/src/makefile/input.rs b/src/makefile/input.rs index 74742f9..345f465 100644 --- a/src/makefile/input.rs +++ b/src/makefile/input.rs @@ -439,15 +439,7 @@ impl<'a, 'parent, R: BufRead> MakefileReader<'a, 'parent, R> { Ok(x) => x, Err(err) => return Some((n, Err(err))), }; - let line = if settings.strip_comments { - COMMENT - .replace(&line, "$1") - .replace(r"\#", "#") - .trim_end() - .to_owned() - } else { - line - }; + // TODO strip comments if it's correct to line_pieces.push(line.trim_start().to_owned()); } } @@ -1150,10 +1142,11 @@ pub struct FinishedMakefileReader { #[cfg(test)] mod test { - use super::*; - use std::io::Cursor; + use super::*; + use crate::makefile::token::Token; + type R = Result<()>; #[test] @@ -1485,4 +1478,35 @@ test: c ); Ok(()) } + + #[cfg(feature = "full")] + #[test] + fn shell_comment() -> R { + let file = r#" +FOO=$(shell \ +echo \ +#abc) + "#; + let args = Args::empty(); + let makefile = MakefileReader::read( + &args, + MacroScopeStack::default(), + MacroSet::new(), + Cursor::new(file), + "", + Default::default(), + )?; + let makefile = makefile.finish(); + assert_eq!( + makefile.macros.get_non_recursive("FOO").map(|x| &x.text), + Some(&TokenString::from(vec![ + Token::Text(String::new()), + Token::FunctionCall { + name: TokenString::text("shell"), + args: vec![TokenString::text("echo #abc")], + }, + ])) + ); + Ok(()) + } } |