[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 31/33: [eqn]: Improve diagnostics.
From: |
G. Branden Robinson |
Subject: |
[groff] 31/33: [eqn]: Improve diagnostics. |
Date: |
Sun, 16 Oct 2022 15:52:21 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit 99423da86366ec3d7f9b49a3c60c584ea179af8a
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sat Oct 15 10:28:37 2022 -0500
[eqn]: Improve diagnostics.
* src/preproc/eqn/lex.cpp (file_input::~file_input):
* src/preproc/eqn/main.cpp (main): Die if `fclose()` fails and report
underlying system error.
(inline_equation): Identify inline equation context.
---
ChangeLog | 9 +++++++++
src/preproc/eqn/lex.cpp | 3 ++-
src/preproc/eqn/main.cpp | 11 +++++++----
3 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 600864aff..bcb0e53d2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2022-10-14 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ [eqn]: Improve diagnostics.
+
+ * src/preproc/eqn/lex.cpp (file_input::~file_input):
+ * src/preproc/eqn/main.cpp (main): Die if `fclose()` fails and
+ report underlying system error.
+ (inline_equation): Identify inline equation context.
+
2022-10-15 G. Branden Robinson <g.branden.robinson@gmail.com>
* tmac/e.tmac (2c, 1c): Throw diagnostic if changing columnation
diff --git a/src/preproc/eqn/lex.cpp b/src/preproc/eqn/lex.cpp
index 72de7f9fe..2770b69e0 100644
--- a/src/preproc/eqn/lex.cpp
+++ b/src/preproc/eqn/lex.cpp
@@ -401,8 +401,9 @@ file_input::file_input(FILE *f, const char *fn, input *p)
file_input::~file_input()
{
+ if (fclose(fp) < 0)
+ fatal("unable to close '%1': %2", filename, strerror(errno));
delete[] filename;
- fclose(fp);
}
int file_input::read_line()
diff --git a/src/preproc/eqn/main.cpp b/src/preproc/eqn/main.cpp
index 4ba894ddf..95023f5af 100644
--- a/src/preproc/eqn/main.cpp
+++ b/src/preproc/eqn/main.cpp
@@ -151,7 +151,8 @@ static int inline_equation(FILE *fp, string &linebuf,
string &str)
inline_flag = 1;
for (;;) {
if (no_newline_in_delim_flag && strchr(start + 1, end_delim) == 0) {
- error("missing '%1'", end_delim);
+ error("unterminated inline equation; started with '%1',"
+ " expecting '%2'", start_delim, end_delim);
char *nl = strchr(start + 1, '\n');
if (nl != 0)
*nl = '\0';
@@ -173,8 +174,8 @@ static int inline_equation(FILE *fp, string &linebuf,
string &str)
}
str += ptr;
if (!read_line(fp, &linebuf))
- fatal("unterminated '%1' at line %2, looking for '%3'",
- start_delim, start_lineno, end_delim);
+ fatal("unterminated inline equation; started with '%1',"
+ " expecting '%2'", start_delim, end_delim);
linebuf += '\0';
ptr = &linebuf[0];
}
@@ -402,7 +403,9 @@ int main(int argc, char **argv)
FILE *fp = config_macro_path.open_file(STARTUP_FILE, &path);
if (fp) {
do_file(fp, path);
- fclose(fp);
+ if (fclose(fp) < 0)
+ fatal("unable to close '%1': %2", STARTUP_FILE,
+ strerror(errno));
free(path);
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 31/33: [eqn]: Improve diagnostics.,
G. Branden Robinson <=