groff-commit
[Top][All Lists]
Advanced

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

[groff] 04/30: [tbl]: Fix logic error in new diagnostic.


From: G. Branden Robinson
Subject: [groff] 04/30: [tbl]: Fix logic error in new diagnostic.
Date: Thu, 10 Oct 2024 20:18:09 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit de98fc96e1505aabb2f23a1369c755a8f36dce37
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Wed Oct 9 11:14:55 2024 -0500

    [tbl]: Fix logic error in new diagnostic.
    
    * src/preproc/tbl/table.cpp (table::add_entry): Fix logic error in *roff
      escape sequence detection, exposed by UTP document
      <https://github.com/larrykollar/Unix-Text-Processing/tree/1.0>.
---
 ChangeLog                 |  6 ++++++
 src/preproc/tbl/table.cpp | 12 ++++++------
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8fdf61e74..ab995decb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-10-09  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * src/preproc/tbl/table.cpp (table::add_entry): Fix logic error
+       in *roff escape sequence detection, exposed by UTP document
+       <https://github.com/larrykollar/Unix-Text-Processing/tree/1.0>.
+
 2024-10-11  Deri James  <deri@chuzzlewit.myzen.co.uk>
 
        * src/devices/gropdf/gropdf.pl: When switching writing
diff --git a/src/preproc/tbl/table.cpp b/src/preproc/tbl/table.cpp
index 3c4bd5a85..83ffa7816 100644
--- a/src/preproc/tbl/table.cpp
+++ b/src/preproc/tbl/table.cpp
@@ -1532,9 +1532,9 @@ void table::add_entry(int r, int c, const string &str,
     int commentpos = str.find("\\\"");
     if (commentpos != -1) {
       int controlpos = str.search('.');
-      if ((-1 == controlpos)
-         || (0 == controlpos)
-         || (-1 == str.search('\n')))
+      if ((-1 == str.search('\n')) // not a text block, AND
+         && ((-1 == controlpos) // (no control character in line OR
+             || (0 == controlpos))) // control character at line start)
        warning_with_file_and_line(fn, ln, "table entry contains"
                                   " comment escape sequence '\\\"'");
     }
@@ -1544,9 +1544,9 @@ void table::add_entry(int r, int c, const string &str,
       commentpos = gcommentpos;
     if (commentpos != -1) {
       int controlpos = str.search('.');
-      if ((-1 == controlpos)
-         || (0 == controlpos)
-         || (-1 == str.search('\n')))
+      if ((-1 == str.search('\n')) // not a text block, AND
+         && ((-1 == controlpos) // (no control character in line OR
+             || (0 == controlpos))) // control character at line start)
        warning_with_file_and_line(fn, ln, "table entry contains"
                                   " comment escape sequence '\\#'");
     }



reply via email to

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