[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 18/19: [grn, groff, troff]: Improve fatal diagnostics.
From: |
G. Branden Robinson |
Subject: |
[groff] 18/19: [grn, groff, troff]: Improve fatal diagnostics. |
Date: |
Thu, 16 Sep 2021 08:59:05 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit 6e79a0e06401af9ec18162a65912df06a94c0cda
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Thu Sep 16 04:00:26 2021 +1000
[grn, groff, troff]: Improve fatal diagnostics.
[grn, groff, troff]: Communicate better when device DESC file can't be
loaded.
* src/libs/libgroff/font.cpp (font::load_desc): Stop writing diagnostic
to standard error.
* src/preproc/grn/main.cpp (getres):
* src/roff/troff/troff.cpp (main): Replace "sorry, I can't continue"
fatal diagnostic with a more informative message. Instead say
which device's DESC file the program was trying to open, which might
reveal a user's logic error or typo.
* src/roff/groff/groff.cpp (main): Replace "invalid device" text of
fatal diagnostic similarly. I think it is more helpful to indicate
the operation that failed rather than saying the device was invalid,
particularly since there are other ways for a device to be invalid
even if a DESC file is found and loaded.
---
ChangeLog | 18 ++++++++++++++++++
src/libs/libgroff/font.cpp | 4 +---
src/preproc/grn/main.cpp | 3 ++-
src/roff/groff/groff.cpp | 6 ++++--
src/roff/troff/input.cpp | 3 ++-
5 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f772d23..9eca83f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
2021-09-16 G. Branden Robinson <g.branden.robinson@gmail.com>
+ [grn, groff, troff]: Communicate better when device DESC file
+ can't be loaded.
+
+ * src/libs/libgroff/font.cpp (font::load_desc): Stop writing
+ diagnostic to standard error.
+ * src/preproc/grn/main.cpp (getres):
+ * src/roff/troff/troff.cpp (main): Replace "sorry, I can't
+ continue" fatal diagnostic with a more informative message.
+ Instead say which device's DESC file the program was trying to
+ open, which might reveal a user's logic error or typo.
+ * src/roff/groff/groff.cpp (main): Replace "invalid device" text
+ of fatal diagnostic similarly. I think it is more helpful to
+ indicate the operation that failed rather than saying the device
+ was invalid, particularly since there are other ways for a
+ device to be invalid even if a DESC file is found and loaded.
+
+2021-09-16 G. Branden Robinson <g.branden.robinson@gmail.com>
+
[troff]: Throw warning diagnostic if device DESC file attempts
to load unavailable fonts.
diff --git a/src/libs/libgroff/font.cpp b/src/libs/libgroff/font.cpp
index 861b04c..0c49ebb 100644
--- a/src/libs/libgroff/font.cpp
+++ b/src/libs/libgroff/font.cpp
@@ -1035,10 +1035,8 @@ bool font::load_desc()
int nfonts = 0;
FILE *fp;
char *path;
- if ((fp = open_file("DESC", &path)) == 0) {
- error("can't find 'DESC' file");
+ if ((fp = open_file("DESC", &path)) == 0)
return false;
- }
text_file t(fp, path);
t.skip_comments = 1;
res = 0;
diff --git a/src/preproc/grn/main.cpp b/src/preproc/grn/main.cpp
index 3a2e332..c4a57a4 100644
--- a/src/preproc/grn/main.cpp
+++ b/src/preproc/grn/main.cpp
@@ -429,7 +429,8 @@ getres()
int linepiece;
if (!font::load_desc())
- fatal("sorry, I can't continue");
+ fatal("cannot load 'DESC' description file for device '%1'",
+ device);
res = font::res;
diff --git a/src/roff/groff/groff.cpp b/src/roff/groff/groff.cpp
index f83ab27..39c21e9 100644
--- a/src/roff/groff/groff.cpp
+++ b/src/roff/groff/groff.cpp
@@ -345,9 +345,11 @@ int main(int argc, char **argv)
}
font::set_unknown_desc_command_handler(handle_unknown_desc_command);
if (!font::load_desc())
- fatal("invalid device '%1'", device);
+ fatal("cannot load 'DESC' description file for device '%1'",
+ device);
if (!postdriver)
- fatal("no 'postpro' command in DESC file for device '%1'", device);
+ fatal("no 'postpro' directive in 'DESC' file for device '%1'",
+ device);
if (predriver && !zflag) {
commands[TROFF_INDEX].insert_arg(commands[TROFF_INDEX].get_name());
commands[TROFF_INDEX].set_name(predriver);
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index abe9bf0..6019dfe 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -8127,7 +8127,8 @@ int main(int argc, char **argv)
init_charset_table();
init_hpf_code_table();
if (!font::load_desc())
- fatal("sorry, I can't continue");
+ fatal("cannot load 'DESC' description file for device '%1'",
+ device);
units_per_inch = font::res;
hresolution = font::hor;
vresolution = font::vert;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 18/19: [grn, groff, troff]: Improve fatal diagnostics.,
G. Branden Robinson <=