bug-groff
[Top][All Lists]
Advanced

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

[bug #64594] [troff] "warning: cannot select font 'C'"


From: G. Branden Robinson
Subject: [bug #64594] [troff] "warning: cannot select font 'C'"
Date: Fri, 25 Aug 2023 10:44:48 -0400 (EDT)

Follow-up Comment #3, bug #64594 (project groff):

I noted the following at the [https://github.com/jgm/pandoc/issues/9020 pandoc
ticket #9020], but here it is for our benefit.

Specifically, the commit that caused the formatter to produce these warnings
where it did not before was this.


commit 1986da1d4bb11dc0421e004b153729b3d2a2a3ca (HEAD, refs/bisect/bad)
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Mon Jun 20 14:15:38 2022 -0500

    [troff]: Warn if nonexistent font name selected.
    
    * src/roff/troff/env.cpp (font_change):
    * src/roff/troff/input.cpp (token::next): Warn upon selection of a
      nonexistent font name.
    
    Fixes <https://savannah.gnu.org/bugs/?62656>.
    
    Also annotate a null pointer to ease any future transition to C++11,
    which defines a keyword for it.

diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 7aeb5bd22..c564ebc82 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -1202,10 +1202,13 @@ void font_change()
        break;
       }
   }
+  // environment::set_font warns if a bogus mounting position is
+  // requested.  We must warn here if a bogus font name is selected.
   if (is_number)
-    curenv->set_font(atoi(s.contents()));
+    (void) curenv->set_font(atoi(s.contents()));
   else
-    curenv->set_font(s);
+    if (!curenv->set_font(s))
+      warning(WARN_FONT, "cannot select font '%1'", s.contents());
   skip_line();
 }
 
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 5a299121d..8aadc243a 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -2052,10 +2052,16 @@ void token::next()
          for (p = s.contents(); *p != '\0'; p++)
            if (!csdigit(*p))
              break;
-         if (*p || s.is_empty())
-           curenv->set_font(s);
+         // environment::set_font warns if a bogus mounting position is
+         // requested.  We must warn here if a bogus font name is
+         // selected.
+         if (*p != 0 /* nullptr */ || s.is_empty()) {
+           if (!curenv->set_font(s))
+             warning(WARN_FONT, "cannot select font '%1'",
+                     s.contents());
+         }
          else
-           curenv->set_font(atoi(s.contents()));
+           (void) curenv->set_font(atoi(s.contents()));
          if (!compatible_flag)
            have_input = 1;
          break;




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?64594>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

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