[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 79/83: [eqn]: Fix Savannah #64105.
From: |
G. Branden Robinson |
Subject: |
[groff] 79/83: [eqn]: Fix Savannah #64105. |
Date: |
Sat, 6 May 2023 23:24:24 -0400 (EDT) |
gbranden pushed a commit to branch branden-2023-05-06
in repository groff.
commit 6de5791ea8dc6213e28d99fc8074abe30777854b
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Sun Apr 30 06:06:51 2023 -0500
[eqn]: Fix Savannah #64105.
* src/preproc/eqn/main.cpp (do_file): Increment the line number if a
malformed `lf` request was encountered, instead of decrementing it if
a valid one was. Increment it when processing an end eqn macro call
(".EN"), not just a start one. Drop an incrementation of the line
number that applied too generally.
This ensures we don't throw the line numbers off in normal input
processing. Fixes a problem introduced by me in commit dc98a8b09e, 31
October.
Fixes <https://savannah.gnu.org/bugs/?64105>.
---
ChangeLog | 17 +++++++++++++++++
src/preproc/eqn/main.cpp | 14 ++++++++------
2 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index fa1081442..e7c1ac245 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2023-04-30 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ [eqn]: Fix Savannah #64105.
+
+ * src/preproc/eqn/main.cpp (do_file): Increment the line number
+ if a malformed `lf` request was encountered, instead of
+ decrementing it if a valid one was. Increment it when
+ processing an end eqn macro call (".EN"), not just a start one.
+ Drop an incrementation of the line number that applied too
+ generally.
+
+ This ensures we don't throw the line numbers off in normal input
+ processing. Fixes a problem introduced by me in commit
+ dc98a8b09e, 31 October.
+
+ Fixes <https://savannah.gnu.org/bugs/?64105>.
+
2023-04-30 G. Branden Robinson <g.branden.robinson@gmail.com>
[eqn]: Improve tests of line number accuracy.
diff --git a/src/preproc/eqn/main.cpp b/src/preproc/eqn/main.cpp
index 324e2b4fb..f2678c2fa 100644
--- a/src/preproc/eqn/main.cpp
+++ b/src/preproc/eqn/main.cpp
@@ -109,9 +109,10 @@ void do_file(FILE *fp, const char *filename)
{
put_string(linebuf, stdout);
linebuf += '\0';
- // In GNU roff, `lf` assigns the number of the _next_ line.
- if (interpret_lf_args(linebuf.contents() + 3))
- current_lineno--;
+ // In GNU roff, `lf` assigns the number of the _next_ line. If it
+ // is malformed, it is nevertheless an input line.
+ if (!(interpret_lf_args(linebuf.contents() + 3)))
+ current_lineno++;
}
else if (linebuf.length() >= 4
&& linebuf[0] == '.'
@@ -132,12 +133,14 @@ void do_file(FILE *fp, const char *filename)
&& linebuf[1] == 'E') {
if (linebuf[2] == 'N'
&& (linebuf.length() == 3 || linebuf[3] == ' '
- || linebuf[3] == '\n' || compatible_flag))
+ || linebuf[3] == '\n' || compatible_flag)) {
+ current_lineno++;
break;
+ }
else if (linebuf[2] == 'Q' && linebuf.length() > 3
&& (linebuf[3] == ' ' || linebuf[3] == '\n'
|| compatible_flag)) {
- current_lineno++; // We just read another line.
+ current_lineno++;
fatal("equations cannot be nested (.EQ within .EQ)");
}
}
@@ -170,7 +173,6 @@ void do_file(FILE *fp, const char *filename)
;
else
put_string(linebuf, stdout);
- current_lineno++;
}
current_filename = 0;
current_lineno = 0;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 79/83: [eqn]: Fix Savannah #64105.,
G. Branden Robinson <=