gbranden pushed a commit to branch master
in repository groff.

commit 2250ab46df2d084a335d2308d4150e3416a58152
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Jul 12 04:51:38 2026 -0500

    [troff]: Improve diagnostic message.
    
    ...when griping about nonexistent special character with a neutral
    apostrophe in its identifier.
    
    * src/roff/troff/node.cpp (make_glyph_node): Do it.
    
    Before:
    troff:../contrib/mom/examples/mon_premier_doc.mom:28: warning: special 
character ''e' not defined [-w char]
    
    After:
    troff:../contrib/mom/examples/mon_premier_doc.mom:28: warning: special 
character "'e" not defined [-w char]
---
 ChangeLog                |  6 ++++++
 src/roff/troff/input.cpp |  1 +
 src/roff/troff/node.cpp  | 14 ++++++++++++--
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index cb44b781f..6fd577f31 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2026-07-12  G. Branden Robinson <[email protected]>
+
+       * src/roff/troff/node.cpp (make_glyph_node): Improve diagnostic
+       message when griping about nonexistent special character with a
+       neutral apostrophe in its identifier.
+
 2026-07-12  G. Branden Robinson <[email protected]>
 
        * src/roff/troff/input.cpp (token::description): Revise
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index effcb4960..6b627165e 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -3162,6 +3162,7 @@ const char *token::description()
     // double quotes if this one does.  A user-defined special character
     // name could contain both characters; we expect such users to lie
     // comfortably in the bed they made for themselves.
+    // XXX: duplicates logic in node.cpp:make_glyph_node()
     {
       const char *sc = nm.contents();
       char qc = '\'';
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index ca42ba8a4..0d3915108 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -5661,13 +5661,23 @@ static node *make_glyph_node(charinfo *s, environment 
*env,
                    int(input_code));
        }
        else if (s->nm.contents()) {
+         // We normally use apostrophes for quotation in diagnostic
+         // messages, but many special character names contain them.
+         // Fall back to double quotes if this one does.  A user-
+         // defined special character name could contain both
+         // characters; we expect such users to lie comfortably in the
+         // bed they made for themselves.
+         // XXX: duplicates logic in input.cpp:token::description()
          const char *nm = s->nm.contents();
+         char qc = '\'';
+         if (strchr(nm, '\'') != 0 /* nullptr */)
+           qc = '"';
          // If the contents are empty, get_char_for_escape_parameter()
          // should already have thrown an error.
          if (nm[0] != '\0') {
            const char *backslash = (nm[1] == '\0') ? "\\" : "";
-           warning(WARN_CHAR, "special character '%1%2' not defined",
-                   backslash, nm);
+           warning(WARN_CHAR, "special character %1%2%3%1 not defined",
+                   qc, backslash, nm);
          }
        }
       }

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to