gbranden pushed a commit to branch master
in repository groff.

commit ecae8c838bf806d4091311fda363a34bf3060831
Author: G. Branden Robinson <[email protected]>
AuthorDate: Tue Apr 21 14:01:49 2026 -0500

    [troff]: Style-warn on nilpotent `\{` and `\}`.
    
    Throw warning in category "style" when nilpotent brace escape sequences
    are encountered.
    
    * src/roff/troff/input.cpp (read_character_in_copy_mode): Do it.
    
    * doc/groff.texi.in (Conditional Blocks, Warnings):
    * man/groff.7.man (Conditional blocks):
    * src/roff/troff/troff.1.man (Warnings): Document new warning
      circumstance.
---
 ChangeLog                  | 12 ++++++++++++
 doc/groff.texi.in          | 12 ++++++++++--
 man/groff.7.man            | 13 +++++++++++--
 src/roff/troff/input.cpp   |  2 ++
 src/roff/troff/troff.1.man |  1 +
 5 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f6aae51f4..17c08f2ce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2026-04-21  G. Branden Robinson <[email protected]>
+
+       [troff]: Throw warning in category "style" when nilpotent brace
+       escape sequences are encountered.
+
+       * src/roff/troff/input.cpp (read_character_in_copy_mode): Do it.
+
+       * doc/groff.texi.in (Conditional Blocks, Warnings):
+       * man/groff.7.man (Conditional blocks):
+       * src/roff/troff/troff.1.man (Warnings): Document new warning
+       circumstance.
+
 2026-04-21  G. Branden Robinson <[email protected]>
 
        * src/roff/troff/input.cpp: Handle brace escape sequences
diff --git a/doc/groff.texi.in b/doc/groff.texi.in
index 114e9bb3b..ea82b13c4 100644
--- a/doc/groff.texi.in
+++ b/doc/groff.texi.in
@@ -16261,8 +16261,15 @@ These
 @dfn{conditional blocks}
 can furthermore be nested.
 
-Brace escape sequences outside of control structures have no meaning and
-produce no output.@c TODO: footnote: style warning
+Brace escape sequences outside of control structures have no meaning
+(but can be used as delimiters)
+and produce no output.@footnote{When its parser can tell
+that a brace escape sequence is useless,
+GNU
+@command{troff} @c GNU
+emits a warning in category
+@samp{style}.
+@xref{Warnings}.}
 
 @DefescList {\@\{, , , }
 @DefescListEnd {\@\}, , , }
@@ -22053,6 +22060,7 @@ ambiguous delimiters are accepted without warning.
 Input was non-idiomatic or likely to produce an unexpected result
 (or none at all),
 but is not invalid:
+a brace escape sequence was employed uselessly;
 the end of a sentence was detected prior to the end of a text line;
 or
 an attempt was made to combine temporary indentation
diff --git a/man/groff.7.man b/man/groff.7.man
index 45f1834f9..6762a96b1 100644
--- a/man/groff.7.man
+++ b/man/groff.7.man
@@ -2225,8 +2225,17 @@ These
 .I "conditional blocks"
 can furthermore be nested.
 .
-Brace escape sequences outside of control structures have no meaning and
-produce no output.\" TODO: footnote: style warning
+Brace escape sequences outside of control structures have no meaning
+(but can be used as delimiters)
+and produce no output.
+.
+When its parser can tell that
+a brace escape sequence is useless,
+GNU
+.I troff \" GNU
+emits a warning in category
+.RB \[lq] style \[rq].
+.
 .
 .
 .P
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 57a49b1f8..1ee1edf62 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -1346,11 +1346,13 @@ static int read_character_in_copy_mode(node **nd,
       (void) input_stack::get(0 /* nullptr */);
       if (is_defining_macro)
        return ESCAPE_LEFT_BRACE;
+      warning(WARN_STYLE, "left brace escape sequence is nilpotent");
       break;
     case '}':
       (void) input_stack::get(0 /* nullptr */);
       if (is_defining_macro)
        return ESCAPE_RIGHT_BRACE;
+      warning(WARN_STYLE, "right brace escape sequence is nilpotent");
       break;
     case '`':
       (void) input_stack::get(0 /* nullptr */);
diff --git a/src/roff/troff/troff.1.man b/src/roff/troff/troff.1.man
index 8e8cd4088..914dbb61e 100644
--- a/src/roff/troff/troff.1.man
+++ b/src/roff/troff/troff.1.man
@@ -853,6 +853,7 @@ style       16      T{
 Input was non-idiomatic or likely to produce an unexpected result
 (or none at all),
 but is not invalid:
+a brace escape sequence was employed uselessly;
 the end of a sentence was detected prior to the end of a text line;
 or
 an attempt was made to combine temporary indentation

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

Reply via email to