groff-commit
[Top][All Lists]
Advanced

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

[groff] 25/38: [troff]: Handle \[AbowXZ] escapes consistently.


From: G. Branden Robinson
Subject: [groff] 25/38: [troff]: Handle \[AbowXZ] escapes consistently.
Date: Mon, 3 Oct 2022 01:42:58 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit a7eda2790eadddd1cb5d2290bc6f246caebae6c5
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sat Oct 1 04:11:05 2022 -0500

    [troff]: Handle \[AbowXZ] escapes consistently.
    
    * src/roff/troff/input.cpp: Fix inconsistencies in handling of escape
      sequences that accept newlines as delimiters.  Some threw spurious
      warnings as in Savannah #63011; others failed to treat a
      newline-terminated escape sequence also as the ending of an input
      line.
    
      (do_name_test, do_zero_width): Suppress spurious warning.
    
      (do_zero_width, do_width, do_special): Synthesize newline to terminate
      input line.
---
 ChangeLog                | 11 +++++++++++
 src/roff/troff/input.cpp | 34 +++++++++++++++++-----------------
 2 files changed, 28 insertions(+), 17 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8cd883b1b..fc88fd8a8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2022-10-01  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * src/roff/troff/input.cpp: Fix inconsistencies in handling of
+       escape sequences that accept newlines as delimiters.  Some threw
+       spurious warnings as in Savannah #63011; others failed to treat
+       a newline-terminated escape sequence also as the ending of an
+       input line.
+       (do_name_test, do_zero_width): Suppress spurious warning.
+       (do_zero_width, do_width, do_special): Synthesize newline to
+       terminate input line.
+
 2022-10-01  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * src/roff/groff/tests/\
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 346b6a466..705befdd5 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -1516,9 +1516,10 @@ static int do_name_test()
   for (;;) {
     tok.next();
     if (tok.is_newline() || tok.is_eof()) {
-      warning(WARN_DELIM, "missing closing delimiter in identifier"
-             " validation escape sequence (got %1)",
-             tok.description());
+      if (tok != start)
+       warning(WARN_DELIM, "missing closing delimiter in identifier"
+               " validation escape sequence (got %1)",
+               tok.description());
       input_stack::push(make_temp_iterator("\n"));
       break;
     }
@@ -1612,8 +1613,9 @@ static node *do_zero_width()
   for (;;) {
     tok.next();
     if (tok.is_newline() || tok.is_eof()) {
-      warning(WARN_DELIM, "missing closing delimiter in"
-             " zero-width escape (got %1)", tok.description());
+      if (tok != start)
+       warning(WARN_DELIM, "missing closing delimiter in"
+               " zero-width escape (got %1)", tok.description());
       input_stack::push(make_temp_iterator("\n"));
       break;
     }
@@ -5273,14 +5275,11 @@ static void do_width()
   curenv = &env;
   for (;;) {
     tok.next();
-    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());
+    if (tok.is_newline() || tok.is_eof()) {
+      if (tok != start)
+       warning(WARN_DELIM, "missing closing delimiter in"
+               " width computation escape sequence (got %1)",
+               tok.description());
       // Pretend we saw a newline.
       input_stack::push(make_temp_iterator("\n"));
       break;
@@ -5487,10 +5486,8 @@ 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()) {
+  for (;;) {
+    tok.next();
     if (tok.is_newline()) {
       input_stack::push(make_temp_iterator("\n"));
       break;
@@ -5502,6 +5499,9 @@ static node *do_special()
       input_stack::push(make_temp_iterator("\n"));
       break;
     }
+    if (tok == start
+       && (compatible_flag || input_stack::get_level() == start_level))
+      break;
     unsigned char c;
     if (tok.is_space())
       c = ' ';



reply via email to

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