gbranden pushed a commit to branch master
in repository groff.
commit fdd490b10ae2a733392ff472f98740eb15cb4025
Author: G. Branden Robinson <[email protected]>
AuthorDate: Mon Nov 17 22:39:49 2025 -0600
[troff]: Fix code style nits.
* src/roff/troff/input.cpp (define_class): Explicitly compare values of
pointer type to null pointer literals instead of letting them pun down
to Booleans. Arrange equality comparison to avoid inadvertent lvalue
assignment.
Also annotate null pointers with `nullptr` comment to ease any future
transition to C++11, which defines it as a keyword.
---
ChangeLog | 7 +++++++
src/roff/troff/input.cpp | 16 ++++++++--------
2 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 6be839e08..e2bee1924 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2025-11-17 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/input.cpp (define_class): Fix code style nits.
+ Explicitly compare values of pointer type to null pointer
+ literals instead of letting them pun down to Booleans. Arrange
+ equality comparison to avoid inadvertent lvalue assignment.
+
2025-11-17 G. Branden Robinson <[email protected]>
[hpftodit,troff]: Fix code style nit.
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 886425696..58fc08420 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -8537,10 +8537,10 @@ void define_class()
charinfo *child1 = 0 /* nullptr */, *child2 = 0 /* nullptr */;
while (!tok.is_newline() && !tok.is_eof()) {
tok.skip();
- if (child1 != 0 && tok.ch() == '-') {
+ if ((child1 != 0 /* nullptr */) && (tok.ch() == '-')) {
tok.next();
child2 = tok.get_char(true /* required */);
- if (!child2) {
+ if (0 /* nullptr */ == child2) {
warning(WARN_MISSING,
"missing end of character range in class '%1'",
nm.contents());
@@ -8569,9 +8569,9 @@ void define_class()
return;
}
ci->add_to_class(u1, u2);
- child1 = child2 = 0;
+ child1 = child2 = 0 /* nullptr */;
}
- else if (child1 != 0) {
+ else if (child1 != 0 /* nullptr */) {
if (child1->is_class()) {
if (ci == child1) {
warning(WARN_SYNTAX, "invalid cyclic class nesting");
@@ -8591,17 +8591,17 @@ void define_class()
}
ci->add_to_class(u1);
}
- child1 = 0;
+ child1 = 0 /* nullptr */;
}
child1 = tok.get_char(true /* required */);
tok.next();
- if (!child1) {
+ if (0 /* nullptr */ == child1) {
if (!tok.is_newline())
skip_line();
break;
}
}
- if (child1 != 0) {
+ if (child1 != 0 /* nullptr */) {
if (child1->is_class()) {
if (ci == child1) {
warning(WARN_SYNTAX, "invalid cyclic class nesting");
@@ -8621,7 +8621,7 @@ void define_class()
}
ci->add_to_class(u1);
}
- child1 = 0;
+ child1 = 0 /* nullptr */;
}
if (!ci->is_class()) {
warning(WARN_SYNTAX,
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit