Preserve alignment boundaries when matching hash-brace macros
This commit is contained in:
1 parent
307303d596
commit
862801ee5f
5 files changed
+57
No files matched your search
@@ -1735,6 +1735,7 @@ impl Executor {
|
||||
if self.required_raw(files)?.token.kind != *expected {
|
||||
return self.fail("macro prefix does not match");
|
||||
}
|
||||
self.consume_macro_delimiter(expected);
|
||||
}
|
||||
let mut arguments = Vec::new();
|
||||
for (index, delimiter) in definition.parameters.iter().enumerate() {
|
||||
@@ -1773,6 +1774,7 @@ impl Executor {
|
||||
// became argument text when the match shifted.
|
||||
matched += 1;
|
||||
if matched == delimiter.len() {
|
||||
self.consume_macro_delimiter(&next.kind);
|
||||
argument.truncate(argument.len() + 1 - matched);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -94,6 +94,13 @@ impl Executor {
|
||||
_ => 0,
|
||||
}
|
||||
}
|
||||
pub(super) fn consume_macro_delimiter(&mut self, kind: &TokenKind) {
|
||||
// The final literal brace of a hash-brace delimiter is appended to the
|
||||
// replacement. Count it when that replacement reaches the alignment.
|
||||
if kind.begin_group() && !self.alignments.is_empty() {
|
||||
self.alignment_balance -= 1;
|
||||
}
|
||||
}
|
||||
pub(super) fn alignment_brace(&mut self, token: &Token) -> i64 {
|
||||
match self.meaning(token) {
|
||||
Meaning::Character(TokenKind::Character(_, CatCode::BeginGroup)) => 1,
|
||||
|
||||
Reference in new issue
Block a user