gbranden pushed a commit to branch master
in repository groff.
commit 4397e9b4111bbab7ceadefe726949d71f28d2458
Author: G. Branden Robinson <[email protected]>
AuthorDate: Fri Jan 24 14:02:52 2025 -0600
[troff]: Slightly refactor (rename `setx_macro`).
Use more idiomatic C++ style, employing a function overload on the
`charinfo` class's `set_macro()` member function instead of a separate
"extended" version `setx_macro()` that takes an additional argument.
* src/roff/troff/charinfo.h (class charinfo): Do it.
* src/roff/troff/input.cpp (charinfo::setx_macro): Rename this...
(charinfo::set_macro): ...to this, overloading the name.
* src/roff/troff/input.cpp (define_character): Update the two-argument
form's only call site.
---
ChangeLog | 15 +++++++++++++++
src/roff/troff/charinfo.h | 4 ++--
src/roff/troff/input.cpp | 9 +++++++--
3 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f2cba1005..3f9003e6e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2025-01-24 G. Branden Robinson <[email protected]>
+
+ [troff]: Slightly refactor. Use more idiomatic C++ style,
+ employing a function overload on the `charinfo` class's
+ `set_macro()` member function instead of a separate "extended"
+ version `setx_macro()` that takes an additional argument.
+
+ * src/roff/troff/charinfo.h (class charinfo): Do it.
+ * src/roff/troff/input.cpp (charinfo::setx_macro): Rename
+ this...
+ (charinfo::set_macro): ...to this, overloading the name.
+
+ * src/roff/troff/input.cpp (define_character): Update the
+ two-argument form's only call site.
+
2025-01-18 G. Branden Robinson <[email protected]>
* src/roff/troff/input.cpp (define_character_request): Promote
diff --git a/src/roff/troff/charinfo.h b/src/roff/troff/charinfo.h
index b5f0c17f1..b44a53f40 100644
--- a/src/roff/troff/charinfo.h
+++ b/src/roff/troff/charinfo.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1989-2024 Free Software Foundation, Inc.
+/* Copyright (C) 1989-2025 Free Software Foundation, Inc.
Written by James Clark ([email protected])
This file is part of groff.
@@ -94,7 +94,7 @@ public:
void set_special_translation(int, int);
int get_special_translation(bool = false);
macro *set_macro(macro *);
- macro *setx_macro(macro *, char_mode);
+ macro *set_macro(macro *, char_mode);
macro *get_macro();
bool first_time_not_found();
void set_number(int);
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 51fd951b0..ab50f1f54 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -4599,7 +4599,7 @@ void define_character(char_mode mode, const char
*font_name)
m->append((unsigned char) c);
c = get_copy(&n);
}
- m = ci->setx_macro(m, mode);
+ m = ci->set_macro(m, mode);
if (m)
delete m;
tok.next();
@@ -10023,6 +10023,8 @@ void charinfo::set_asciify_code(unsigned char c)
asciify_code = c;
}
+// Replace character definition with macro `m`, returning previous
+// macro if any (if none, return a null pointer).
macro *charinfo::set_macro(macro *m)
{
macro *tem = mac;
@@ -10030,7 +10032,10 @@ macro *charinfo::set_macro(macro *m)
return tem;
}
-macro *charinfo::setx_macro(macro *m, char_mode cm)
+// Replace character definition with macro `m` and update its character
+// mode to `cm`, returning previous macro if any (if none, return a null
+// pointer).
+macro *charinfo::set_macro(macro *m, char_mode cm)
{
macro *tem = mac;
mac = m;
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit