gbranden pushed a commit to branch master
in repository groff.
commit 33883cde2978ae4e4aa617d7626217675381f5ae
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Jul 3 00:04:38 2024 -0500
Revert "[troff]: Slightly refactor escape seq handling."
This reverts commit 2fa56ec84577fcc37d6f38f650b3e42a2d072bd5.
I found a case where we can in fact enter this function with a newline
as the next token. Unfortunately, it is hard to find a minimal
reproducer for it. But here is the meat of the case.
.nr li*prefix-pad 1
.de XX
.ds li*c-mark \" empty
.if \\n[.$]>0 .as li*c-mark \\$1\"
.if \\n[li*prefix-pad] .as li*c-mark \ \"
.ie d li*enumerator .as li*c-mark \\*[li*enumerator}\" XXX
.el .as li*c-mark \\*[li*mark]\"
..
.XX
.XX *
The line flagged "XXX" causes the reverted assertion to fail when the
foregoing code is applied to the `LI` macro in our mm package.
---
ChangeLog | 7 -------
src/roff/troff/input.cpp | 12 +++++++-----
2 files changed, 7 insertions(+), 12 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 886a29432..56808cc5c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1764,13 +1764,6 @@
* src/roff/troff/input.cpp (is_usable_as_delimiter): Fix code
style nit, using C++-style type cast instead of C-style cast.
-2024-03-07 G. Branden Robinson <[email protected]>
-
- * src/roff/troff/input.cpp (get_char_for_escape_parameter):
- Slightly refactor. Assert that the character handed to us by
- our caller is not a newline. Consequently, drop newline
- handler. Drop `if` test that is redundant with a `switch` case.
-
2024-03-07 G. Branden Robinson <[email protected]>
* src/roff/troff/input.cpp: Trivially refactor.
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index ebf5c5bc0..2df745156 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -921,10 +921,8 @@ void shift()
static char get_char_for_escape_parameter(bool allow_space = false)
{
- int c = get_copy(0 /* nullptr */,
- false /* is defining */,
+ int c = get_copy(0 /* nullptr */, false /* is defining */,
true /* handle \E */);
- assert(c != '\n');
switch (c) {
case EOF:
copy_mode_error("end of input in escape sequence");
@@ -932,9 +930,13 @@ static char get_char_for_escape_parameter(bool allow_space
= false)
default:
if (!is_invalid_input_char(c))
break;
- // fall through
+ // fall through
+ case '\n':
+ if (c == '\n')
+ input_stack::push(make_temp_iterator("\n"));
+ // fall through
case ' ':
- if (allow_space)
+ if (c == ' ' && allow_space)
break;
// fall through
case '\t':
_______________________________________________
Groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit