From: Alan T. DeKok Date: Tue, 24 Jul 2012 13:44:32 +0000 (-0400) Subject: Trigger whitespace removal via '"\EOL' X-Git-Tag: release_3_0_0_beta0~114 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d39af36e564493a9f9c75fb9b461012dac054099;p=thirdparty%2Ffreeradius-server.git Trigger whitespace removal via '"\EOL' foo = "\ bar \ baz" --> foo = "bar baz" Makes dealing with long queries much easier. --- diff --git a/src/main/conffile.c b/src/main/conffile.c index a3ba7739f82..07c0cefb635 100644 --- a/src/main/conffile.c +++ b/src/main/conffile.c @@ -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.