Do not assume there is whitespace between define id and body
@@ -414,8 +414,8 @@ impl<'a> PreProcessor<'a> {
self.file_processor.tokens_until_newline(whitespace)
}
- fn is_not_whitespace(res: &CppResult<Token>) -> bool {
- !matches!(
+ fn is_whitespace(res: &CppResult<Token>) -> bool {
+ matches!(
res,
Ok(Locatable {
data: Token::Whitespace(_),
@@ -423,6 +423,9 @@ impl<'a> PreProcessor<'a> {
})
)
}
+ fn is_not_whitespace(res: &CppResult<Token>) -> bool {
+ !PreProcessor::is_whitespace(res)
+ }
/// If at the start of the line and we see `#directive`, return that directive.
/// Otherwise, if we see a token (or error), return that error.
@@ -896,7 +899,7 @@ impl<'a> PreProcessor<'a> {
let body = |this: &mut PreProcessor| {
this.tokens_until_newline(true)
.into_iter()
- .skip(1) // First is always unwanted whitespace
+ .skip_while(PreProcessor::is_whitespace) // TODO warning if nothing skips
.map(|res| res.map(|loc| loc.data))
.collect::<Result<Vec<_>, Locatable<Error>>>()
};
