rse 98/03/04 04:08:49
Modified: src CHANGES src/main util.c . STATUS Log: The Line Contunuation feature (take 4): Same as the voted take 3 but I've replaced the *(cp-N) syntax with cp[-N] because most of us like this one more. Submitted by: Ralf S. Engelschall Reviewed by: Jim Jagielski, Dean Gaudet, Martin Kraemer, Dirk-Willem van Gulik, Ralf S. Engelschall Revision Changes Path 1.683 +7 -0 apache-1.3/src/CHANGES Index: CHANGES =================================================================== RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.682 retrieving revision 1.683 diff -u -r1.682 -r1.683 --- CHANGES 1998/03/04 10:58:06 1.682 +++ CHANGES 1998/03/04 12:08:45 1.683 @@ -1,5 +1,12 @@ Changes with Apache 1.3b6 + *) Now all configuration files support Unix-style line-continuation via + the trailing backslash ("\") character. This enables us to write down + complex or just very long directives in a more readable way. The + backslash character has to be really the last character before the + newline and it has not been prefixed by another (escaping) backslash. + [Ralf S. Engelschall] + *) When using ProxyPass the ?querystring was not passed correctly. [Joel Truher <[EMAIL PROTECTED]>] 1.97 +58 -3 apache-1.3/src/main/util.c Index: util.c =================================================================== RCS file: /export/home/cvs/apache-1.3/src/main/util.c,v retrieving revision 1.96 retrieving revision 1.97 diff -u -r1.96 -r1.97 --- util.c 1998/03/04 09:45:38 1.96 +++ util.c 1998/03/04 12:08:47 1.97 @@ -756,9 +756,49 @@ /* If a "get string" function is defined, use it */ if (cfp->getstr != NULL) { char *src, *dst; - ++cfp->line_number; - if (cfp->getstr(buf, bufsize, cfp->param) == NULL) - return 1; + char *cp; + char *cbuf = buf; + size_t cbufsize = bufsize; + + while (1) { + ++cfp->line_number; + if (cfp->getstr(cbuf, cbufsize, cfp->param) == NULL) + return 1; + + /* + * check for line continuation, + * i.e. match [^\\]\\[\r]\n only + */ + cp = cbuf; + while (cp < cbuf+cbufsize && *cp != '\0') + cp++; + if (cp > cbuf && cp[-1] == LF) { + cp--; + if (cp > cbuf && cp[-1] == CR) + cp--; + if (cp > cbuf && cp[-1] == '\\') { + cp--; + if (!(cp > cbuf && cp[-1] == '\\')) { + /* + * line continuation requested - + * then remove backslash and continue + */ + cbuf = cp; + cbufsize -= (cp-cbuf); + continue; + } + else { + /* + * no real continuation because escaped - + * then just remove escape character + */ + for ( ; cp < cbuf+cbufsize && *cp != '\0'; cp++) + cp[0] = cp[1]; + } + } + } + break; + } /* Compress the line, reducing all blanks and tabs to one space. * Leading and trailing white space is eliminated completely @@ -820,6 +860,21 @@ ++cfp->line_number; } if (c == EOF || c == 0x4 || c == LF || i >= (bufsize - 2)) { + /* + * check for line continuation + */ + if (i > 0 && buf[i-1] == '\\') { + i--; + if (!(i > 0 && buf[i-1] == '\\')) { + /* line is continued */ + c = cfp->getch(cfp->param); + continue; + } + /* else nothing needs be done because + * then the backslash is escaped and + * we just strip to a single one + */ + } /* blast trailing whitespace */ while (i > 0 && isspace(buf[i - 1])) --i; 1.173 +1 -10 apache-1.3/STATUS Index: STATUS =================================================================== RCS file: /export/home/cvs/apache-1.3/STATUS,v retrieving revision 1.172 retrieving revision 1.173 diff -u -r1.172 -r1.173 --- STATUS 1998/03/04 09:59:47 1.172 +++ STATUS 1998/03/04 12:08:48 1.173 @@ -65,18 +65,9 @@ * back out USE_PTHREAD_SERIALIZED_ACCEPT for solaris * Ken's abstraction of SERVER_{BUILT,VERSION} * Ken's fix for os/unix/os.h and the new -DHIDE functionality + * Ralf's Config File Line Continuation Available Patches: - - * Ralf's [PATCH] Config File Line Continuation (take 3) - <[EMAIL PROTECTED]> - (this version uses strict matching of the backslash, i.e. no trailing - spaces are allowed - this should be now avoid problems) - Status: Ralf +1 - Martin +1 (on concept) - Dean +1 (on concept, but -1? because of RAW_ARGS issues?) - Dirk-Willem van Gulik +1 - Jim +1 * M.D.Parker's [PATCH] mod_status/1448: Status Information have version <[EMAIL PROTECTED]>