summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorG. Branden Robinson <g.branden.robinson@gmail.com>2023-04-30 06:06:51 -0500
committerG. Branden Robinson <g.branden.robinson@gmail.com>2023-05-06 20:25:28 -0500
commit6de5791ea8dc6213e28d99fc8074abe30777854b (patch)
tree8af7e7d0818c4e2b2aed445f3dc8d407702b6f54
parent5401e89372a48d40d1bc68ca06688b3c6ebddb4a (diff)
downloadgroff-git-6de5791ea8dc6213e28d99fc8074abe30777854b.tar.gz
[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>.
-rw-r--r--ChangeLog17
-rw-r--r--src/preproc/eqn/main.cpp14
2 files changed, 25 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index fa1081442..e7c1ac245 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,22 @@
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.
* src/preproc/eqn/tests/\
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;