diff --git a/libs/preprocessor/src/processor/mod.rs b/libs/preprocessor/src/processor/mod.rs index c07319a0..92c50654 100644 --- a/libs/preprocessor/src/processor/mod.rs +++ b/libs/preprocessor/src/processor/mod.rs @@ -138,7 +138,12 @@ impl Processor { } (Symbol::Directive, false) => { let token = stream.next().expect("peeked above"); - if in_macro.is_some() && stream.peek().map_or(false, |t| t.symbol().is_word()) { + if in_macro.is_some() + && stream.peek().map_or(false, |t| t.symbol().is_word()) + // check if the # token is from another file, or defined before the callsite, ie not in the root arguments + && (token.position().path() != callsite.unwrap().path() + || token.position().start().0 < callsite.unwrap().start().0) + { self.output( Token::new(Symbol::DoubleQuote, token.position().clone()), buffer, diff --git a/libs/preprocessor/tests/bootstrap.rs b/libs/preprocessor/tests/bootstrap.rs index 9d79f88c..f87bec05 100644 --- a/libs/preprocessor/tests/bootstrap.rs +++ b/libs/preprocessor/tests/bootstrap.rs @@ -41,34 +41,35 @@ bootstrap!(cba_is_admin); bootstrap!(cba_multiline); bootstrap!(comment_edgecase); bootstrap!(define_builtin); -bootstrap!(define_function); bootstrap!(define_function_empty); bootstrap!(define_function_multiline); +bootstrap!(define_function); bootstrap!(define_inside_else); bootstrap!(define_multi); -bootstrap!(define_nested); bootstrap!(define_nested_nested); +bootstrap!(define_nested); bootstrap!(define_single); bootstrap!(define_undef); bootstrap!(define_use_define); bootstrap!(define_with_dash); +bootstrap!(hashtag_outside_macro); bootstrap!(if_nested); bootstrap!(if_operators); bootstrap!(if_pass); bootstrap!(if_read); bootstrap!(if_value); bootstrap!(ignore_quoted); -bootstrap!(include); bootstrap!(include_empty); +bootstrap!(include); bootstrap!(join_digit); bootstrap!(join_ignore); bootstrap!(name_collision); bootstrap!(procedural_texture); -bootstrap!(quote); bootstrap!(quote_recursive); +bootstrap!(quote); bootstrap!(redefine_external); bootstrap!(self_recursion); -bootstrap!(sqf); bootstrap!(sqf_select); +bootstrap!(sqf); bootstrap!(strings); bootstrap!(utf); diff --git a/libs/preprocessor/tests/bootstrap/hashtag_outside_macro/expected.hpp b/libs/preprocessor/tests/bootstrap/hashtag_outside_macro/expected.hpp new file mode 100644 index 00000000..136bbb63 --- /dev/null +++ b/libs/preprocessor/tests/bootstrap/hashtag_outside_macro/expected.hpp @@ -0,0 +1,2 @@ + +"#structural" diff --git a/libs/preprocessor/tests/bootstrap/hashtag_outside_macro/source.hpp b/libs/preprocessor/tests/bootstrap/hashtag_outside_macro/source.hpp new file mode 100644 index 00000000..fdfb1314 --- /dev/null +++ b/libs/preprocessor/tests/bootstrap/hashtag_outside_macro/source.hpp @@ -0,0 +1,3 @@ +#define QOUTE(s) #s + +QOUTE(#structural)