[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 09/15: [libgroff]: Make error reporting more flexible.
From: |
G. Branden Robinson |
Subject: |
[groff] 09/15: [libgroff]: Make error reporting more flexible. |
Date: |
Fri, 17 Sep 2021 05:34:38 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit cd0457b6265f5a12f6ba50d4e7f8ff7be3b2bd80
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Fri Sep 17 15:38:22 2021 +1000
[libgroff]: Make error reporting more flexible.
* src/libs/libgroff/error.cpp (do_error_with_file_and_line): Interpret a
line number of zero specially: treat the diagnostic as applying to the
entire file, and omit the line number.
---
ChangeLog | 8 ++++++++
src/libs/libgroff/error.cpp | 21 ++++++++++++++-------
2 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index bd50be3..873eac9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2021-09-17 G. Branden Robinson <g.branden.robinson@gmail.com>
+ [libgroff]: Make error reporting more flexible.
+
+ * src/libs/libgroff/error.cpp (do_error_with_file_and_line):
+ Interpret a line number of zero specially: treat the diagnostic
+ as applying to the entire file, and omit the line number.
+
+2021-09-17 G. Branden Robinson <g.branden.robinson@gmail.com>
+
[libgroff]: Add information to diagnostics.
* src/libs/libgroff/font.cpp (font::load): Drop unused argument
diff --git a/src/libs/libgroff/error.cpp b/src/libs/libgroff/error.cpp
index 1a54589..a06239a 100644
--- a/src/libs/libgroff/error.cpp
+++ b/src/libs/libgroff/error.cpp
@@ -1,4 +1,3 @@
-// -*- C++ -*-
/* Copyright (C) 1989-2020 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
@@ -34,8 +33,8 @@ enum error_type { DEBUG, WARNING, ERROR, FATAL };
static void do_error_with_file_and_line(const char *filename,
const char *source_filename,
int lineno,
- error_type type,
- const char *format,
+ error_type type,
+ const char *format,
const errarg &arg1,
const errarg &arg2,
const errarg &arg3)
@@ -45,13 +44,15 @@ static void do_error_with_file_and_line(const char
*filename,
fprintf(stderr, "%s:", program_name);
need_space = true;
}
- if (lineno >= 0 && filename != 0) {
+ if (filename != 0) {
if (strcmp(filename, "-") == 0)
filename = "<standard input>";
+ fprintf(stderr, "%s", filename);
if (source_filename != 0)
- fprintf(stderr, "%s (%s):%d:", filename, source_filename, lineno);
- else
- fprintf(stderr, "%s:%d:", filename, lineno);
+ fprintf(stderr, ":(%s)", source_filename);
+ if (lineno > 0)
+ fprintf(stderr, ":%d", lineno);
+ fputc(':', stderr);
need_space = true;
}
if (need_space)
@@ -163,3 +164,9 @@ void fatal_with_file_and_line(const char *filename,
do_error_with_file_and_line(filename, 0, lineno,
FATAL, format, arg1, arg2, arg3);
}
+
+// Local Variables:
+// fill-column: 72
+// mode: C++
+// End:
+// vim: set cindent noexpandtab shiftwidth=2 textwidth=72:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 09/15: [libgroff]: Make error reporting more flexible.,
G. Branden Robinson <=