gbranden pushed a commit to branch master
in repository groff.
commit 87363c0af29f1d3856a3d7af6996b2307ded9620
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Apr 1 05:44:38 2026 -0500
src/roff/troff/dictionary.h: Improve code style.
* src/roff/troff/dictionary.h (object_dictionary_iterator::get): Use
explicit `reinterpret_cast` c++ operator instead of c-style cast.
annotate why we use this footgun.
Also drop some unnecessary blank lines.
---
ChangeLog | 6 ++++++
src/roff/troff/dictionary.h | 6 +++---
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e48ec4c83..d0f6948d9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,12 @@
disclose the specific format demanded. Also tighten message
wording.
+2026-04-01 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/dictionary.h (object_dictionary_iterator::get):
+ Use explicit `reinterpret_cast` C++ operator instead of C-style
+ cast. Annotate why we use this footgun.
+
2026-04-01 G. Branden Robinson <[email protected]>
* src/roff/troff/env.cpp (print_hyphenation_exceptions): Skip
diff --git a/src/roff/troff/dictionary.h b/src/roff/troff/dictionary.h
index 258271f5e..b6e726574 100644
--- a/src/roff/troff/dictionary.h
+++ b/src/roff/troff/dictionary.h
@@ -17,7 +17,6 @@ for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
// There is no distinction between a name with no value and a name with
// a 0 (nullptr) value. Null names are not permitted; they are ignored.
@@ -82,10 +81,11 @@ public:
friend class object_dictionary_iterator;
};
-
inline bool object_dictionary_iterator::get(symbol *sp, object **op)
{
- return di.get(sp, (void **)op);
+ // We must use the nuclear `reinterpret_cast` operator because GNU
+ // troff's dictionary class uses a pre-STL approach to containers.
+ return di.get(sp, reinterpret_cast<void **>(op));
}
// Local Variables:
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit