]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Trigger whitespace removal via '"\EOL'
authorAlan T. DeKok <aland@freeradius.org>
Tue, 24 Jul 2012 13:44:32 +0000 (09:44 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 24 Jul 2012 13:44:32 +0000 (09:44 -0400)
foo = "\
bar \
baz"

 --> foo = "bar baz"

Makes dealing with long queries much easier.

src/main/conffile.c

index a3ba7739f826b791fb0a3c2d5610e930dcd37f08..07c0cefb635aa050dabe3b7ad7fe1f04f710c4f8 100644 (file)
@@ -1374,6 +1374,7 @@ static int cf_section_read(const char *filename, int *lineno, FILE *fp,
        char buf2[8192];
        char buf3[8192];
        int t1, t2, t3;
+       int spaces = FALSE;
        char *cbuf = buf;
        size_t len;
 
@@ -1405,6 +1406,16 @@ static int cf_section_read(const char *filename, int *lineno, FILE *fp,
                        return -1;
                }
 
+               if (spaces) {
+                       ptr = cbuf;
+                       while (isspace((int) *ptr)) ptr++;
+
+                       if (ptr > cbuf) {
+                               memmove(cbuf, ptr, len - (ptr - cbuf));
+                               len -= (ptr - cbuf);
+                       }
+               }
+
                /*
                 *      Not doing continuations: check for edge
                 *      conditions.
@@ -1433,12 +1444,20 @@ static int cf_section_read(const char *filename, int *lineno, FILE *fp,
                }
 
                if ((len > 0) && (cbuf[len - 1] == '\\')) {
+                       /*
+                        *      Check for "suppress spaces" magic.
+                        */
+                       if (!spaces && (len > 2) && (cbuf[len - 2] == '"')) {
+                               spaces = TRUE;
+                       }
+
                        cbuf[len - 1] = '\0';
                        cbuf += len - 1;
                        continue;
                }
 
                ptr = cbuf = buf;
+               spaces = FALSE;
 
                /*
                 *      The parser is getting to be evil.