[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 09/12: [troff]: Slightly refactor escape seq handling.
From: |
G. Branden Robinson |
Subject: |
[groff] 09/12: [troff]: Slightly refactor escape seq handling. |
Date: |
Thu, 7 Mar 2024 18:37:44 -0500 (EST) |
gbranden pushed a commit to branch master
in repository groff.
commit 2fa56ec84577fcc37d6f38f650b3e42a2d072bd5
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Thu Mar 7 06:53:38 2024 -0600
[troff]: Slightly refactor escape seq handling.
* 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 redunant with a `switch` case.
---
ChangeLog | 7 +++++++
src/roff/troff/input.cpp | 12 +++++-------
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 959e0f8a8..02a9c4e46 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-03-07 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ * 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 redunant with a `switch` case.
+
2024-03-07 G. Branden Robinson <g.branden.robinson@gmail.com>
* src/roff/troff/input.cpp: Trivially refactor.
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 9419bd4e7..2fbbe9106 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -919,8 +919,10 @@ 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");
@@ -928,13 +930,9 @@ static char get_char_for_escape_parameter(bool allow_space
= false)
default:
if (!is_invalid_input_char(c))
break;
- // fall through
- case '\n':
- if (c == '\n')
- input_stack::push(make_temp_iterator("\n"));
- // fall through
+ // fall through
case ' ':
- if (c == ' ' && allow_space)
+ if (allow_space)
break;
// fall through
case '\t':
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 09/12: [troff]: Slightly refactor escape seq handling.,
G. Branden Robinson <=