Return-Path: Delivered-To: new-httpd-archive@hyperreal.org Received: (qmail 13937 invoked by uid 6000); 28 Feb 1998 16:03:58 -0000 Received: (qmail 13930 invoked from network); 28 Feb 1998 16:03:56 -0000 Received: from slarti.muc.de (193.174.4.10) by taz.hyperreal.org with SMTP; 28 Feb 1998 16:03:56 -0000 Received: (qmail 25399 invoked by uid 66); 28 Feb 1998 16:03:28 -0000 Received: by en1.engelschall.com (Sendmail 8.8.8) for new-httpd@apache.org id RAA02379; Sat, 28 Feb 1998 17:01:02 +0100 (MET) Message-Id: <199802281601.RAA02379@en1.engelschall.com> Subject: [PATCH] Config File Line Continuation (take 2) To: new-httpd@apache.org (Apache Developer ML) Date: Sat, 28 Feb 1998 17:01:01 +0100 (MET) From: rse@engelschall.com (Ralf S. Engelschall) Organization: Engelschall, Germany. X-Home: http://www.engelschall.com/ X-Mailer: ELM [version 2.4ME+ PL39 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: new-httpd-owner@apache.org Precedence: bulk Reply-To: new-httpd@apache.org Config File Line Continuation ----------------------------- Exactly one year ago someone posted a simple hack for line-contnuation. Some of us said "+1 on idea but -1 on patch". Then the idea was forgotten. Whenever I wrote down long CustomLog or RewriteXXX directives I felt sick because of we still had no such feature. So, because I'm still thinking a real man's config should provide line-continuation and because currently I've time and power to create new stuff, I've given the idea a second chance and now provide a patch which should do it more carefully and completely. It patches the cfg_getline() function in src/main/util.c for both cases: when a getstr function exists and when no such function exists. We use strict matching here, i.e. we don't allow trailing whitespaces after the backslash (the backslash has to be followed directly by a LF or CR+LF combination). Ralf S. Engelschall rse@engelschall.com www.engelschall.com Index: CHANGES =================================================================== RCS file: /e/apache/REPOS/apache-1.3/src/CHANGES,v retrieving revision 1.673 diff -u -r1.673 CHANGES --- CHANGES 1998/02/28 15:39:25 1.673 +++ CHANGES 1998/02/28 15:41:45 @@ -1,5 +1,10 @@ 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. + [Ralf S. Engelschall] + *) Add `Rule HIDE' to Configuration to hide the Apache symbol namespace from conflicting with third-party libraries some modules force to be linked with Apache. [Ralf S. Engelschall] Index: main/util.c =================================================================== RCS file: /e/apache/REPOS/apache-1.3/src/main/util.c,v retrieving revision 1.93 diff -u -r1.93 util.c --- util.c 1998/02/02 22:33:34 1.93 +++ util.c 1998/02/28 15:57:09 @@ -754,10 +754,32 @@ /* 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 */ + 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) == '\\') { + cbuf = --cp; + cbufsize -= (cp - cbuf); + continue; + } + } + break; + } + /* Compress the line, reducing all blanks and tabs to one space. * Leading and trailing white space is eliminated completely */ @@ -818,6 +840,12 @@ ++cfp->line_number; } if (c == EOF || c == 0x4 || c == LF || i >= (bufsize - 2)) { + /* check for line continuation */ + if (i > 0 && buf[i-1] == '\\') { + --i; + c = cfp->getch(cfp->param); + continue; + } /* blast trailing whitespace */ while (i > 0 && isspace(buf[i - 1])) --i;