gbranden pushed a commit to branch master
in repository groff.
commit a52141ac46eef95dd1f85e4c2e0a336affa9bcc9
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu Aug 8 06:53:23 2024 -0500
[troff]: Continue fixing Savannah #66054.
* src/roff/troff/input.cpp (set_hyphenation_codes): Handle the common
case (copying the existing hyphenation code of one character to
another) first. Support clearing a character's hyphenation code by
copying that of a character that lacks one. Reorganize for clarity,
and add comments.
Continues fixing <https://savannah.gnu.org/bugs/?66054>.
---
ChangeLog | 10 ++++++++++
src/roff/troff/input.cpp | 23 ++++++++++++-----------
2 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index de9cd6205..aa28b4ac7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2024-08-08 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/input.cpp (set_hyphenation_codes): Handle the
+ common case (copying the existing hyphenation code of one
+ character to another) first. Support clearing a character's
+ hyphenation code by copying that of a character that lacks one.
+ Reorganize for clarity, and add comments.
+
+ Continues fixing <https://savannah.gnu.org/bugs/?66054>.
+
2024-08-07 G. Branden Robinson <[email protected]>
* src/roff/troff/env.cpp (hyphenate): Slightly refactor.
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index cc7d9dd71..946b93570 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -7309,25 +7309,26 @@ static void set_hyphenation_codes()
error("cannot use the hyphenation code of a numeral");
break;
}
- unsigned char new_code = 0; // TODO: int
+ unsigned char new_code = 0;
charinfo *cisrc = tok.get_char();
- if (csrc != 0)
- new_code = csrc;
- else {
+ if (cisrc != 0 /* nullptr */)
+ // Common case: assign destination character the hyphenation code
+ // of the source character.
+ new_code = cisrc->get_hyphenation_code();
+ if (0 == csrc) {
if (0 /* nullptr */ == cisrc) {
error("expected ordinary or special character, got %1",
tok.description());
break;
}
- // source character is special
- if (0 == cisrc->get_hyphenation_code()) {
- error("second member of hyphenation code pair must be an"
- " ordinary character, or a special character already"
- " assigned a hyphenation code");
- break;
- }
new_code = cisrc->get_hyphenation_code();
}
+ else {
+ // If assigning a ordinary character's hyphenation code to itself,
+ // use its character code point as the value.
+ if (csrc == cdst)
+ new_code = tok.ch();
+ }
cidst->set_hyphenation_code(new_code);
if (cidst->get_translation()
&& cidst->get_translation()->get_translation_input())
_______________________________________________
Groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit