gbranden pushed a commit to branch master
in repository groff.
commit 7f643d1f765c53437471207ffbff11d01e38f57e
Author: G. Branden Robinson <[email protected]>
AuthorDate: Fri Feb 7 18:50:18 2025 -0600
[troff]: Revert most of Savannah #66387 fix.
Retain unit test, which fails at this commit.
See Savannah #66392 for background.
---
ChangeLog | 39 +++------------------------------------
src/roff/troff/env.cpp | 45 +++------------------------------------------
src/roff/troff/env.h | 4 ----
3 files changed, 6 insertions(+), 82 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e0be30d76..24581da80 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2602,47 +2602,14 @@
2024-10-31 G. Branden Robinson <[email protected]>
- [troff]: Couple the current hyphenation language more tightly
- with the environment. This is to ease maintenance of
- multilingual documents, and address a curious situation where an
- environment could bear an automatic hyphenation code that had
- nothing to do with the selected hyphenation language, because
- the `hla` request has to date never altered the environment.
-
- * src/roff/troff/env.h (class environment): Add private member
- variable `language_code` of type `symbol`. Declare public
- member functions `get_language_code()` and
- `set_language_code()`. Declare `environment_switch()` as a
- friend function.
- * src/roff/troff/env.cpp (environment::environment): Plain
- constructor initializes `language_code` as empty string.
- (environment::environment): Copy constructor copies the language
- code from the source object.
- (environment::copy): Member function backing `evc` request
- copies the language code from the source environment.
- (environment::print_env): Report the hyphenation language code
- in use by the environment. Clarify when the automatic
- hyphenation mode is ignored because no hyphenation language is
- configured in the environment.
- (select_hyphenation_language): When the `hla` request is called
- without an argument, set the current environment's hyphenation
- language code to the empty string. With an argument, update the
- environment's hyphenation to the value of the argument. Add
- assertions prior to function return to enforce invariants: (1)
- the current environment's hyphenation language code must not be
- null and (2) the `current_language` global variable and the
- current environment's hyphenation language code must agree.
- (environment_copy, environment_switch): Set the
- `current_language` global variable to current environment's
- hyphenation language code.
- (environment::get_language_code): Implement accessor.
- (environment::set_language_code): Implement mutator.
+ Add test of hyphenation language as a global vs. environmental
+ property.
* src/roff/groff/tests/\
current-language-and-environment-in-sync.sh: Add unit test.
* src/roff/groff/groff.am (groff_TESTS): Run test.
- Fixes <https://savannah.gnu.org/bugs/?66387>.
+ See <https://savannah.gnu.org/bugs/?66387>.
2024-10-30 G. Branden Robinson <[email protected]>
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 0e83cf46a..4abb05f56 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -787,7 +787,6 @@ environment::environment(symbol nm)
line_number_indent(0),
line_number_multiple(1),
no_number_count(0),
- language_code(""),
hyphenation_mode(1),
hyphenation_mode_default(1),
hyphen_line_count(0),
@@ -882,7 +881,6 @@ environment::environment(const environment *e)
line_number_indent(e->line_number_indent),
line_number_multiple(e->line_number_multiple),
no_number_count(e->no_number_count),
- language_code(e->language_code),
hyphenation_mode(e->hyphenation_mode),
hyphenation_mode_default(e->hyphenation_mode_default),
hyphen_line_count(0),
@@ -970,7 +968,6 @@ void environment::copy(const environment *e)
no_number_count = e->no_number_count;
tab_char = e->tab_char;
leader_char = e->leader_char;
- set_language_code(e->language_code.contents());
hyphenation_mode = e->hyphenation_mode;
hyphenation_mode_default = e->hyphenation_mode_default;
fontno = e->fontno;
@@ -3553,10 +3550,6 @@ void environment::print_env()
errprint(" lines remaining for which to suppress numbering: %1\n",
no_number_count);
}
- const char *hl = language_code.contents();
- bool is_hyphenation_impossible = language_code.is_empty();
- errprint(" hyphenation language code: %1\n",
- is_hyphenation_impossible ? "(none)" : hl);
string hf = hyphenation_mode ? "on" : "off";
if (hyphenation_mode & HYPHEN_NOT_LAST_LINE)
hf += ", not on line before vertical position trap";
@@ -3569,10 +3562,8 @@ void environment::print_env()
if (hyphenation_mode & HYPHEN_NOT_FIRST_CHARS)
hf += ", not allowed within first two characters";
hf += '\0';
- errprint(" hyphenation mode: %1 (%2)%3\n", hyphenation_mode,
- hf.contents(),
- is_hyphenation_impossible ? " [no hyphenation language]"
- : "");
+ errprint(" hyphenation mode: %1 (%2)\n", hyphenation_mode,
+ hf.contents());
errprint(" hyphenation mode default: %1\n",
hyphenation_mode_default);
errprint(" count of consecutive hyphenated lines: %1\n",
@@ -3659,7 +3650,6 @@ static void select_hyphenation_language()
{
if (!has_arg()) {
current_language = 0 /* nullptr */;
- curenv->set_language_code("");
skip_line();
return;
}
@@ -3672,22 +3662,10 @@ static void select_hyphenation_language()
(void) language_dictionary.lookup(nm,
static_cast<hyphenation_language *>(current_language));
}
- curenv->set_language_code(nm.contents());
}
- assert(!(curenv->get_language_code().is_null()));
- if (current_language != 0 /* nullptr */)
- assert(strcmp(current_language->name.contents(),
- curenv->get_language_code().contents()) == 0);
skip_line();
}
-// The environment class has no visibility into which hyphenation
-// languages are defined; it has only a code that is either empty
-// or must reference a valid one (and since the code uniquely
-// identifies a language, a `const char *` is more ergonomic than a
-// pointer to a type that's not visible in the class's scope). So
-// updating that code is a two-step process.
-
void environment_copy()
{
if (!has_arg()) {
@@ -3701,27 +3679,14 @@ void environment_copy()
symbol nm = get_long_name();
assert(nm != 0 /* nullptr */);
e = static_cast<environment *>(env_dictionary.lookup(nm));
- if (e != 0 /* nullptr */) {
+ if (e != 0 /* nullptr */)
curenv->copy(e);
- current_language = static_cast<hyphenation_language *>
- (language_dictionary.lookup(e->get_language_code()));
- }
else
error("cannot copy from nonexistent environment '%1'",
nm.contents());
skip_line();
}
-symbol environment::get_language_code()
-{
- return language_code;
-}
-
-void environment::set_language_code(const char *lang)
-{
- language_code = lang;
-}
-
void environment_switch()
{
if (curenv->is_dummy()) {
@@ -3737,8 +3702,6 @@ void environment_switch()
bool seen_eol = curenv->seen_eol;
bool suppress_next_eol = curenv->suppress_next_eol;
curenv = env_stack->env;
- current_language = static_cast<hyphenation_language *>
- (language_dictionary.lookup(curenv->language_code));
curenv->seen_space = seen_space;
curenv->seen_eol = seen_eol;
curenv->suppress_next_eol = suppress_next_eol;
@@ -3756,8 +3719,6 @@ void environment_switch()
}
env_stack = new env_list_node(curenv, env_stack);
curenv = e;
- current_language = static_cast<hyphenation_language *>
- (language_dictionary.lookup(curenv->language_code));
}
}
skip_line();
diff --git a/src/roff/troff/env.h b/src/roff/troff/env.h
index 1d70f5529..6b4ec03f9 100644
--- a/src/roff/troff/env.h
+++ b/src/roff/troff/env.h
@@ -212,7 +212,6 @@ class environment {
int line_number_indent; // in digit spaces
int line_number_multiple;
int no_number_count;
- symbol language_code;
unsigned hyphenation_mode;
unsigned hyphenation_mode_default;
int hyphen_line_count;
@@ -313,8 +312,6 @@ public:
hunits get_input_line_position();
const char *get_tabs();
int is_using_line_tabs();
- symbol get_language_code();
- void set_language_code(const char *);
unsigned get_hyphenation_mode();
unsigned get_hyphenation_mode_default();
int get_hyphen_line_max();
@@ -398,7 +395,6 @@ public:
friend void number_lines();
friend void leader_character();
friend void tab_character();
- friend void environment_switch();
friend void hyphenate_request();
friend void set_hyphenation_mode_default();
friend void no_hyphenate();
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit