gbranden pushed a commit to branch master
in repository groff.
commit 2ede28af8cb7a5b6e525a2a68065b6004a68a25f
Author: G. Branden Robinson <[email protected]>
AuthorDate: Mon Nov 23 10:18:34 2026 -0600
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>.
---
ChangeLog | 10 ++++++++++
src/roff/troff/env.cpp | 39 ++++++++++++++++++++++-----------------
2 files changed, 32 insertions(+), 17 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 6905606a8..d67949913 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2026-11-23 G. Branden Robinson <[email protected]>
+
+ * 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>.
+
2026-11-23 G. Branden Robinson <[email protected]>
[groff]: Regression-test Savannah #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();
}
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit