[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 10/26: [refer]: Refactor diagnostic message reporting.
From: |
G. Branden Robinson |
Subject: |
[groff] 10/26: [refer]: Refactor diagnostic message reporting. |
Date: |
Sun, 15 May 2022 05:07:53 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit be87fd2c03f6fca0109db6ea9469c63db22b7f43
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Thu May 5 17:31:35 2022 -0500
[refer]: Refactor diagnostic message reporting.
* src/preproc/refer/command.cpp (process_commands): Begin migration to
use existing global variables for location reports in diagnostic
messages. Save current file name and line number before calling
`command_loop()` and restore them afterward. Also decrement line
counter before entering that loop because it would be too far advanced
by one due to the final newline on a parsed input line.
---
ChangeLog | 10 ++++++++++
src/preproc/refer/command.cpp | 7 +++++++
2 files changed, 17 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 4a5acce0..774456e0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2022-05-05 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ * src/preproc/refer/command.cpp (process_commands): Begin
+ migration to use existing global variables for location reports
+ in diagnostic messages. Save current file name and line number
+ before calling `command_loop()` and restore them afterward.
+ Also decrement line counter before entering that loop because it
+ would be too far advanced by one due to the final newline on a
+ parsed input line.
+
2022-05-05 G. Branden Robinson <g.branden.robinson@gmail.com>
* src/preproc/refer/refer.cpp (main): Report system error on
diff --git a/src/preproc/refer/command.cpp b/src/preproc/refer/command.cpp
index c7014b62..c2076d9b 100644
--- a/src/preproc/refer/command.cpp
+++ b/src/preproc/refer/command.cpp
@@ -795,9 +795,16 @@ static void command_loop()
void process_commands(string &s, const char *file, int lineno)
{
+ const char *saved_filename = current_filename;
+ int saved_lineno = current_lineno;
input_stack::init();
+ current_filename = file;
+ // Report diagnostics with respect to line _before_ last newline seen.
+ current_lineno = lineno - 1;
input_stack::push_string(s, file, lineno);
command_loop();
+ current_filename = saved_filename;
+ current_lineno = saved_lineno;
}
// Local Variables:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 10/26: [refer]: Refactor diagnostic message reporting.,
G. Branden Robinson <=