]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Author: Francesco Chemolli <kinkie@squid-cache.org>
authorAmos Jeffries <squid3@treenet.co.nz>
Fri, 6 Mar 2009 07:36:36 +0000 (20:36 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Fri, 6 Mar 2009 07:36:36 +0000 (20:36 +1300)
Bug 2608: Build broken by Linux basename() implementation.

This patch implements a replacement for the call to basename() in
debugs().

It involves a hard-coded relative test location for debugs.cc used as an
anchor within the __FILE__ path. This relative path MUST be updated
whenever debugs.cc is moved.

debugs() is no longer valid to be used within auto-generated files which
may retain a completely different relative base path.

1  2 
configure.in
src/Debug.h
src/cf_gen.cc
src/debug.cc

diff --cc configure.in
index 0fd7ef57f00729b198fd1fe6bf50a5de1144c9eb,8fb385d12a65ecf9b0fd57f34ec0a0154caf3a32..37ddb5ae81448e479b8c58aa41d5c9e3cfd3c5a5
@@@ -2244,7 -2229,7 +2244,6 @@@ AC_CHECK_HEADERS( 
        ip_nat.h \
        ipl.h \
        libc.h \
--      libgen.h \
        limits.h \
        malloc.h \
        math.h \
diff --cc src/Debug.h
index f9cec79b0b8d658450e81f78fe70f3b1335b5d62,a668c9023e6a8c5374fbffd1c18f90d04551a013..2322bb52285fd928fa55c7880bcf2bf7c97f062b
@@@ -86,6 -80,8 +80,10 @@@ private
  
  extern FILE *debug_log;
  
 -SQUIDCEXTERN const char* SkipBuildPrefix(const char* path);
++const size_t BuildPrefixInit();
++const char * SkipBuildPrefix(const char* path);
++
  /* Debug stream */
  #define debugs(SECTION, LEVEL, CONTENT) \
     do { \
diff --cc src/cf_gen.cc
index 0180906a27d2de97ea37de467bf79542f7e9c5d9,0180906a27d2de97ea37de467bf79542f7e9c5d9..8ad00de525e13c359904d69dcd21a8536d16bbd0
@@@ -663,7 -663,7 +663,6 @@@ gen_parse(Entry * head, FILE * fp
              "parse_line(char *buff)\n"
              "{\n"
              "\tchar\t*token;\n"
--            "\tdebugs(0, 10, \"parse_line: \" << buff << \"\\n\" );\n"
              "\tif ((token = strtok(buff, w_space)) == NULL) \n"
              "\t\treturn 1;\t/* ignore empty lines */\n"
             );
diff --cc src/debug.cc
index 466e4820d59cc88172a8ea4faa4dfb784dc6ec03,ea02e8d4e7d5d5d61d9bc7b2a799bd4f4614f687..bbd9da8c6dadb29bc19be091bc682eab2e825633
   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
   *
   */
 -/* Anyone moving the src/Debug.cc file MUST record its new location here,
 - * or there will be issues in the debugging statements, possibly fatal!
 - */
 -#define RELATIVE_PATH_TO_DEBUG_CC "src/debug.cc"
 -
  #include "config.h"
  #include "Debug.h"
  #include "SquidTime.h"
@@@ -746,3 -752,18 +747,27 @@@ Debug::xassert(const char *msg, const c
  }
  
  std::ostringstream (*Debug::CurrentDebug)(NULL);
 -static const size_t BuildPrefixInit()
 -    const char *rptdcc=RELATIVE_PATH_TO_DEBUG_CC;
 -    assert(strstr(file,rptdcc)!=NULL);
 -    return strlen(file)-strlen(rptdcc);
++const size_t
++BuildPrefixInit()
+ {
++
++    /* Anyone moving the src/Debug.cc file MUST record its new location here,
++     * or there will be issues in the debugging statements, possibly fatal!
++     */
++
++    const char *ThisFileNameTail = "src/debug.cc";
++
+     //leave immediately if misconfigured. Unfortunately not possible to detect at build
+     const char *file=__FILE__;
 -static const size_t BuildPrefixLength=BuildPrefixInit();
 -const char* SkipBuildPrefix(const char* path)
++    assert(strstr(file,ThisFileNameTail)!=NULL);
++    return strlen(file)-strlen(ThisFileNameTail);
+ }
 -
++
++const char*
++SkipBuildPrefix(const char* path)
+ {
++    static const size_t BuildPrefixLength = BuildPrefixInit();
++
+     return path+BuildPrefixLength;
+ }