groff-commit
[Top][All Lists]
Advanced

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

[groff] 17/19: [troff]: Warn if device DESC file can't load font.


From: G. Branden Robinson
Subject: [groff] 17/19: [troff]: Warn if device DESC file can't load font.
Date: Thu, 16 Sep 2021 08:59:05 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit d0cfa32a4b0086ea26d09bf8babc37b0747222d0
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Thu Sep 16 03:09:21 2021 +1000

    [troff]: Warn if device DESC file can't load font.
    
    [troff]: Throw warning diagnostic if device DESC file attempts to load
    unavailable fonts.
    
    * src/roff/troff/input.cpp (main): Take advantage of new Boolean return
      values of `mount_style()` and `mount_font()` to produce warning
      diagnostics if mounting a style or font as directed by the DESC file
      fails.  Explain in a comment why, at present, this style mount warning
      will never actually trip.
    
    Also use consistent brace style.
---
 ChangeLog                | 11 +++++++++++
 src/roff/troff/input.cpp | 20 ++++++++++++++------
 2 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 65058bc..f772d23 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2021-09-16  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       [troff]: Throw warning diagnostic if device DESC file attempts
+       to load unavailable fonts.
+
+       * src/roff/troff/input.cpp (main): Take advantage of new Boolean
+       return values of `mount_style()` and `mount_font()` to produce
+       warning diagnostics if mounting a style or font as directed by
+       the DESC file fails.  Explain in a comment why, at present, this
+       style mount warning will never actually trip.
+
 2021-09-15  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        [troff]: Lift font mounting diagnostic messages to be closer to
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 4b214ed..abe9bf0 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -8140,15 +8140,23 @@ int main(int argc, char **argv)
   font_size::init_size_table(font::sizes);
   int i;
   int j = 1;
-  if (font::style_table) {
+  if (font::style_table)
     for (i = 0; font::style_table[i]; i++)
-      mount_style(j++, symbol(font::style_table[i]));
-  }
+      // Mounting a style can't actually fail due to a bad style name;
+      // that's not determined until the full font name is resolved.
+      // The DESC file also can't provoke a problem by requesting over a
+      // thousand slots in the style table.
+      if (!mount_style(j++, symbol(font::style_table[i])))
+       warning(WARN_FONT, "cannot mount style '%1' directed by 'DESC'"
+               " file for device '%2'", font::style_table[i], device);
   for (i = 0; font::font_name_table[i]; i++, j++)
-    // In the DESC file a font name of 0 (zero) means leave this
-    // position empty.
+    // In the DESC file, a font name of 0 (zero) means "leave this
+    // position empty".
     if (strcmp(font::font_name_table[i], "0") != 0)
-      mount_font(j, symbol(font::font_name_table[i]));
+      if (!mount_font(j, symbol(font::font_name_table[i])))
+       warning(WARN_FONT, "cannot mount font '%1' directed by 'DESC'"
+               " file for device '%2'", font::font_name_table[i],
+               device);
   curdiv = topdiv = new top_level_diversion;
   if (nflag)
     topdiv->set_next_page_number(next_page_number);



reply via email to

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