gbranden pushed a commit to branch master
in repository groff.
commit 6d2b6dee361b836b0dffaffd50f3225a2f218f96
Author: G. Branden Robinson <[email protected]>
AuthorDate: Fri May 30 19:22:53 2025 -0500
[troff]: Trivially refactor.
...continuing naming reform of functions that advance the input stream
pointer to use the verb "read" instead of "get" or "has", which are more
general, and can refer to accessor functions that don't mutate the state
of the formatter.
* src/roff/troff/token.h:
* src/roff/troff/input.cpp:
(get_optional_char): Rename this...
(read_character): ...to this.
* src/roff/troff/env.cpp (tab_character, leader_character)
(hyphen_char, field_characters):
* src/roff/troff/input.cpp (set_page_character):
* src/roff/troff/node.cpp (set_soft_hyphen_character): Update call
sites.
---
ChangeLog | 18 ++++++++++++++++++
src/roff/troff/env.cpp | 10 +++++-----
src/roff/troff/input.cpp | 5 +++--
src/roff/troff/node.cpp | 2 +-
src/roff/troff/token.h | 2 +-
5 files changed, 28 insertions(+), 9 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 43bf17b2a..321c6110b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2025-05-30 G. Branden Robinson <[email protected]>
+
+ [troff]: Trivially refactor, continuing naming reform of
+ functions that advance the input stream pointer to use the verb
+ "read" instead of "get" or "has", which are more general, and
+ can refer to accessor functions that don't mutate the state of
+ the formatter.
+
+ * src/roff/troff/token.h:
+ * src/roff/troff/input.cpp:
+ (get_optional_char): Rename this...
+ (read_character): ...to this.
+ * src/roff/troff/env.cpp (tab_character, leader_character)
+ (hyphen_char, field_characters):
+ * src/roff/troff/input.cpp (set_page_character):
+ * src/roff/troff/node.cpp (set_soft_hyphen_character): Update
+ call sites.
+
2025-05-30 G. Branden Robinson <[email protected]>
* src/roff/troff/node.cpp (set_soft_hyphen_character):
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 981994df5..90bb92a08 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -320,13 +320,13 @@ void init_environments()
void tab_character()
{
- curenv->tab_char = get_optional_char();
+ curenv->tab_char = read_character();
skip_line();
}
void leader_character()
{
- curenv->leader_char = get_optional_char();
+ curenv->leader_char = read_character();
skip_line();
}
@@ -1795,7 +1795,7 @@ void set_hyphenation_mode_default()
void hyphen_char()
{
- curenv->hyphen_indicator_char = get_optional_char();
+ curenv->hyphen_indicator_char = read_character();
skip_line();
}
@@ -3019,9 +3019,9 @@ tab_type environment::distance_to_next_tab(hunits
*distance, hunits *leftpos)
void field_characters()
{
- field_delimiter_char = get_optional_char();
+ field_delimiter_char = read_character();
if (field_delimiter_char)
- padding_indicator_char = get_optional_char();
+ padding_indicator_char = read_character();
else
padding_indicator_char = 0 /* nullptr */;
skip_line();
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 7093abcf8..fcc45bd6b 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -5966,7 +5966,7 @@ charinfo *page_character;
void set_page_character()
{
- page_character = get_optional_char();
+ page_character = read_character();
skip_line();
}
@@ -8352,11 +8352,12 @@ charinfo *token::get_char(bool required, bool
suppress_creation)
return 0 /* nullptr */;
}
-charinfo *get_optional_char()
+charinfo *read_character(/* TODO?: bool required */)
{
while (tok.is_space())
tok.next();
charinfo *ci = tok.get_char();
+ // TODO?: if (required && (0 /* nullptr */ == ci))
if (0 /* nullptr */ == ci)
check_missing_character();
else
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index 074d14b81..7c0f8af40 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -7316,7 +7316,7 @@ static void set_kerning_mode()
static void set_soft_hyphen_character()
{
- soft_hyphen_char = get_optional_char();
+ soft_hyphen_char = read_character();
if (0 /* nullptr */ == soft_hyphen_char)
soft_hyphen_char = get_charinfo(HYPHEN_SYMBOL);
skip_line();
diff --git a/src/roff/troff/token.h b/src/roff/troff/token.h
index 37a6d3b9c..290d1387f 100644
--- a/src/roff/troff/token.h
+++ b/src/roff/troff/token.h
@@ -114,7 +114,7 @@ extern token tok; // the current token
extern symbol get_name(bool /* required */ = false);
extern symbol get_long_name(bool /* required */ = false);
-extern charinfo *get_optional_char();
+extern charinfo *read_character(); // TODO?: bool /* required */ = false
extern char *read_rest_of_line_as_argument();
extern void check_missing_character();
extern void skip_line();
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit