groff-commit
[Top][All Lists]
Advanced

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

[groff] 43/63: [troff]: Suppress warning when redundant.


From: G. Branden Robinson
Subject: [groff] 43/63: [troff]: Suppress warning when redundant.
Date: Mon, 19 Aug 2024 20:06:39 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit dec7d527753495df72fcfac33ac98248b9f3e9fd
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Mon Aug 19 12:52:31 2024 -0500

    [troff]: Suppress warning when redundant.
    
    * src/roff/troff/node.cpp (make_glyph_node): Don't throw a warning if
      `get_char_for_escape_parameter()` in "input.cpp" already threw an
      error for the same input token.  Also compare array elements of `const
      char` type to character, not integer, literals.
    
    Before:
    
    $ printf '\\(\001' | nroff -z
    troff:<standard input>:1: error: a leader character is not allowed in an 
escape sequence parameter
    troff:<standard input>:1: warning: special character '' not defined
    
    Now:
    
    $ printf '\\(\001' | ./build/test-groff -T ascii -z
    troff:<standard input>:1: error: a leader character is not allowed in an 
escape sequence parameter
---
 ChangeLog               |  8 ++++++++
 src/roff/troff/node.cpp | 11 ++++++++---
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f2524812d..ff3f657ab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-08-19  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * src/roff/troff/node.cpp (make_glyph_node): Don't throw a
+       warning if `get_char_for_escape_parameter()` in "input.cpp"
+       already threw an error for the same input token.  Also compare
+       array elements of `const char` type to character, not integer,
+       literals.
+
 2024-08-19  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        [troff]: Boolify and rename `compatible_flag`, demoting it from
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index abca748fd..f7089defe 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -5038,9 +5038,14 @@ static node *make_glyph_node(charinfo *s, environment 
*env,
        }
        else if (s->nm.contents()) {
          const char *nm = s->nm.contents();
-         const char *backslash = (nm[1] == 0) ? "\\" : "";
-         warning(WARN_CHAR, "special character '%1%2' not defined",
-                 backslash, nm);
+         // If the contents are empty, get_char_for_escape_parameter()
+         // should already have thrown an error.
+         // XXX: Why are we here if the parse failed that early?
+         if (nm[0] != '\0') {
+           const char *backslash = (nm[1] == '\0') ? "\\" : "";
+           warning(WARN_CHAR, "special character '%1%2' not defined",
+                   backslash, nm);
+         }
        }
       }
       return 0 /* nullptr */;



reply via email to

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