summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorG. Branden Robinson <g.branden.robinson@gmail.com>2024-03-07 06:53:38 -0600
committerG. Branden Robinson <g.branden.robinson@gmail.com>2024-03-07 17:21:07 -0600
commit2fa56ec84577fcc37d6f38f650b3e42a2d072bd5 (patch)
treee59e6714e45069f8ab3dbe4fba095326edbd0113
parentf795639afe4b500d8a657dffbff38f09c2d7c150 (diff)
[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.
-rw-r--r--ChangeLog7
-rw-r--r--src/roff/troff/input.cpp12
2 files changed, 12 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 959e0f8a8..02a9c4e46 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
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.
(do_special): Rename this...
(do_device_control): ...to this.
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':