groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bizarre eqn diagnostic


From: G. Branden Robinson
Subject: Re: bizarre eqn diagnostic
Date: Mon, 26 Jun 2023 11:41:41 -0500

Hi Doug,

At 2023-06-26T12:11:12-0400, Douglas McIlroy wrote:
> Given this input, eqn says it sees an end of file while reading
> arguments of delim, but goes on to copy xxx to the output
>     .EQ
>     delim
>     .EN
>     xxx

Yes.  Thanks for the report.  This is an implementation detail leaking
into a diagnostic message.

GNU eqn internally uses EOF to indicate the end of what I term an "eqn
region" and other modules of its recursive-descent input parser to
itself.  Most of these already use the phrase "end of input" in
diagnostics rather than "end of file", but this one is an exception.

I have the following patch queued.  I would expect it to go into groff
1.23.1 and/or 1.24.0.

diff --git a/src/preproc/eqn/lex.cpp b/src/preproc/eqn/lex.cpp
index e38a486e3..831fa5c9a 100644
--- a/src/preproc/eqn/lex.cpp
+++ b/src/preproc/eqn/lex.cpp
@@ -1078,7 +1078,7 @@ void do_delim()
     c = get_char();
   int d;
   if (c == EOF || (d = get_char()) == EOF)
-    lex_error("end of file while reading argument to 'delim'");
+    lex_error("end of input while reading argument to 'delim'");
   else {
     if (c == 'o' && d == 'f' && peek_char() == 'f') {
       (void)get_char();

One use of "end of file" remains, but it appears to be correct.

$ grep -B3 -A1 "end of file" src/preproc/eqn/main.cpp
      for (;;) {
        if (!read_line(fp, &linebuf)) {
          current_lineno = 0; // suppress report of line number
          fatal("end of file before .EN");
        }

Regards,
Branden

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]