summaryrefslogtreecommitdiff
path: root/src/roff/troff
diff options
context:
space:
mode:
authorG. Branden Robinson <g.branden.robinson@gmail.com>2022-10-01 04:18:47 -0500
committerG. Branden Robinson <g.branden.robinson@gmail.com>2022-10-03 00:24:05 -0500
commitad4fa80a3f2d66ed7e9d4342fbc58d2be07984ea (patch)
tree7bb0e6e3644d517bf8368b0bc1ae64647183a3ca /src/roff/troff
parenta7eda2790eadddd1cb5d2290bc6f246caebae6c5 (diff)
downloadgroff-git-ad4fa80a3f2d66ed7e9d4342fbc58d2be07984ea.tar.gz
[troff]: Refactor to parallelize logic.
* src/roff/troff/input.cpp: Refactor to parallelize logic in similar routines; namely, those handling escape sequences that accept newlines as argument delimiters.
Diffstat (limited to 'src/roff/troff')
-rw-r--r--src/roff/troff/input.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 705befdd5..1553bb9b6 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -1433,9 +1433,9 @@ static void define_color()
node *do_overstrike()
{
- token start;
overstrike_node *on = new overstrike_node;
int start_level = input_stack::get_level();
+ token start;
start.next();
for (;;) {
tok.next();
@@ -1446,7 +1446,7 @@ node *do_overstrike()
if (tok.is_eof()) {
warning(WARN_DELIM, "missing closing delimiter in overstrike"
" escape sequence (got %1)", tok.description());
- // Pretend we saw a newline.
+ // Synthesize an input line ending.
input_stack::push(make_temp_iterator("\n"));
break;
}
@@ -1475,10 +1475,10 @@ node *do_overstrike()
static node *do_bracket()
{
- token start;
bracket_node *bn = new bracket_node;
- start.next();
int start_level = input_stack::get_level();
+ token start;
+ start.next();
for (;;) {
tok.next();
if (tok.is_newline()) {
@@ -1489,7 +1489,7 @@ static node *do_bracket()
warning(WARN_DELIM, "missing closing delimiter in"
" bracket-building escape sequence (got %1)",
tok.description());
- // Pretend we saw a newline.
+ // Synthesize an input line ending.
input_stack::push(make_temp_iterator("\n"));
break;
}
@@ -1508,9 +1508,9 @@ static node *do_bracket()
static int do_name_test()
{
+ int start_level = input_stack::get_level();
token start;
start.next();
- int start_level = input_stack::get_level();
bool got_bad_char = false;
bool got_some_char = false;
for (;;) {
@@ -1520,6 +1520,7 @@ static int do_name_test()
warning(WARN_DELIM, "missing closing delimiter in identifier"
" validation escape sequence (got %1)",
tok.description());
+ // Synthesize an input line ending.
input_stack::push(make_temp_iterator("\n"));
break;
}
@@ -1607,15 +1608,16 @@ static node *do_zero_width()
static node *do_zero_width()
{
node *rev = new dummy_node;
+ int start_level = input_stack::get_level();
token start;
start.next();
- int start_level = input_stack::get_level();
for (;;) {
tok.next();
if (tok.is_newline() || tok.is_eof()) {
if (tok != start)
warning(WARN_DELIM, "missing closing delimiter in"
" zero-width escape (got %1)", tok.description());
+ // Synthesize an input line ending.
input_stack::push(make_temp_iterator("\n"));
break;
}
@@ -5267,9 +5269,9 @@ static void do_register()
static void do_width()
{
+ int start_level = input_stack::get_level();
token start;
start.next();
- int start_level = input_stack::get_level();
environment env(curenv);
environment *oldenv = curenv;
curenv = &env;
@@ -5280,7 +5282,7 @@ static void do_width()
warning(WARN_DELIM, "missing closing delimiter in"
" width computation escape sequence (got %1)",
tok.description());
- // Pretend we saw a newline.
+ // Synthesize an input line ending.
input_stack::push(make_temp_iterator("\n"));
break;
}
@@ -5482,9 +5484,9 @@ static void encode_char(macro *mac, char c)
static node *do_special()
{
+ int start_level = input_stack::get_level();
token start;
start.next();
- int start_level = input_stack::get_level();
macro mac;
for (;;) {
tok.next();
@@ -5495,7 +5497,7 @@ static node *do_special()
if (tok.is_eof()) {
warning(WARN_DELIM, "missing closing delimiter in device control"
" escape sequence (got %1)", tok.description());
- // Pretend we saw a newline.
+ // Synthesize an input line ending.
input_stack::push(make_temp_iterator("\n"));
break;
}