groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 95/115: [troff]: Fix Savannah #64166.


From: G. Branden Robinson
Subject: [groff] 95/115: [troff]: Fix Savannah #64166.
Date: Thu, 1 Jun 2023 10:46:16 -0400 (EDT)

gbranden pushed a commit to branch branden-2022-06-01
in repository groff.

commit 081b4d8f34600cc6ec35f43eefc9d2643d9550ae
Author: G. Branden Robinson <g.branden.robinson@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 b6376e22e..ddb5b600b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2023-05-13  G. Branden Robinson <g.branden.robinson@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.robinson@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));



reply via email to

[Prev in Thread] Current Thread [Next in Thread]