src/server/config/serverconfig.c

changeset 459
f21b4ff81c01
parent 455
e52a9fc670d2
child 464
0a29110b94ec
--- a/src/server/config/serverconfig.c	Sat Feb 25 21:12:51 2023 +0100
+++ b/src/server/config/serverconfig.c	Fri Mar 10 22:45:58 2023 +0100
@@ -48,6 +48,7 @@
     ConfigParser2 parser;
     memset(&parser, 0, sizeof(ConfigParser2));
     parser.mp = mp;
+    parser.filename = file;
     parser.allow_hierarchy = true;
     parser.delim = "";
     ConfigNode *root = serverconfig_load_file(&parser, file);
@@ -126,12 +127,21 @@
         if(c == '\n') {
             if(quote) {
                 *pos = i;
+                log_ereport(
+                        LOG_FAILURE,
+                        "cfgparser: file %s:%d:%d: error: %s",
+                        parser->filename,
+                        parser->linenum,
+                        parser->linepos+2,
+                        "missing '\"' character before end of line");
                 return token; // error
             } else if(start == i) {
                 // single newline char token
                 type = CFG_TOKEN_NEWLINE;
                 token_begin = i;
                 token_end = i+1;
+                parser->linenum++;
+                parser->linepos = 0;
                 break;
             }
             
@@ -179,12 +189,14 @@
             token_begin = i;
         }
         prev = c;
+        
+        parser->linepos++;
     }
     
     *pos = i + 1;
     
     if(token_begin < 0) {
-        return token; // error
+        return token; // error or EOF
     }
     
     token.type = type;
@@ -249,6 +261,9 @@
     CxMempool *mp = parser->mp;
     CxAllocator *a = (CxAllocator*)mp->allocator;
     
+    parser->linenum = 1;
+    parser->linepos = 1;
+    
     if(!parser->delim) {
         parser->delim = "";
     }

mercurial