gbranden pushed a commit to branch master
in repository groff.
commit cb185b2841d49e0d602b756c9d63c397823e3553
Author: G. Branden Robinson <[email protected]>
AuthorDate: Tue Jul 7 09:47:50 2026 -0500
src/roff/troff/node.cpp: Refactor.
* src/roff/troff/node.cpp (zoom_font_request): Call
`read_font_identifier()` instead of `read_identifier()` to gather
first argument. Emit error diagnostic on an attempt to apply a zoom
factor to a mounting position. This was already prohibited in 1.24.0,
but now, thanks to other refactoring, we can diagnose it more easily.
---
ChangeLog | 9 +++++++++
src/roff/troff/node.cpp | 38 ++++++++++++++------------------------
2 files changed, 23 insertions(+), 24 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 0e634e879..eff7bb29d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2026-07-07 G. Branden Robinson <[email protected]>
+
+ * src/roff/troff/node.cpp (zoom_font_request): Refactor. Call
+ `read_font_identifier()` instead of `read_identifier()` to
+ gather first argument. Emit error diagnostic on an attempt to
+ apply a zoom factor to a mounting position. This was already
+ prohibited in 1.24.0, but now, thanks to other refactoring, we
+ can diagnose it more easily.
+
2026-07-05 G. Branden Robinson <[email protected]>
* src/roff/troff/node.cpp (suppress_node::suppress_node):
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index f2ec44f10..ca42ba8a4 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -7239,47 +7239,37 @@ static void zoom_font_request() // .fzoom
skip_line();
return;
}
- symbol font_name = read_identifier();
- // has_arg()+read_identifier() should ensure the assertion succeeds.
- assert(font_name != 0 /* nullptr */);
- if (is_nonnegative_integer(font_name.contents())) {
- warning(WARN_FONT, "cannot set zoom factor of a font mounting"
- " position");
+ font_lookup_info finfo;
+ if (!read_font_identifier(&finfo)) {
+ font_lookup_error(finfo, "to set its zoom factor");
skip_line();
return;
}
- if (!(has_arg())) {
- warning(WARN_MISSING, "font zoom factor request expects zoom factor"
- " argument");
+ if (0 /* nullptr */ == finfo.requested_name) {
+ error("applying a zoom factor to a font mounting position"
+ " is not yet supported");
skip_line();
return;
}
int fpos = next_available_font_mounting_position();
- if (!(mount_font_at_position(font_name, fpos))) {
+ if (!(mount_font_at_position(finfo.requested_name, fpos))) {
error("cannot mount font '%1' to set a zoom factor for it",
- font_name.contents());
+ finfo.requested_name);
skip_line();
return;
}
-#if 0
- // This would be a good diagnostic to have, but
- // mount_font_at_position() is too formally complex to make it easy.
- // Instead it will fail in the above test on a font named "R", for
- // instance, when that is literally true but might not help users who
- // don't understand that "R", "I", "B", and "BI" are (by default)
- // abstract styles, not fonts in the GNU troff sense. It is a shame
- // that a lot of our validation functions are willing only to handle
- // arguments that they eat from the input stream (i.e., you can't pass
- // them information you obtained elsewhere). That design also forces
- // us to validate request arguments in the order they appear in the
- // input, and seems unnecessarily inflexible to me. --GBR
if (font_table[fpos]->is_style()) {
warning(WARN_FONT, "ignoring request to set font zoom factor on an"
" abstract style");
skip_line();
return;
}
-#endif
+ if (!(has_arg())) {
+ warning(WARN_MISSING, "font zoom factor request expects zoom factor"
+ " argument");
+ skip_line();
+ return;
+ }
int zoom = 0;
read_integer(&zoom);
if (zoom < 0) {
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit