[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 12/17: src/roff/troff/env.cpp: Trivially refactor.
From: |
G. Branden Robinson |
Subject: |
[groff] 12/17: src/roff/troff/env.cpp: Trivially refactor. |
Date: |
Sun, 3 Nov 2024 02:14:23 -0500 (EST) |
gbranden pushed a commit to branch master
in repository groff.
commit d272e93213f47e88193f1b52d75454aa8fd53170
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Thu Oct 31 00:05:31 2024 -0500
src/roff/troff/env.cpp: Trivially refactor.
* src/roff/troff/env.cpp (environment_switch, environment_copy):
Relocate function definitions to prepare for feature change that will
require additional type and global variable visibility within them.
---
ChangeLog | 7 +++
src/roff/troff/env.cpp | 116 ++++++++++++++++++++++++-------------------------
2 files changed, 64 insertions(+), 59 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index dd9003630..e696a0fa8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-10-30 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ * src/roff/troff/env.cpp (environment_switch, environment_copy):
+ Trivially refactor. Relocate function definitions to prepare
+ for feature change that will require additional type and global
+ variable visibility within them.
+
2024-10-30 G. Branden Robinson <g.branden.robinson@gmail.com>
* src/roff/troff/env.cpp (environment::print_env): Describe
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 5cb41e157..73b725961 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -1235,65 +1235,6 @@ node *environment::extract_output_line()
return nd;
}
-/* environment related requests */
-
-void environment_switch()
-{
- if (curenv->is_dummy()) {
- error("cannot switch out of dummy environment");
- }
- else {
- symbol nm = get_long_name();
- if (nm.is_null()) {
- if (env_stack == 0 /* nullptr */)
- error("environment stack underflow");
- 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;
- }
- }
- else {
- environment *e = (environment *)env_dictionary.lookup(nm);
- if (!e) {
- e = new environment(nm);
- (void)env_dictionary.lookup(nm, e);
- }
- env_stack = new env_list_node(curenv, env_stack);
- curenv = e;
- }
- }
- skip_line();
-}
-
-void environment_copy()
-{
- if (!has_arg()) {
- warning(WARN_MISSING, "environment copy request expects an"
- " argument");
- skip_line();
- return;
- }
- environment *e = 0 /* nullptr */;
- tok.skip();
- symbol nm = get_long_name();
- assert(nm != 0 /* nullptr */);
- e = static_cast<environment *>(env_dictionary.lookup(nm));
- if (e != 0 /* nullptr */)
- curenv->copy(e);
- else
- error("cannot copy from nonexistent environment '%1'",
- nm.contents());
- skip_line();
-}
-
void fill_color_change()
{
symbol s = get_name();
@@ -3715,6 +3656,63 @@ static void select_hyphenation_language()
skip_line();
}
+void environment_copy()
+{
+ if (!has_arg()) {
+ warning(WARN_MISSING, "environment copy request expects an"
+ " argument");
+ skip_line();
+ return;
+ }
+ environment *e = 0 /* nullptr */;
+ tok.skip();
+ symbol nm = get_long_name();
+ assert(nm != 0 /* nullptr */);
+ e = static_cast<environment *>(env_dictionary.lookup(nm));
+ if (e != 0 /* nullptr */)
+ curenv->copy(e);
+ else
+ error("cannot copy from nonexistent environment '%1'",
+ nm.contents());
+ skip_line();
+}
+
+void environment_switch()
+{
+ if (curenv->is_dummy()) {
+ error("cannot switch out of dummy environment");
+ }
+ else {
+ symbol nm = get_long_name();
+ if (nm.is_null()) {
+ if (env_stack == 0 /* nullptr */)
+ error("environment stack underflow");
+ 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;
+ }
+ }
+ else {
+ environment *e = (environment *)env_dictionary.lookup(nm);
+ if (!e) {
+ e = new environment(nm);
+ (void)env_dictionary.lookup(nm, e);
+ }
+ env_stack = new env_list_node(curenv, env_stack);
+ curenv = e;
+ }
+ }
+ skip_line();
+}
+
const int WORD_MAX = 256; // we use unsigned char for offsets in
// hyphenation exceptions
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 12/17: src/roff/troff/env.cpp: Trivially refactor.,
G. Branden Robinson <=