gbranden pushed a commit to branch master
in repository groff.
commit fb4d55dc2dad60ebe1ce968c5ca7c8cc346dcaf8
Author: G. Branden Robinson <[email protected]>
AuthorDate: Mon Nov 16 11:27:41 2026 -0600
src/preproc/pic/pic.ypp: Fix code style nits.
* src/preproc/pic/pic.ypp <placeless_element, label>
(lookup_label, look_up_variable): Explicitly compare variable of
pointer type to ISO C++98 null pointer literal, instead of punning it
down to a Boolean. Arrange equality comparisons to avoid inadvertent
assignment to lvalue.
---
ChangeLog | 8 ++++++++
src/preproc/pic/pic.ypp | 8 ++++----
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 7d1437632..eff9750d7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2026-11-16 G. Branden Robinson <[email protected]>
+
+ * src/preproc/pic/pic.ypp <placeless_element, label>
+ (lookup_label, look_up_variable): Explicitly compare variable of
+ pointer type to ISO C++98 null pointer literal, instead of
+ punning it down to a Boolean. Arrange equality comparisons to
+ avoid inadvertent assignment to lvalue.
+
2026-11-16 G. Branden Robinson <[email protected]>
* src/preproc/pic/lex.cpp (get_token): Slightly refactor; use
diff --git a/src/preproc/pic/pic.ypp b/src/preproc/pic/pic.ypp
index aa427b425..a2d73b398 100644
--- a/src/preproc/pic/pic.ypp
+++ b/src/preproc/pic/pic.ypp
@@ -353,7 +353,7 @@ placeless_element:
| VARIABLE ':' '=' any_expr
{
place *p = lookup_label($1);
- if (!p) {
+ if (0 /* nullptr */ == p) {
lex_error("variable '%1' not defined", $1);
YYABORT;
}
@@ -1328,7 +1328,7 @@ label:
LABEL
{
place *p = lookup_label($1);
- if (!p) {
+ if (0 /* nullptr */ == p) {
lex_error("there is no place '%1'", $1);
YYABORT;
}
@@ -1813,7 +1813,7 @@ place *lookup_label(const char *label)
place *pl = tbl->lookup(label);
if (pl)
return pl;
- if (!state)
+ if (0 /* nullptr */ == state)
return 0 /* nullptr */;
tbl = state->tbl;
state = state->prev;
@@ -1833,7 +1833,7 @@ void define_label(const char *label, const place *pl)
bool look_up_variable(const char *name, double *val)
{
place *pl = lookup_label(name);
- if (pl) {
+ if (pl != 0 /* nullptr */) {
*val = pl->x;
return true;
}
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit