Fix line count error reporting in config files, like pg_hba.conf, per
authorBruce Momjian <[email protected]>
Wed, 11 Dec 2002 22:17:31 +0000 (22:17 +0000)
committerBruce Momjian <[email protected]>
Wed, 11 Dec 2002 22:17:31 +0000 (22:17 +0000)
report from Oliver Elphick.

Backpatch to 7.3.

src/backend/libpq/hba.c

index 2f9664cfd1867305ed37216694ce33ec2014875d..76e3d9a62caf04dbcabd6f02c0eabc69b475f4da 100644 (file)
@@ -93,6 +93,7 @@ void
 next_token(FILE *fp, char *buf, const int bufsz)
 {
        int                     c;
+       char       *start_buf = buf;
        char       *end_buf = buf + (bufsz - 1);
        bool            in_quote = false;
        bool            was_quote = false;
@@ -115,7 +116,10 @@ next_token(FILE *fp, char *buf, const int bufsz)
                        {
                                while ((c = getc(fp)) != EOF && c != '\n')
                                        ;
-                               continue;
+                               /* If only comment, consume EOL too; return EOL */
+                               if (c != EOF && buf == start_buf)
+                                       c = getc(fp);
+                               break;
                        }
 
                        if (buf >= end_buf)