[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 10/35: [groff]: Add information to diagnostic messages.
From: |
G. Branden Robinson |
Subject: |
[groff] 10/35: [groff]: Add information to diagnostic messages. |
Date: |
Tue, 21 Jun 2022 14:26:28 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit 64dc40d23addb7c8f395140dff1f49329bfed8e1
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sun Jun 19 03:24:43 2022 -0500
[groff]: Add information to diagnostic messages.
* src/roff/groff/groff.cpp (main): Report underlying system error if
`putenv()` fails.
(handle_unknown_desc_command): Set globals `current_filename` and
`current_lineno` from `filename` and `lineno` arguments passed to us
to we can use the simpler interface of `error()` rather than
`error_with_file_and_line()`.
Also wrap long lines.
---
ChangeLog | 11 +++++++++++
src/roff/groff/groff.cpp | 33 ++++++++++++++++-----------------
2 files changed, 27 insertions(+), 17 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 684de007..352b614e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2022-06-19 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ [groff]: Add information to diagnostic messages.
+
+ * src/roff/groff/groff.cpp (main): Report underlying system
+ error if `putenv()` fails.
+ (handle_unknown_desc_command): Set globals `current_filename`
+ and `current_lineno` from `filename` and `lineno` arguments
+ passed to us to we can use the simpler interface of `error()`
+ rather than `error_with_file_and_line()`.
+
2022-06-19 G. Branden Robinson <g.branden.robinson@gmail.com>
[libgroff]: Update return type of `font::load_desc` function to
diff --git a/src/roff/groff/groff.cpp b/src/roff/groff/groff.cpp
index 95180f9e..6312c642 100644
--- a/src/roff/groff/groff.cpp
+++ b/src/roff/groff/groff.cpp
@@ -48,7 +48,8 @@ extern "C" {
}
#endif /* NEED_DECLARATION_PUTENV */
-// The number of commands must be in sync with MAX_COMMANDS in pipeline.h
+// The number of commands must be in sync with MAX_COMMANDS in
+// pipeline.h.
// grap, chem, and ideal must come before pic;
// tbl must come before eqn
@@ -140,7 +141,8 @@ int main(int argc, char **argv)
};
while ((opt = getopt_long(
argc, argv,
- "abcCd:D:eEf:F:gGhiI:jJkK:lL:m:M:n:No:pP:r:RsStT:UvVw:W:XzZ",
+ "abcCd:D:eEf:F:gGhiI:jJkK:lL:m:M:"
+ "n:No:pP:r:RsStT:UvVw:W:XzZ",
long_options, NULL))
!= EOF) {
char buf[3];
@@ -464,7 +466,7 @@ int main(int argc, char **argv)
}
e += '\0';
if (putenv(strsave(e.contents())))
- fatal("putenv failed");
+ fatal("putenv failed: %1", strerror(errno));
}
{
// we save the original path in GROFF_PATH__ and put it into the
@@ -476,7 +478,7 @@ int main(int argc, char **argv)
e += path;
e += '\0';
if (putenv(strsave(e.contents())))
- fatal("putenv failed");
+ fatal("putenv failed: %1", strerror(errno));
char *binpath = getenv("GROFF_BIN_PATH");
string f = "PATH";
f += '=';
@@ -492,7 +494,7 @@ int main(int argc, char **argv)
}
f += '\0';
if (putenv(strsave(f.contents())))
- fatal("putenv failed");
+ fatal("putenv failed: %1", strerror(errno));
}
if (Vflag)
print_commands(Vflag == 1 ? stdout : stderr);
@@ -524,23 +526,22 @@ const char *xbasename(const char *s)
void handle_unknown_desc_command(const char *command, const char *arg,
const char *filename, int lineno)
{
+ current_filename = filename;
+ current_lineno = lineno;
if (strcmp(command, "print") == 0) {
if (arg == 0 /* nullptr */)
- error_with_file_and_line(filename, lineno,
- "'print' command requires an argument");
+ error("'print' directive requires an argument");
else
spooler = strsave(arg);
}
if (strcmp(command, "prepro") == 0) {
if (arg == 0 /* nullptr */)
- error_with_file_and_line(filename, lineno,
- "'prepro' command requires an argument");
+ error("'prepro' directive requires an argument");
else {
for (const char *p = arg; *p; p++)
if (csspace(*p)) {
- error_with_file_and_line(filename, lineno,
- "invalid 'prepro' argument '%1'"
- ": program name required", arg);
+ error("invalid 'prepro' directive argument '%1':"
+ " program name required", arg);
return;
}
predriver = strsave(arg);
@@ -548,14 +549,12 @@ void handle_unknown_desc_command(const char *command,
const char *arg,
}
if (strcmp(command, "postpro") == 0) {
if (arg == 0 /* nullptr */)
- error_with_file_and_line(filename, lineno,
- "'postpro' command requires an argument");
+ error("'postpro' directive requires an argument");
else {
for (const char *p = arg; *p; p++)
if (csspace(*p)) {
- error_with_file_and_line(filename, lineno,
- "invalid 'postpro' argument '%1'"
- ": program name required", arg);
+ error("invalid 'postpro' directive argument '%1':"
+ " program name required", arg);
return;
}
postdriver = strsave(arg);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 10/35: [groff]: Add information to diagnostic messages.,
G. Branden Robinson <=