groff-commit
[Top][All Lists]
Advanced

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

[groff] 05/30: [tbl]: Make diagnostic messages more helpful.


From: G. Branden Robinson
Subject: [groff] 05/30: [tbl]: Make diagnostic messages more helpful.
Date: Thu, 10 Oct 2024 20:18:10 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit 6d3986deac8a6e8d0bc70f612eedc7e184131b2e
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Wed Oct 9 11:15:38 2024 -0500

    [tbl]: Make diagnostic messages more helpful.
    
    * src/preproc/tbl/table.cpp (table::add_entry): Quote the contents of
      (ordinary) non-text-block table entries when throwing diagnostics
      about their contents.
---
 ChangeLog                 |  6 ++++++
 src/preproc/tbl/table.cpp | 36 +++++++++++++++++++++++++-----------
 2 files changed, 31 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ab995decb..93927035a 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): Quote the
+       contents of (ordinary) non-text-block table entries when
+       throwing diagnostics about their contents.
+
 2024-10-09  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * src/preproc/tbl/table.cpp (table::add_entry): Fix logic error
diff --git a/src/preproc/tbl/table.cpp b/src/preproc/tbl/table.cpp
index 83ffa7816..3ffbe3471 100644
--- a/src/preproc/tbl/table.cpp
+++ b/src/preproc/tbl/table.cpp
@@ -1535,8 +1535,9 @@ void table::add_entry(int r, int c, const string &str,
       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 '\\\"'");
+       warning_with_file_and_line(fn, ln, "comment escape sequence"
+                                  " '\\\"' in entry \"%1\"",
+                                  str.extract());
     }
     int gcommentpos = str.find("\\#");
     // If both types of comment are present, the first is what matters.
@@ -1547,21 +1548,34 @@ void table::add_entry(int r, int c, const string &str,
       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 '\\#'");
+       warning_with_file_and_line(fn, ln, "comment escape sequence"
+                                  " '\\#' in entry \"%1\"",
+                                  str.extract());
     }
     // A \! escape sequence after a comment has started is okay.
     int exclpos = str.find("\\!");
     if ((exclpos != -1)
        && ((-1 == commentpos)
-           || (exclpos < commentpos)))
-      warning_with_file_and_line(fn, ln, "table entry contains"
-                                " transparent throughput escape"
-                                " sequence '\\!'");
+           || (exclpos < commentpos))) {
+      if (-1 == str.search('\n')) // not a text block
+       warning_with_file_and_line(fn, ln, "transparent throughput"
+                                  " escape sequence '\\!' in entry"
+                                  " \"%1\"", str.extract());
+      else
+       warning_with_file_and_line(fn, ln, "transparent throughput"
+                                  " escape sequence '\\!' in text"
+                                  " block entry");
+    }
     // An incomplete \z sequence at the entry's end causes problems.
-    if (str.find("\\z") == (len - 2)) // max valid index is (len - 1)
-      error_with_file_and_line(fn, ln, "table entry ends with"
-                              " zero-motion escape sequence '\\z'");
+    if (str.find("\\z") == (len - 2)) { // max valid index is (len - 1)
+      if (-1 == str.search('\n')) // not a text block
+       error_with_file_and_line(fn, ln, "zero-motion escape sequence"
+                                " '\\z' at end of entry \"%1\"",
+                                str.extract());
+      else
+       error_with_file_and_line(fn, ln, "zero-motion escape sequence"
+                                " '\\z' at end of text block entry");
+    }
   }
   char *s = str.extract();
   if (str.search('\n') != -1) { // if it's a text block



reply via email to

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