groff-commit
[Top][All Lists]
Advanced

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

[groff] 75/78: [troff]: Make error diagnostics more revealing.


From: G. Branden Robinson
Subject: [groff] 75/78: [troff]: Make error diagnostics more revealing.
Date: Fri, 7 Apr 2023 12:18:00 -0400 (EDT)

gbranden pushed a commit to branch branden-2023-04-07
in repository groff.

commit b3e61a1ce9acfe6b9db1fa54ff4d7b48976fa4b1
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sat Apr 1 18:59:44 2023 -0500

    [troff]: Make error diagnostics more revealing.
    
    * src/roff/troff/input.cpp (chop_macro, do_string_case_transform)
      (substring_request, asciify_macro, unformat_macro)
      (write_macro_request): When diagnosing impossible operations on
      request names, report the name of the request they were attempted
      upon.
    
    * src/roff/groff/tests/string_case_xform_errors.sh: Update test
      expectations.
---
 ChangeLog                                        | 10 ++++++++++
 src/roff/groff/tests/string_case_xform_errors.sh |  2 +-
 src/roff/troff/input.cpp                         | 20 ++++++++++----------
 3 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b40eb4648..afaf1b5cb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2023-04-01  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       * src/roff/troff/input.cpp (chop_macro)
+       (do_string_case_transform, substring_request, asciify_macro):
+       (unformat_macro, write_macro_request): When diagnosing
+       impossible operations on request names, report the name of the
+       request they were attempted upon.
+       * src/roff/groff/tests/string_case_xform_errors.sh: Update test
+       expectations.
+
 2023-04-01  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * src/roff/troff/input.cpp (alias_macro): Promote diagnostic
diff --git a/src/roff/groff/tests/string_case_xform_errors.sh 
b/src/roff/groff/tests/string_case_xform_errors.sh
index a16d763de..f108d6685 100755
--- a/src/roff/groff/tests/string_case_xform_errors.sh
+++ b/src/roff/groff/tests/string_case_xform_errors.sh
@@ -20,7 +20,7 @@
 
 groff="${abs_top_builddir:-.}/test-groff"
 
-expected="troff:<standard input>:1: error: cannot apply string case 
transformation to a request ('br')"
+expected="troff:<standard input>:1: error: cannot apply string case 
transformation to request 'br'"
 
 actual=$("$groff" -Tutf8 2>&1 <<EOF
 .stringdown br
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index baca587b4..44f422723 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -4718,13 +4718,13 @@ void chop_macro()
     request_or_macro *p = lookup_request(s);
     macro *m = p->to_macro();
     if (!m)
-      error("cannot chop request");
+      error("cannot chop request '%1'", s.contents());
     else if (m->empty())
-      error("cannot chop empty macro");
+      error("cannot chop empty object '%1'", s.contents());
     else {
       int have_restore = 0;
-      // we have to check for additional save/restore pairs which could be
-      // there due to empty am1 requests.
+      // We have to check for additional save/restore pairs which could
+      // be there due to empty am1 requests.
       for (;;) {
        if (m->get(m->len - 1) != POP_GROFFCOMP_MODE)
          break;
@@ -4739,7 +4739,7 @@ void chop_macro()
          break;
       }
       if (m->len == 0)
-       error("cannot chop empty macro");
+       error("cannot chop empty object '%1'", s.contents());
       else {
        if (have_restore)
          m->set(POP_GROFFCOMP_MODE, m->len - 1);
@@ -4765,7 +4765,7 @@ void do_string_case_transform(case_xform_mode mode)
   request_or_macro *p = lookup_request(s);
   macro *m = p->to_macro();
   if (!m) {
-    error("cannot apply string case transformation to a request ('%1')",
+    error("cannot apply string case transformation to request '%1'",
          s.contents());
     skip_line();
     return;
@@ -4810,7 +4810,7 @@ void substring_request()
     request_or_macro *p = lookup_request(s);
     macro *m = p->to_macro();
     if (!m)
-      error("cannot apply 'substring' on a request");
+      error("cannot extract substring of request '%1'", s.contents());
     else {
       int end = -1;
       if (!has_arg() || get_integer(&end)) {
@@ -4936,7 +4936,7 @@ void asciify_macro()
     request_or_macro *p = lookup_request(s);
     macro *m = p->to_macro();
     if (!m)
-      error("cannot asciify request");
+      error("cannot asciify request '%1'", s.contents());
     else {
       macro am;
       string_iterator iter(*m);
@@ -4963,7 +4963,7 @@ void unformat_macro()
     request_or_macro *p = lookup_request(s);
     macro *m = p->to_macro();
     if (!m)
-      error("cannot unformat request");
+      error("cannot unformat request '%1'", s.contents());
     else {
       macro am;
       string_iterator iter(*m);
@@ -6902,7 +6902,7 @@ void write_macro_request()
   request_or_macro *p = lookup_request(s);
   macro *m = p->to_macro();
   if (!m)
-    error("cannot write request");
+    error("cannot write request '%1' to a stream", s.contents());
   else {
     string_iterator iter(*m);
     for (;;) {



reply via email to

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