gbranden pushed a commit to branch branden-2023-07-05 in repository groff. commit e86d670914fc0ed590bb1dcc2b755dd92a3fe510 Author: G. Branden Robinson <g.branden.robin...@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 9b78dd491..bead82dad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2023-04-01 G. Branden Robinson <g.branden.robin...@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.robin...@gmail.com> [troff]: Make futile aliasing an error. 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 (;;) { _______________________________________________ Groff-commit mailing list Groff-commit@gnu.org https://lists.gnu.org/mailman/listinfo/groff-commit