]> git.armaanb.net Git - opendoas.git/commitdiff
espie reminds me that EOF can happen for errors as well, so check for that
authortedu <tedu>
Fri, 4 Dec 2015 09:41:49 +0000 (09:41 +0000)
committerDuncan Overbruck <mail@duncano.de>
Thu, 28 Jan 2021 19:40:51 +0000 (20:40 +0100)
happening and print a message.

parse.y

diff --git a/parse.y b/parse.y
index 85e20cc81b9504686b1446f26ac19f313484e6a1..388c2a57f988a3b4e550f8332f08c3228968be13 100644 (file)
--- a/parse.y
+++ b/parse.y
@@ -251,12 +251,12 @@ repeat:
                        /* skip comments; NUL is allowed; no continuation */
                        while ((c = getc(yyfp)) != '\n')
                                if (c == EOF)
-                                       return 0;
+                                       goto eof;
                        yylval.colno = 0;
                        yylval.lineno++;
                        return c;
                case EOF:
-                       return 0;
+                       goto eof;
        }
 
        /* parsing next word */
@@ -330,7 +330,7 @@ eow:
                 * the main loop.
                 */
                if (c == EOF)
-                       return 0;
+                       goto eof;
                else if (qpos == -1)    /* accept, e.g., empty args: cmd foo args "" */
                        goto repeat;
        }
@@ -344,4 +344,9 @@ eow:
                err(1, "%s", __func__);
        yylval.str = str;
        return TSTRING;
+
+eof:
+       if (ferror(yyfp))
+               yyerror("input error reading config");
+       return 0;
 }