gbranden pushed a commit to branch master
in repository groff.
commit 9124004dc0bdd3ac011e937886999a9514923e19
Author: G. Branden Robinson <[email protected]>
AuthorDate: Thu May 28 14:29:49 2026 -0500
src/roff/troff/div.cpp: Refactor `pn` req hanlder.
* src/roff/troff/div.cpp (set_page_number_request): Refactor--trivially
now but not so in the near future. Stop calling `has_arg()`
redundantly. A forthcoming change will alter the semantics of
`has_arg()` to return true only if an _argument_ lies ahead in the
input stream, and a space must occur before any _argument_.
`has_arg()`, when not "peeking", advances the input stream cursor, and
this function has already called it (to throw a diagnostic if the
argument is omitted), so the cursor is already at the argument's first
character. The argument is at the formatter's feet, and does not "lie
ahead". Manual inspection suggests that other request handlers are
already careful not to call `has_arg()` except (1) upon receiving
control from the request-handler dispatcher (via a function pointer);
or (2) after calling a function that itself advances the input stream
cursor, like `read_identifier()`.
---
ChangeLog | 18 ++++++++++++++++++
src/roff/troff/div.cpp | 2 +-
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 72ce77811..35910d79b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2026-05-28 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/div.cpp (set_page_number_request): Refactor--
+ trivially now but not so in the near future. Stop calling
+ `has_arg()` redundantly. A forthcoming change will alter the
+ semantics of `has_arg()` to return true only if an _argument_
+ lies ahead in the input stream, and a space must occur before
+ any _argument_. `has_arg()`, when not "peeking", advances the
+ input stream cursor, and this function has already called it (to
+ throw a diagnostic if the argument is omitted), so the cursor is
+ already at the argument's first character. The argument is at
+ the formatter's feet, and does not "lie ahead". Manual
+ inspection suggests that other request handlers are already
+ careful not to call `has_arg()` except (1) upon receiving
+ control from the request-handler dispatcher (via a function
+ pointer); or (2) after calling a function that itself advances
+ the input stream cursor, like `read_identifier()`.
+
2026-05-25 G. Branden Robinson <[email protected]>
[tfmtodit]: Be more fastidious with heap-allocated memory.
diff --git a/src/roff/troff/div.cpp b/src/roff/troff/div.cpp
index e862b3884..b8eed09cf 100644
--- a/src/roff/troff/div.cpp
+++ b/src/roff/troff/div.cpp
@@ -931,7 +931,7 @@ static void set_page_number_request() // .pn
return;
}
int n = 0;
- if (has_arg() && read_integer_crement(&n, topdiv->get_page_number()))
+ if (read_integer_crement(&n, topdiv->get_page_number()))
topdiv->set_next_page_number(n);
skip_line();
}
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit