[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 02/02: Reorganize backtrace output.
From: |
G. Branden Robinson |
Subject: |
[groff] 02/02: Reorganize backtrace output. |
Date: |
Fri, 10 Apr 2020 03:31:29 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit 29a796dedd1c6f5f95841f8a282b566b75f903c9
Author: G. Branden Robinson <address@hidden>
AuthorDate: Fri Apr 10 16:54:49 2020 +1000
Reorganize backtrace output.
* src/roff/troff/input.cpp (string_iterator::backtrace): Prefix the
output with the program name if it is known. In a deviation from the
GNU Coding Standards, put the string "backtrace:" immediately next
instead of the file and line number; this is because, particularly in
cases where the backtrace is most interesting or needed, it will
produce multiple lines of output and the common prefix aids visual
understanding.
(file_iterator::backtrace): As above; also, change prefix for popened
nodes in the iterator from "process" to "pipe". This seemed
preferable to omitting the information entirely or using an
inscrutable sigil like 'f' or 'p'. The advantage is that the output
is better aligned--better ergonomics for those who have to cope with a
lot of it. Furthermore, output the filename only once.
Example of old and new output:
/tmp/inner:2: backtrace: file '/tmp/inner'
echo .so /tmp/inner:1: backtrace: process 'echo .so /tmp/inner'
/tmp/outer:1: backtrace: file '/tmp/outer'
troff: backtrace: file '/tmp/inner':2
troff: backtrace: pipe 'echo .so /tmp/inner':1
troff: backtrace: file '/tmp/outer':1
---
ChangeLog | 30 ++++++++++++++++++++++++++++++
src/roff/troff/input.cpp | 11 ++++++++---
2 files changed, 38 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 2119c52..c6418f4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,35 @@
2020-04-10 G. Branden Robinson <address@hidden>
+ Reorganize backtrace output.
+
+ * src/roff/troff/input.cpp (string_iterator::backtrace):
+ Prefix the output with the program name if it is known. In a
+ deviation from the GNU Coding Standards, put the string
+ "backtrace:" immediately next instead of the file and line
+ number; this is because, particularly in cases where the
+ backtrace is most interesting or needed, it will produce
+ multiple lines of output and the common prefix aids visual
+ understanding.
+ (file_iterator::backtrace): As above; also, change prefix for
+ popened nodes in the iterator from "process" to "pipe". This
+ seemed preferable to omitting the information entirely or using
+ an inscrutable sigil like 'f' or 'p'. The advantage is that the
+ output is better aligned--better ergonomics for those who have
+ to cope with a lot of it. Furthermore, output the filename only
+ once.
+
+ Example of old and new output:
+
+ /tmp/inner:2: backtrace: file '/tmp/inner'
+ echo .so /tmp/inner:1: backtrace: process 'echo .so /tmp/inner'
+ /tmp/outer:1: backtrace: file '/tmp/outer'
+
+ troff: backtrace: file '/tmp/inner':2
+ troff: backtrace: pipe 'echo .so /tmp/inner':1
+ troff: backtrace: file '/tmp/outer':1
+
+2020-04-10 G. Branden Robinson <address@hidden>
+
* src/roff/troff/input.cpp (read_size): Add units to diagnostic.
This function works only with device-specific basic units
internally; users likely think in terms of point size, so add
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 43fc9e5..5d2ceb6 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -401,8 +401,10 @@ int file_iterator::get_location(int /*allow_macro*/,
void file_iterator::backtrace()
{
- errprint("%1:%2: backtrace: %3 '%1'\n", filename, lineno,
- popened ? "process" : "file");
+ if (program_name)
+ fprintf(stderr, "%s: ", program_name);
+ errprint("backtrace: %3 '%1':%2\n", filename, lineno,
+ popened ? "pipe" : "file");
}
int file_iterator::set_location(const char *f, int ln)
@@ -3570,8 +3572,11 @@ int string_iterator::get_location(int allow_macro,
void string_iterator::backtrace()
{
+ if (program_name)
+ fprintf(stderr, "%s: ", program_name);
if (mac.filename) {
- errprint("%1:%2: backtrace", mac.filename, mac.lineno + lineno - 1);
+ errprint("backtrace: '%1':%2", mac.filename,
+ mac.lineno + lineno - 1);
if (how_invoked) {
if (!nm.is_null())
errprint(": %1 '%2'\n", how_invoked, nm.contents());
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 02/02: Reorganize backtrace output.,
G. Branden Robinson <=