groff-commit
[Top][All Lists]
Advanced

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

[groff] 08/23: [troff]: Fix Savannah #63011.


From: G. Branden Robinson
Subject: [groff] 08/23: [troff]: Fix Savannah #63011.
Date: Fri, 16 Sep 2022 13:07:41 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit 9c526ce2243f9326ec43d2220576cd48697e44de
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Tue Sep 13 08:12:56 2022 -0500

    [troff]: Fix Savannah #63011.
    
    Don't throw a spurious warning when using newline as delimiter with the
    few escape sequences that permit this.
    
    * src/roff/troff/input.cpp (do_overstrike, do_bracket, do_width)
    (do_special): Do it.
    
    Fixes <https://savannah.gnu.org/bugs/?63011>.  Thanks to Bjarni Ingi
    Gislason for the report and Dave Kemper for the discussion.
---
 ChangeLog                | 11 +++++++++++
 src/roff/troff/input.cpp | 50 +++++++++++++++++++++++++++++-------------------
 2 files changed, 41 insertions(+), 20 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index aba1c6863..0a6cdfb42 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2022-09-13  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       [troff]: Don't throw a spurious warning when using newline as
+       delimiter with the few escape sequences that permit this.
+
+       * src/roff/troff/input.cpp (do_overstrike, do_bracket, do_width)
+       (do_special): Do it.
+
+       Fixes <https://savannah.gnu.org/bugs/?63011>.  Thanks to Bjarni
+       Ingi Gislason for the report and Dave Kemper for the discussion.
+
 2022-09-13  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        [troff]: Add regression test for Savannah #63011.
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 36d49fbb5..a02ba568b 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -1439,9 +1439,14 @@ node *do_overstrike()
   start.next();
   for (;;) {
     tok.next();
-    if (tok.is_newline() || tok.is_eof()) {
+    if (tok.is_newline()) {
+      input_stack::push(make_temp_iterator("\n"));
+      break;
+    }
+    if (tok.is_eof()) {
       warning(WARN_DELIM, "missing closing delimiter in overstrike"
             " escape sequence (got %1)", tok.description());
+      // Pretend we saw a newline.
       input_stack::push(make_temp_iterator("\n"));
       break;
     }
@@ -1476,15 +1481,16 @@ static node *do_bracket()
   int start_level = input_stack::get_level();
   for (;;) {
     tok.next();
-    if (tok.is_eof() || tok.is_newline()) {
+    if (tok.is_newline()) {
+      input_stack::push(make_temp_iterator("\n"));
+      break;
+    }
+    if (tok.is_eof()) {
       warning(WARN_DELIM, "missing closing delimiter in"
              " bracket-building escape sequence (got %1)",
              tok.description());
-      // XXX: Most other places we miss a closing delimiter, we push a
-      // temp iterator for the EOF case too.  What's special about \b?
-      // Exceptions: \w, \X are like this too.
-      if (tok.is_newline())
-       input_stack::push(make_temp_iterator("\n"));
+      // Pretend we saw a newline.
+      input_stack::push(make_temp_iterator("\n"));
       break;
     }
     if (tok == start
@@ -5263,14 +5269,16 @@ static void do_width()
   curenv = &env;
   for (;;) {
     tok.next();
-    if (tok.is_eof() || tok.is_newline()) {
+    if (tok.is_newline()) {
+      input_stack::push(make_temp_iterator("\n"));
+      break;
+    }
+    if (tok.is_eof()) {
       warning(WARN_DELIM, "missing closing delimiter in"
-             " width computation escape sequence (got %1)", tok.description());
-      // XXX: Most other places we miss a closing delimiter, we push a
-      // temp iterator for the EOF case too.  What's special about \w?
-      // Exception: \b, \X are like this too.
-      if (tok.is_newline())
-       input_stack::push(make_temp_iterator("\n"));
+             " width computation escape sequence (got %1)",
+             tok.description());
+      // Pretend we saw a newline.
+      input_stack::push(make_temp_iterator("\n"));
       break;
     }
     if (tok == start
@@ -5475,17 +5483,19 @@ static node *do_special()
   start.next();
   int start_level = input_stack::get_level();
   macro mac;
+  // XXX: will tok != start ever be false?
   for (tok.next();
        tok != start || input_stack::get_level() != start_level;
        tok.next()) {
-    if (tok.is_eof() || tok.is_newline()) {
+    if (tok.is_newline()) {
+      input_stack::push(make_temp_iterator("\n"));
+      break;
+    }
+    if (tok.is_eof()) {
       warning(WARN_DELIM, "missing closing delimiter in device control"
              " escape sequence (got %1)", tok.description());
-      // XXX: Most other places we miss a closing delimiter, we push a
-      // temp iterator for the EOF case too.  What's special about \X?
-      // Exceptions: \b, \w are like this too.
-      if (tok.is_newline())
-       input_stack::push(make_temp_iterator("\n"));
+      // Pretend we saw a newline.
+      input_stack::push(make_temp_iterator("\n"));
       break;
     }
     unsigned char c;



reply via email to

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