diff options
author | G. Branden Robinson <g.branden.robinson@gmail.com> | 2021-09-16 04:00:26 +1000 |
---|---|---|
committer | G. Branden Robinson <g.branden.robinson@gmail.com> | 2021-09-16 04:09:48 +1000 |
commit | 6e79a0e06401af9ec18162a65912df06a94c0cda (patch) | |
tree | 096eaf130c7a0665e8a7e1eb6465524a04407cc6 /src | |
parent | d0cfa32a4b0086ea26d09bf8babc37b0747222d0 (diff) | |
download | groff-git-6e79a0e06401af9ec18162a65912df06a94c0cda.tar.gz |
[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.
Diffstat (limited to 'src')
-rw-r--r-- | src/libs/libgroff/font.cpp | 4 | ||||
-rw-r--r-- | src/preproc/grn/main.cpp | 3 | ||||
-rw-r--r-- | src/roff/groff/groff.cpp | 6 | ||||
-rw-r--r-- | src/roff/troff/input.cpp | 3 |
4 files changed, 9 insertions, 7 deletions
diff --git a/src/libs/libgroff/font.cpp b/src/libs/libgroff/font.cpp index 861b04cbc..0c49ebb19 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 3a2e332a9..c4a57a49f 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 f83ab27c1..39c21e902 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 abe9bf013..6019dfea2 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; |