gbranden pushed a commit to branch master
in repository groff.

commit a9e4729cf72a758387c1f41e73a3f6bb955b1832
Author: G. Branden Robinson <[email protected]>
AuthorDate: Mon Oct 20 14:14:48 2025 -0500

    [troff]: Throw syntax warning on chars after `\c`.
    
    * src/roff/troff/env.cpp (environment::add_char): Throw syntax warning
      upon encountering formattable ordinary or special characters after
      `\c` escape sequence on an input line.
    
    * src/roff/troff/troff.1.man (Warnings): Document it.
    
    Illustration:
    
    $ printf 'foo\\cbar\n' | ./build/test-groff -z
    troff:<standard input>:1: warning: ignoring character 'b' on input line 
after output line continuation escape sequence
    troff:<standard input>:1: warning: ignoring character 'a' on input line 
after output line continuation escape sequence
    troff:<standard input>:1: warning: ignoring character 'r' on input line 
after output line continuation escape sequence
    $ printf 'foo\\c\\[aq]\n' | ./build/test-groff -z
    troff:<standard input>:1: warning: ignoring special character on input line 
after output line continuation escape sequence
    $ printf 'foo\\c!"#$%%&'"'"'\n' | ./build/test-groff -z
    troff:<standard input>:1: warning: ignoring character '!' on input line 
after output line continuation escape sequence
    troff:<standard input>:1: warning: ignoring character '"' on input line 
after output line continuation escape sequence
    troff:<standard input>:1: warning: ignoring character '#' on input line 
after output line continuation escape sequence
    troff:<standard input>:1: warning: ignoring character '$' on input line 
after output line continuation escape sequence
    troff:<standard input>:1: warning: ignoring character '%' on input line 
after output line continuation escape sequence
    troff:<standard input>:1: warning: ignoring character '&' on input line 
after output line continuation escape sequence
    troff:<standard input>:1: warning: ignoring character "'" on input line 
after output line continuation escape sequence
---
 ChangeLog                  |  7 +++++++
 src/roff/troff/env.cpp     | 14 ++++++++++++--
 src/roff/troff/troff.1.man |  2 ++
 3 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 42a19c145..412881ccd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2025-10-20  G. Branden Robinson <[email protected]>
+
+       * src/roff/troff/env.cpp (environment::add_char): Throw syntax
+       warning upon encountering formattable ordinary or special
+       characters after `\c` escape sequence on an input line.
+       * src/roff/troff/troff.1.man (Warnings): Document it.
+
 2025-10-20  G. Branden Robinson <[email protected]>
 
        * tmac/an.tmac (an*end-hyperlink): Work around apparently
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 566baf446..73408f956 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -343,8 +343,18 @@ void leader_character_request()
 void environment::add_char(charinfo *ci)
 {
   node *gc_np = 0 /* nullptr */;
-  if (was_line_interrupted)
-    ;
+  if (was_line_interrupted) {
+    unsigned char cc = ci->get_ascii_code();
+    if (0 == cc)
+      warning(WARN_SYNTAX, "ignoring special character on input line"
+             " after output line continuation escape sequence");
+    else if (cc != '\'' )
+      warning(WARN_SYNTAX, "ignoring character '%1' on input line after"
+             " output line continuation escape sequence", cc);
+    else
+      warning(WARN_SYNTAX, "ignoring character \"%1\" on input line"
+             " after output line continuation escape sequence", cc);
+  }
   // don't allow fields in dummy environments
   else if (ci == field_delimiter_char && !is_dummy_env) {
     if (has_current_field)
diff --git a/src/roff/troff/troff.1.man b/src/roff/troff/troff.1.man
index ed6cd3029..e1fa1d432 100644
--- a/src/roff/troff/troff.1.man
+++ b/src/roff/troff/troff.1.man
@@ -796,6 +796,8 @@ It never occurs in compatibility mode.
 A self-contradictory hyphenation mode or character flags were requested;
 an empty or incomplete numeric expression was encountered;
 an operand to a numeric operator was missing;
+an attempt was made to format characters on an input line
+after an output line continuation escape sequence;
 a recognized but inapposite escape sequence
 or unprintable character code
 was used in a device extension command;

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

Reply via email to