gbranden pushed a commit to branch master
in repository groff.
commit 0f74dfdf8d110ee88ce53bf2fb3680f7fd188842
Author: G. Branden Robinson <[email protected]>
AuthorDate: Mon Nov 23 11:43:37 2026 -0600
src/roff/troff/env.cpp: Alter `pev` report.
* src/roff/troff/env.cpp (print_environment_request): Invoking the `pev`
request without arguments no longer reports environment properties.
It instead reports the names of stacked environments, starting at the
top (current environment). It then lists the names of unstacked
environments, only if any exist.
Begins fixing <https://savannah.gnu.org/bugs/?68907>.
Example of interactive use:
$ groff
.pev
environment stack:
0 *
.ev foo
.pev
environment stack:
foo *
0
.ev bar
.pev
environment stack:
bar *
foo
0
.ev
.pev
environment stack:
foo *
0
unstacked environments:
bar
---
ChangeLog | 9 +++++++++
src/roff/troff/env.cpp | 39 +++++++++++++++++++++++++++------------
2 files changed, 36 insertions(+), 12 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d4c54df3a..2b6eb918a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2026-11-23 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/env.cpp (print_environment_request): Alter
+ `pev` report. Invoking the `pev` request without arguments no
+ longer reports environment properties. It instead reports the
+ names of stacked environments, starting at the top (current
+ environment). It then lists the names of unstacked
+ environments, only if any exist.
+
2026-11-23 G. Branden Robinson <[email protected]>
* src/roff/troff/env.cpp: Refactor. Migrate representation of
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 07a2d284c..fd8998fc5 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -3814,8 +3814,6 @@ void environment::dump()
fflush(stderr);
}
-// TODO: Revise to report, without arguments, only the environment stack
-// contents from top to bottom, then list unstacked environments.
static void print_environment_request() // .pev
{
symbol s;
@@ -3838,16 +3836,33 @@ static void print_environment_request() // .pev
} while(has_arg());
}
else {
- errprint("Current Environment:\n");
- curenv->dump();
- dictionary_iterator iter(env_dictionary);
- while (iter.get(&s, (void **)&e)) {
- assert(!s.is_null());
- errprint("Environment %1:\n", s.contents());
- if (e != curenv)
- e->dump();
- else
- errprint(" current\n");
+ errprint("environment stack:\n");
+ const char star[] = "\t*";
+ const char empty[] = "";
+ const char *marker = star;
+ std::vector<environment *>::reverse_iterator it
+ = env_stack.rbegin();
+ for (; it != env_stack.rend(); ++it) {
+ errprint("\t%1%2\n", (*it)->name.contents(), marker);
+ marker = empty;
+ }
+ dictionary_iterator dict_it(env_dictionary);
+ symbol nm;
+ bool need_heading = true;
+ while (dict_it.get(&nm, 0 /* nullptr */)) {
+ bool is_in_stack = false;
+ for (it = env_stack.rbegin(); it != env_stack.rend(); ++it)
+ if ((*it)->name == nm) {
+ is_in_stack = true;
+ break;
+ }
+ if (!is_in_stack) {
+ if (need_heading) {
+ errprint("unstacked environments:\n");
+ need_heading = false;
+ }
+ errprint("\t%1\n", nm.contents());
+ }
}
}
fflush(stderr);
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit