Update of bug #68954 (group groff):
Summary: [troff] `ev` request should not perform operation if
argument invalid => [PATCH] [troff] `ev` request should not perform operation
if argument invalid
_______________________________________________________
Follow-up Comment #1:
commit 8bc826201b8102f437f68733c47d8faf6fc584c5
Author: G. Branden Robinson <[email protected]>
Date: Mon Nov 23 10:18:34 2026 -0600
XXX src/roff/troff/env.cpp: Fix Savannah #68954.
* src/roff/troff/env.cpp (environment_switch_request): Restructure logic
to recognize that an invalid argument is not the same thing as no
argument. Explicitly skip the remainder of the line and return when
given an invalid argument. Perform a pop operation only if given no
argument.
Fixes <https://savannah.gnu.org/bugs/?68954>.
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 220959e99..220a3273b 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -3952,24 +3952,12 @@ static void environment_switch_request() // .ev
skip_line();
return;
}
- symbol nm = read_long_identifier();
- if (nm.is_null()) {
- if (env_stack == 0 /* nullptr */)
- error("cannot pop the only environment in the stack");
- else {
- bool seen_space = curenv->seen_space;
- bool seen_eol = curenv->seen_eol;
- bool suppress_next_eol = curenv->suppress_next_eol;
- curenv = env_stack->env;
- curenv->seen_space = seen_space;
- curenv->seen_eol = seen_eol;
- curenv->suppress_next_eol = suppress_next_eol;
- env_list_node *tem = env_stack;
- env_stack = env_stack->next;
- delete tem;
+ if (has_arg()) {
+ symbol nm = read_long_identifier();
+ if (nm.is_null()) {
+ skip_line();
+ return;
}
- }
- else {
environment *e
= static_cast<environment *>(env_dictionary.lookup(nm));
if (!e) {
@@ -3979,6 +3967,23 @@ static void environment_switch_request() // .ev
env_stack = new env_list_node(curenv, env_stack);
curenv = e;
}
+ else {
+ if (env_stack == 0 /* nullptr */) {
+ error("cannot pop the only environment in the stack");
+ skip_line();
+ return;
+ }
+ bool seen_space = curenv->seen_space;
+ bool seen_eol = curenv->seen_eol;
+ bool suppress_next_eol = curenv->suppress_next_eol;
+ curenv = env_stack->env;
+ curenv->seen_space = seen_space;
+ curenv->seen_eol = seen_eol;
+ curenv->suppress_next_eol = suppress_next_eol;
+ env_list_node *tem = env_stack;
+ env_stack = env_stack->next;
+ delete tem;
+ }
skip_line();
}
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?68954>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc
Description: PGP signature
