gbranden pushed a commit to branch master
in repository groff.

commit 1381d6a3471b88ec3d2a8aa601836531e0b3a9eb
Author: G. Branden Robinson <[email protected]>
AuthorDate: Fri Apr 5 09:17:14 2024 -0500

    src/roff/troff/input.cpp: Fix Savannah #45502.
    
    * src/roff/troff/input.cpp (skip_branch): Handle control flow branches
      consisting only of a newline correctly when skipping them--actually
      skip them, as AT&T troff does.  A newline after the `el` request, or
      after the conditional expression of an `if`, `ie`, or `while` request,
      is not "nothing"; if the branch is taken, it puts a newline on the
      output, and if it is not taken, it should neither affect output nor be
      _syntactically_ ignored on the pretense that the next input line was
      actually part of the branch.
    
    Fixes <https://savannah.gnu.org/bugs/?45502>.  Problem likely goes back
    to groff's origin.  (You could always avoid it with brace escape
    sequences, which might explain why it seemed to cause little
    consternation.)  Thanks to Carsten Kunze for the report and to Dave
    Kemper for the code review.
---
 ANNOUNCE                 |  1 +
 ChangeLog                | 18 ++++++++++++++++++
 src/roff/troff/input.cpp |  4 ++++
 3 files changed, 23 insertions(+)

diff --git a/ANNOUNCE b/ANNOUNCE
index 9a0d2845a..66f8ec2a6 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -162,6 +162,7 @@ Alexis ("no, the other one")
 Bjarni Ingi Gislason
 Brian Inglis
 Bruno Haible
+Carsten Kunze
 Colin Watson
 Damian McGuckin
 Dave Kemper
diff --git a/ChangeLog b/ChangeLog
index 9fbbd9e1c..c1d935544 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2024-04-05  G. Branden Robinson <[email protected]>
+
+       * src/roff/troff/input.cpp (skip_branch): Handle control flow
+       branches consisting only of a newline correctly when skipping
+       them--actually skip them, as AT&T troff does.  A newline after
+       the `el` request, or after the conditional expression of an
+       `if`, `ie`, or `while` request, is not "nothing"; if the branch
+       is taken, it puts a newline on the output, and if it is not
+       taken, it should neither affect output nor be _syntactically_
+       ignored on the pretense that the next input line was actually
+       part of the branch.
+
+       Fixes <https://savannah.gnu.org/bugs/?45502>.  Problem likely
+       goes back to groff's origin.  (You could always avoid it with
+       brace escape sequences, which might explain why it seemed to
+       cause little consternation.)  Thanks to Carsten Kunze for the
+       report and to Dave Kemper for the code review.
+
 2024-04-04  G. Branden Robinson <[email protected]>
 
        [troff]: Regression-test Savannah #45502.
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index cac51d1a6..5c53217fc 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -5880,6 +5880,10 @@ static void troff_request()
 
 static void skip_branch()
 {
+  if (tok.is_newline()) {
+    tok.next();
+    return;
+  }
   int level = 0;
   // ensure that ".if 0\{" works as expected
   if (tok.is_left_brace())

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

Reply via email to