gbranden pushed a commit to branch branden-2023-07-05 in repository groff. commit 11f5dc218190be1b1cad8b0a048fe8be8c181e90 Author: G. Branden Robinson <g.branden.robin...@gmail.com> AuthorDate: Mon May 8 21:49:19 2023 -0500
[troff]: Fix Savannah #64166. * src/roff/troff/node.cpp (bold_font): Add `WARN_MISSING` diagnostic if request given no arguments; it does nothing, and the behavior of this request is sufficiently complex that it's worth saying so. Stop throwing font lookup error if second argument cannot be resolved as a font name; it might be an emboldening amount instead. Fixes <https://savannah.gnu.org/bugs/?64166>. --- ChangeLog | 11 +++++++++++ src/roff/troff/node.cpp | 21 +++++++++++---------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2f4fe5ff0..c79e41bad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2023-05-13 G. Branden Robinson <g.branden.robin...@gmail.com> + + [troff]: Fix Savannah #64166. + + * src/roff/troff/node.cpp (bold_font): Add `WARN_MISSING` + diagnostic if request given no arguments; it does nothing, and + the behavior of this request is sufficiently complex that it's + worth saying so. Stop throwing font lookup error if second + argument cannot be resolved as a font name; it might be an + emboldening amount instead. + 2023-05-10 G. Branden Robinson <g.branden.robin...@gmail.com> * tmac/s.tmac (PE): Turn on no-space mode after a pic(1) diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp index dcc6aefbe..304d25cc0 100644 --- a/src/roff/troff/node.cpp +++ b/src/roff/troff/node.cpp @@ -6415,21 +6415,24 @@ hunits env_narrow_space_width(environment *env) return font_table[fn]->get_narrow_space_width(fs); } +// XXX: We can only conditionally (un)embolden a font specified by name, +// not position. Does ".bd 1 2" mean "embolden font position 1 by 2 +// units" (really one unit), or "stop conditionally emboldening font 2 +// when font 1 is selected"? + void bold_font() { font_lookup_info finfo; - if (!has_font(&finfo)) + if (!(has_arg())) + warning(WARN_MISSING, "font name or position expected in" + " emboldening request"); + else if (!has_font(&finfo)) font_lookup_error(finfo, "for emboldening"); else { int n = finfo.position; if (has_arg()) { - // This is a bit non-orthogonal, but faithful to CSTR #54. We can - // only conditionally embolden a font specified by name, not - // position, so ".bd S B 4" works but ".bd 5 3 4" does not. The - // latter bolds the font at position 5 unconditionally, and - // ignores the third argument. if (tok.usable_as_delimiter()) { - font_lookup_info finfo2; + font_lookup_info finfo2; if (!has_font(&finfo2)) font_lookup_error(finfo2, "for conditional emboldening"); else { @@ -6442,9 +6445,7 @@ void bold_font() } } else { - font_lookup_info finfo2; - if (!has_font(&finfo2)) - font_lookup_error(finfo2, "for conditional emboldening"); + // A numeric second argument must be an emboldening amount. units offset; if (get_number(&offset, 'u') && offset >= 1) font_table[n]->set_bold(hunits(offset - 1)); _______________________________________________ Groff-commit mailing list Groff-commit@gnu.org https://lists.gnu.org/mailman/listinfo/groff-commit