--------------------- PatchSet 4443 Date: 2007/05/03 10:05:07 Author: amosjeffries Branch: ayjwork Tag: (none) Log: change of tack. Members: src/CommonPool.h:1.3.22.1->1.3.22.2 src/ESIAssign.cc:1.3.20.1->1.3.20.2 src/ESIAssign.h:1.3.20.1->1.3.20.2 src/ESISegment.cc:1.4.22.2->1.4.22.3 src/ESISegment.h:1.5.8.1->1.5.8.2 src/HttpHdrCc.cc:1.6.12.3->1.6.12.4 src/HttpHdrRange.cc:1.13.8.2->1.13.8.3 src/HttpHdrSc.cc:1.5.8.3->1.5.8.4 src/HttpHeader.cc:1.40.4.4->1.40.4.5 src/HttpHeader.h:1.18.4.2->1.18.4.3 src/HttpHeaderRange.h:1.9.8.2->1.9.8.3 src/HttpHeaderTools.cc:1.21.4.3->1.21.4.4 src/HttpReply.cc:1.38.4.2->1.38.4.3 src/HttpRequest.h:1.25.4.2->1.25.4.3 src/HttpStatusLine.cc:1.5.12.2->1.5.12.3 src/Makefile.am:1.116.2.3->1.116.2.4 src/SquidString.h:1.8->1.8.8.1 src/access_log.cc:1.41.4.4->1.41.4.5 src/cache_cf.cc:1.79.2.3->1.79.2.4 src/client_side.cc:1.119.2.3->1.119.2.4 src/client_side_request.cc:1.66.4.3->1.66.4.4 src/delay_pools.cc:1.20.8.2->1.20.8.3 src/external_acl.cc:1.52.4.3->1.52.4.4 src/ftp.cc:1.62.4.5->1.62.4.6 src/gopher.cc:1.23.4.3->1.23.4.4 src/http.cc:1.99.2.4->1.99.2.5 src/redirect.cc:1.21.8.3->1.21.8.4 src/stat.cc:1.36.2.3->1.36.2.4 src/store.cc:1.51.4.3->1.51.4.4 src/structs.h:1.105.2.2->1.105.2.3 src/tools.cc:1.43.2.3->1.43.2.4 src/typedefs.h:1.44.8.1->1.44.8.2 src/urn.cc:1.25.8.3->1.25.8.4 src/auth/digest/auth_digest.cc:1.29.4.2->1.29.4.3 Index: squid3/src/CommonPool.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/CommonPool.h,v retrieving revision 1.3.22.1 retrieving revision 1.3.22.2 diff -u -r1.3.22.1 -r1.3.22.2 --- squid3/src/CommonPool.h 1 May 2007 16:09:26 -0000 1.3.22.1 +++ squid3/src/CommonPool.h 3 May 2007 10:05:07 -0000 1.3.22.2 @@ -1,6 +1,6 @@ /* - * $Id: CommonPool.h,v 1.3.22.1 2007/05/01 16:09:26 amosjeffries Exp $ + * $Id: CommonPool.h,v 1.3.22.2 2007/05/03 10:05:07 amosjeffries Exp $ * * DEBUG: section 77 Delay Pools * AUTHOR: Robert Collins @@ -43,7 +43,7 @@ #define COMMONPOOL_H #if DELAY_POOLS #include "squid.h" -#include +#include "SquidString.h" #include "CompositePoolNode.h" /* Next steps: make this a composite, and TypeLabel a composite method. Index: squid3/src/ESIAssign.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ESIAssign.cc,v retrieving revision 1.3.20.1 retrieving revision 1.3.20.2 diff -u -r1.3.20.1 -r1.3.20.2 --- squid3/src/ESIAssign.cc 1 May 2007 12:50:23 -0000 1.3.20.1 +++ squid3/src/ESIAssign.cc 3 May 2007 10:05:07 -0000 1.3.20.2 @@ -1,6 +1,6 @@ /* - * $Id: ESIAssign.cc,v 1.3.20.1 2007/05/01 12:50:23 amosjeffries Exp $ + * $Id: ESIAssign.cc,v 1.3.20.2 2007/05/03 10:05:07 amosjeffries Exp $ * * DEBUG: section 86 ESI processing * AUTHOR: Robert Collins @@ -117,7 +117,7 @@ if (!value) return ESI_PROCESS_COMPLETE; - varState->addVariable (name.buf(), name.size(), value); + varState->addVariable (name.c_str(), name.size(), value); value = NULL; @@ -181,12 +181,12 @@ ESIVariableExpression::~ESIVariableExpression() {} -ESIVariableExpression::ESIVariableExpression (String const &aString) : expression (aString) +ESIVariableExpression::ESIVariableExpression (string const &aString) : expression (aString) {} void ESIVariableExpression::eval (ESIVarState &state, char const *subref, char const *defaultOnEmpty) const { /* XXX: Implement evaluation of the expression */ - ESISegment::ListAppend (state.getOutput(), expression.buf(), expression.size()); + ESISegment::ListAppend (state.getOutput(), expression.c_str(), expression.size()); } Index: squid3/src/ESIAssign.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ESIAssign.h,v retrieving revision 1.3.20.1 retrieving revision 1.3.20.2 diff -u -r1.3.20.1 -r1.3.20.2 --- squid3/src/ESIAssign.h 1 May 2007 16:09:26 -0000 1.3.20.1 +++ squid3/src/ESIAssign.h 3 May 2007 10:05:07 -0000 1.3.20.2 @@ -1,5 +1,5 @@ /* - * $Id: ESIAssign.h,v 1.3.20.1 2007/05/01 16:09:26 amosjeffries Exp $ + * $Id: ESIAssign.h,v 1.3.20.2 2007/05/03 10:05:07 amosjeffries Exp $ * * DEBUG: section 86 ESI processing * AUTHOR: Robert Collins @@ -38,7 +38,7 @@ #include "squid.h" #include "ESIElement.h" -#include +#include "SquidString.h" #include "ESIVarState.h" /* ESIVariableExpression */ @@ -49,7 +49,7 @@ public: ~ESIVariableExpression(); - ESIVariableExpression (String const &value); + ESIVariableExpression (string const &value); virtual void eval (ESIVarState &state, char const *, char const *) const; private: @@ -81,10 +81,10 @@ void evaluateVariable(); esiTreeParentPtr parent; ESIVarState *varState; - String name; + string name; ESIVariableExpression * value; ESIElement::Pointer variable; - String unevaluatedVariable; + string unevaluatedVariable; }; MEMPROXY_CLASS_INLINE(ESIAssign) Index: squid3/src/ESISegment.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ESISegment.cc,v retrieving revision 1.4.22.2 retrieving revision 1.4.22.3 diff -u -r1.4.22.2 -r1.4.22.3 --- squid3/src/ESISegment.cc 1 May 2007 16:09:26 -0000 1.4.22.2 +++ squid3/src/ESISegment.cc 3 May 2007 10:05:07 -0000 1.4.22.3 @@ -1,6 +1,6 @@ /* - * $Id: ESISegment.cc,v 1.4.22.2 2007/05/01 16:09:26 amosjeffries Exp $ + * $Id: ESISegment.cc,v 1.4.22.3 2007/05/03 10:05:07 amosjeffries Exp $ * * DEBUG: section 86 ESI processing * AUTHOR: Robert Collins @@ -35,6 +35,7 @@ #include "squid.h" #include "ESISegment.h" +#include "SquidString.h" CBDATA_TYPE(ESISegment); Index: squid3/src/ESISegment.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ESISegment.h,v retrieving revision 1.5.8.1 retrieving revision 1.5.8.2 diff -u -r1.5.8.1 -r1.5.8.2 --- squid3/src/ESISegment.h 1 May 2007 16:09:26 -0000 1.5.8.1 +++ squid3/src/ESISegment.h 3 May 2007 10:05:07 -0000 1.5.8.2 @@ -1,5 +1,5 @@ /* - * $Id: ESISegment.h,v 1.5.8.1 2007/05/01 16:09:26 amosjeffries Exp $ + * $Id: ESISegment.h,v 1.5.8.2 2007/05/03 10:05:07 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -39,7 +39,7 @@ #include "cbdata.h" #include "RefCount.h" -#include +#include "SquidString.h" class ESISegment : public RefCountable { Index: squid3/src/HttpHdrCc.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/HttpHdrCc.cc,v retrieving revision 1.6.12.3 retrieving revision 1.6.12.4 diff -u -r1.6.12.3 -r1.6.12.4 --- squid3/src/HttpHdrCc.cc 2 May 2007 00:09:50 -0000 1.6.12.3 +++ squid3/src/HttpHdrCc.cc 3 May 2007 10:05:07 -0000 1.6.12.4 @@ -1,6 +1,6 @@ /* - * $Id: HttpHdrCc.cc,v 1.6.12.3 2007/05/02 00:09:50 amosjeffries Exp $ + * $Id: HttpHdrCc.cc,v 1.6.12.4 2007/05/03 10:05:07 amosjeffries Exp $ * * DEBUG: section 65 HTTP Cache Control Header * AUTHOR: Alex Rousskov @@ -206,7 +206,7 @@ assert(cc); if (cc->other.c_str()) - cc->other = ""; + cc->other.clear(); memFree(cc, MEM_HTTP_HDR_CC); } Index: squid3/src/HttpHdrRange.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/HttpHdrRange.cc,v retrieving revision 1.13.8.2 retrieving revision 1.13.8.3 diff -u -r1.13.8.2 -r1.13.8.3 --- squid3/src/HttpHdrRange.cc 1 May 2007 16:09:26 -0000 1.13.8.2 +++ squid3/src/HttpHdrRange.cc 3 May 2007 10:05:07 -0000 1.13.8.3 @@ -1,6 +1,6 @@ /* - * $Id: HttpHdrRange.cc,v 1.13.8.2 2007/05/01 16:09:26 amosjeffries Exp $ + * $Id: HttpHdrRange.cc,v 1.13.8.3 2007/05/03 10:05:07 amosjeffries Exp $ * * DEBUG: section 64 HTTP Range Header * AUTHOR: Alex Rousskov @@ -256,7 +256,7 @@ debugs(64, 8, "parsing range field: '" << *range_spec << "'"); /* check range type */ - if (strncasecmp(range_spec->c_str(),"bytes=", 6)) + if (strncasecmp(*range_spec,"bytes=", 6)) return 0; /* skip "bytes="; hack! */ Index: squid3/src/HttpHdrSc.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/HttpHdrSc.cc,v retrieving revision 1.5.8.3 retrieving revision 1.5.8.4 diff -u -r1.5.8.3 -r1.5.8.4 --- squid3/src/HttpHdrSc.cc 2 May 2007 00:09:50 -0000 1.5.8.3 +++ squid3/src/HttpHdrSc.cc 3 May 2007 10:05:07 -0000 1.5.8.4 @@ -1,6 +1,6 @@ /* - * $Id: HttpHdrSc.cc,v 1.5.8.3 2007/05/02 00:09:50 amosjeffries Exp $ + * $Id: HttpHdrSc.cc,v 1.5.8.4 2007/05/03 10:05:07 amosjeffries Exp $ * * DEBUG: section 90 HTTP Cache Control Header * AUTHOR: Alex Rousskov @@ -196,7 +196,7 @@ if (!p || !httpHeaderParseQuotedString(p, &sct->content)) { debugs(90, 2, "sc: invalid content= quoted string near '" << item << "'"); - sct->content = ""; + sct->content.clear(); EBIT_CLR(sct->mask, type); } Index: squid3/src/HttpHeader.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/HttpHeader.cc,v retrieving revision 1.40.4.4 retrieving revision 1.40.4.5 diff -u -r1.40.4.4 -r1.40.4.5 --- squid3/src/HttpHeader.cc 2 May 2007 00:09:50 -0000 1.40.4.4 +++ squid3/src/HttpHeader.cc 3 May 2007 10:05:10 -0000 1.40.4.5 @@ -1,6 +1,6 @@ /* - * $Id: HttpHeader.cc,v 1.40.4.4 2007/05/02 00:09:50 amosjeffries Exp $ + * $Id: HttpHeader.cc,v 1.40.4.5 2007/05/03 10:05:10 amosjeffries Exp $ * * DEBUG: section 55 HTTP Header * AUTHOR: Alex Rousskov @@ -599,7 +599,7 @@ } } - if (e->id == HDR_OTHER && strpbrk(e->name.c_str(), w_space) != NULL) { + if (e->id == HDR_OTHER && strpbrk(e->name, w_space) != NULL) { debugs(55, Config.onoff.relaxed_header_parser <= 0 ? 1 : 2, "WARNING: found whitespace in HTTP header name {" << getStringPrefix(field_start, field_end) << "}"); @@ -722,7 +722,7 @@ debugs(55, 9, "deleting '" << name << "' fields in hdr " << this); while ((e = getEntry(&pos))) { - if (!strcasecmp(e->name.c_str(),name)) { + if (!strcasecmp(e->name,name)) { delAt(pos); count++; } else @@ -925,7 +925,7 @@ /* Sorry, an unknown header name. Do linear search */ while ((e = getEntry(&pos))) { - if (e->id == HDR_OTHER && strcasecmp(e->name.c_str(),name) == 0) { + if (e->id == HDR_OTHER && strcasecmp(e->name,name) == 0) { strListAdd(&result, e->value.c_str(), ','); } } @@ -1423,10 +1423,8 @@ assert_eid(id); /* set field name */ - if (id == HDR_OTHER) { - name = field_start; - name[name_len] = '\0'; - } + if (id == HDR_OTHER) + name.limitInit(field_start, name_len); else name = Headers[id].name; @@ -1442,14 +1440,13 @@ debugs(55, 1, "WARNING: ignoring '" << name << "' header of " << (field_end - value_start) << " bytes"); if (id == HDR_OTHER) - name = ""; + name.clear(); return NULL; } /* set field value */ - value = value_start; - value[field_end - value_start] = '\0'; + value.limitInit(value_start, field_end - value_start); Headers[id].stat.seenCount++; @@ -1613,7 +1610,7 @@ if (name_len >= 0 && name_len != info[i].name.size()) continue; - if (!strncasecmp(name, info[i].name.c_str(), + if (!strncasecmp(name, info[i].name, name_len < 0 ? info[i].name.size() + 1 : name_len)) return info[i].id; } Index: squid3/src/HttpHeader.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/HttpHeader.h,v retrieving revision 1.18.4.2 retrieving revision 1.18.4.3 diff -u -r1.18.4.2 -r1.18.4.3 --- squid3/src/HttpHeader.h 2 May 2007 12:53:05 -0000 1.18.4.2 +++ squid3/src/HttpHeader.h 3 May 2007 10:05:11 -0000 1.18.4.3 @@ -1,6 +1,6 @@ /* - * $Id: HttpHeader.h,v 1.18.4.2 2007/05/02 12:53:05 amosjeffries Exp $ + * $Id: HttpHeader.h,v 1.18.4.3 2007/05/03 10:05:11 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -171,8 +171,6 @@ typedef struct _ETag ETag; -#include "typedefs.h" - class HttpHeaderEntry { Index: squid3/src/HttpHeaderRange.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/HttpHeaderRange.h,v retrieving revision 1.9.8.2 retrieving revision 1.9.8.3 diff -u -r1.9.8.2 -r1.9.8.3 --- squid3/src/HttpHeaderRange.h 2 May 2007 12:53:05 -0000 1.9.8.2 +++ squid3/src/HttpHeaderRange.h 3 May 2007 10:05:11 -0000 1.9.8.3 @@ -1,6 +1,6 @@ /* - * $Id: HttpHeaderRange.h,v 1.9.8.2 2007/05/02 12:53:05 amosjeffries Exp $ + * $Id: HttpHeaderRange.h,v 1.9.8.3 2007/05/03 10:05:11 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -34,13 +34,11 @@ #ifndef SQUID_HTTPHEADERRANGE_H #define SQUID_HTTPHEADERRANGE_H -#include "typedefs.h" - #include "MemPool.h" #include "Range.h" #include "Array.h" #include "Packer.h" -#include +#include "SquidString.h" class HttpReply; /* http byte-range-spec */ Index: squid3/src/HttpHeaderTools.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/HttpHeaderTools.cc,v retrieving revision 1.21.4.3 retrieving revision 1.21.4.4 diff -u -r1.21.4.3 -r1.21.4.4 --- squid3/src/HttpHeaderTools.cc 1 May 2007 16:09:26 -0000 1.21.4.3 +++ squid3/src/HttpHeaderTools.cc 3 May 2007 10:05:11 -0000 1.21.4.4 @@ -1,6 +1,6 @@ /* - * $Id: HttpHeaderTools.cc,v 1.21.4.3 2007/05/01 16:09:26 amosjeffries Exp $ + * $Id: HttpHeaderTools.cc,v 1.21.4.4 2007/05/03 10:05:11 amosjeffries Exp $ * * DEBUG: section 66 HTTP Header Tools * AUTHOR: Alex Rousskov @@ -204,7 +204,7 @@ strListIsSubstr(const string * list, const char *s, char del) { assert(list && del); - return list->find(s) != 0; + return list->pos(s) != 0; /* * Note: the original code with a loop is broken because it uses strstr() Index: squid3/src/HttpReply.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/HttpReply.cc,v retrieving revision 1.38.4.2 retrieving revision 1.38.4.3 diff -u -r1.38.4.2 -r1.38.4.3 --- squid3/src/HttpReply.cc 1 May 2007 16:09:26 -0000 1.38.4.2 +++ squid3/src/HttpReply.cc 3 May 2007 10:05:11 -0000 1.38.4.3 @@ -1,6 +1,6 @@ /* - * $Id: HttpReply.cc,v 1.38.4.2 2007/05/01 16:09:26 amosjeffries Exp $ + * $Id: HttpReply.cc,v 1.38.4.3 2007/05/03 10:05:11 amosjeffries Exp $ * * DEBUG: section 58 HTTP Reply (Response) * AUTHOR: Alex Rousskov @@ -220,7 +220,7 @@ hdr->putStr(HDR_CONTENT_TYPE, ctype); content_type = ctype; } else - content_type = ""; + content_type.clear(); if (clen >= 0) hdr->putInt(HDR_CONTENT_LENGTH, clen); @@ -278,9 +278,7 @@ two = otherRep->header.getStrOrList(HDR_ETAG); - if (!one.c_str() || !two.c_str() || strcasecmp (one.c_str(), two.c_str())) { - one.clear(); - two.clear(); + if (!one.c_str() || !two.c_str() || strcasecmp (one, two)) { return 0; } @@ -292,7 +290,7 @@ two = otherRep->header.getStrOrList(HDR_CONTENT_MD5); - if (!one.c_str() || !two.c_str() || strcasecmp (one.c_str(), two.c_str())) { + if (!one.c_str() || !two.c_str() || strcasecmp (one, two)) { one.clear(); two.clear(); return 0; @@ -380,10 +378,8 @@ keep_alive = httpMsgIsPersistent(sline.version, &header); const char *str = header.getStr(HDR_CONTENT_TYPE); - if (str) { - content_type = str; - content_type[strcspn(str, ";\t ")] = '\0'; - } + if (str) + content_type.limitInit(str, strcspn(str, ";\t ")); else content_type = ""; @@ -437,7 +433,7 @@ bool HttpReply::sanityCheckStartLine(MemBuf *buf, http_status *error) { - if ((unsigned int)buf->contentSize() >= protoPrefix.size() && strncmp(protoPrefix.c_str(), buf->content(), protoPrefix.size()) != 0) { + if ((unsigned int)buf->contentSize() >= protoPrefix.size() && strncmp(protoPrefix, buf->content(), protoPrefix.size()) != 0) { debugs(58, 3, "HttpReply::sanityCheckStartLine: missing protocol prefix (" << protoPrefix << ") in '" << buf->content() << "'"); *error = HTTP_INVALID_HEADER; return false; Index: squid3/src/HttpRequest.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/HttpRequest.h,v retrieving revision 1.25.4.2 retrieving revision 1.25.4.3 diff -u -r1.25.4.2 -r1.25.4.3 --- squid3/src/HttpRequest.h 1 May 2007 16:09:26 -0000 1.25.4.2 +++ squid3/src/HttpRequest.h 3 May 2007 10:05:11 -0000 1.25.4.3 @@ -1,6 +1,6 @@ /* - * $Id: HttpRequest.h,v 1.25.4.2 2007/05/01 16:09:26 amosjeffries Exp $ + * $Id: HttpRequest.h,v 1.25.4.3 2007/05/03 10:05:11 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -34,7 +34,6 @@ #ifndef SQUID_HTTPREQUEST_H #define SQUID_HTTPREQUEST_H -#include #include "HttpMsg.h" #include "client_side.h" #include "HierarchyLogEntry.h" Index: squid3/src/HttpStatusLine.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/HttpStatusLine.cc,v retrieving revision 1.5.12.2 retrieving revision 1.5.12.3 diff -u -r1.5.12.2 -r1.5.12.3 --- squid3/src/HttpStatusLine.cc 1 May 2007 16:09:26 -0000 1.5.12.2 +++ squid3/src/HttpStatusLine.cc 3 May 2007 10:05:11 -0000 1.5.12.3 @@ -1,6 +1,6 @@ /* - * $Id: HttpStatusLine.cc,v 1.5.12.2 2007/05/01 16:09:26 amosjeffries Exp $ + * $Id: HttpStatusLine.cc,v 1.5.12.3 2007/05/03 10:05:11 amosjeffries Exp $ * * DEBUG: section 57 HTTP Status-line * AUTHOR: Alex Rousskov @@ -90,7 +90,7 @@ // XXX: HttpMsg::parse() has a similar check but is using // casesensitive comparison (which is required by HTTP errata?) - if (strncasecmp(protoPrefix.c_str(),start, protoPrefix.size()) != 0) + if (strncasecmp(protoPrefix,start, protoPrefix.size()) != 0) return 0; start += protoPrefix.size(); Index: squid3/src/Makefile.am =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Makefile.am,v retrieving revision 1.116.2.3 retrieving revision 1.116.2.4 diff -u -r1.116.2.3 -r1.116.2.4 --- squid3/src/Makefile.am 2 May 2007 12:53:05 -0000 1.116.2.3 +++ squid3/src/Makefile.am 3 May 2007 10:05:11 -0000 1.116.2.4 @@ -1,7 +1,7 @@ # # Makefile for the Squid Object Cache server # -# $Id: Makefile.am,v 1.116.2.3 2007/05/02 12:53:05 amosjeffries Exp $ +# $Id: Makefile.am,v 1.116.2.4 2007/05/03 10:05:11 amosjeffries Exp $ # # Uncomment and customize the following to suit your needs: # @@ -556,6 +556,7 @@ $(SSL_SOURCE) \ stat.cc \ StatHist.cc \ + SqString.cc \ stmem.cc \ stmem.h \ store.cc \ @@ -594,7 +595,6 @@ StoreSwapLogData.h \ Server.cc \ Server.h \ - string_ext.cc \ structs.h \ SwapDir.cc \ SwapDir.h \ @@ -626,6 +626,9 @@ MemBuf.h \ Store.cci \ StoreEntryStream.h \ + SqString.cci \ + SqString.h \ + SquidString.h \ SquidTime.h nodist_squid_SOURCES = \ @@ -725,6 +728,7 @@ StoreMetaUnpacker.cc \ StoreMetaURL.cc \ StoreMetaVary.cc \ + SqString.cc \ time.cc \ ufsdump.cc \ url.cc \ @@ -851,7 +855,6 @@ store_swapin.cc \ store_swapmeta.cc \ store_swapout.cc \ - string_ext.cc \ structs.h \ SwapDir.cc \ tools.cc \ @@ -1105,18 +1108,15 @@ tests_testAuth_SOURCES= tests/testAuth.cc tests/testMain.cc tests/testAuth.h $(TESTSOURCES) \ authenticate.cc \ ConfigParser.cc \ - tests/stub_acl.cc \ - tests/stub_cache_cf.cc \ - tests/stub_helper.cc cbdata.cc \ - tests/stub_store.cc \ - HttpHeaderTools.cc HttpHeader.cc acl.cc event.cc mem.cc \ + tests/stub_acl.cc tests/stub_cache_cf.cc \ + tests/stub_helper.cc cbdata.cc SqString.cc \ + tests/stub_store.cc HttpHeaderTools.cc HttpHeader.cc acl.cc event.cc mem.cc \ MemBuf.cc HttpHdrContRange.cc Packer.cc ACLChecklist.cc HttpHdrCc.cc HttpHdrSc.cc \ HttpHdrScTarget.cc url.cc ACLProxyAuth.cc ACLRegexData.cc ACLUserData.cc \ StatHist.cc HttpHdrRange.cc ETag.cc tests/stub_errorpage.cc \ tests/stub_HttpRequest.cc tests/stub_DelayId.cc \ tests/stub_MemObject.cc mem_node.cc \ stmem.cc \ - string_ext.cc \ tests/stub_comm.cc \ tests/stub_http.cc \ HttpMsg.cc \ @@ -1127,7 +1127,7 @@ URLScheme.cc \ wordlist.cc ## acl.cc cache_cf.cc tools.cc \ -## helper.cc cbdata.cc HttpHeaderTools.cc store.cc cache_manager.cc \ +## helper.cc SqString.cc cbdata.cc HttpHeaderTools.cc store.cc cache_manager.cc \ ## HttpHeader.cc url.cc mem.cc HttpRequest.cc Packer.cc access_log.cc \ ## MemBuf.cc StatHist.cc logfile.cc @@ -1163,6 +1163,7 @@ ## HttpHdrScTarget.cc \ ## Packer.cc \ ## StatHist.cc \ +## SqString.cc \ tests_testACLMaxUserIP_SOURCES= \ acl.cc \ ACLChecklist.cc \ @@ -1187,7 +1188,7 @@ Parsing.cc \ StatHist.cc \ stmem.cc \ - string_ext.cc \ + SqString.cc \ tests/stub_cache_cf.cc \ tests/stub_comm.cc \ tests/stub_DelayId.cc \ @@ -1235,6 +1236,7 @@ HttpRequest.cc \ HttpRequestMethod.cc \ mem.cc \ + SqString.cc \ tests/testCacheManager.cc \ tests/testCacheManager.h \ tests/testMain.cc \ @@ -1344,7 +1346,6 @@ StoreMetaURL.cc \ StoreMetaVary.cc \ StoreSwapLogData.cc \ - string_ext.cc \ tools.cc \ tunnel.cc \ SwapDir.cc \ @@ -1399,6 +1400,7 @@ HttpRequestMethod.cc \ mem.cc \ RemovalPolicy.cc \ + SqString.cc \ tests/CapturingStoreEntry.h \ tests/testEvent.cc \ tests/testEvent.h \ @@ -1508,7 +1510,6 @@ StoreMetaURL.cc \ StoreMetaVary.cc \ StoreSwapLogData.cc \ - string_ext.cc \ tools.cc \ tunnel.cc \ SwapDir.cc \ @@ -1551,6 +1552,7 @@ HttpRequestMethod.cc \ mem.cc \ RemovalPolicy.cc \ + SqString.cc \ tests/testEventLoop.cc \ tests/testEventLoop.h \ tests/testMain.cc \ @@ -1659,7 +1661,6 @@ StoreMetaURL.cc \ StoreMetaVary.cc \ StoreSwapLogData.cc \ - string_ext.cc \ tools.cc \ tunnel.cc \ SwapDir.cc \ @@ -1839,7 +1840,7 @@ StoreMetaURL.cc \ StoreMetaVary.cc \ StoreSwapLogData.cc \ - string_ext.cc \ + SqString.cc \ SwapDir.cc \ time.cc \ tools.cc \ @@ -1881,6 +1882,7 @@ HttpRequest.cc \ HttpRequestMethod.cc \ mem.cc \ + SqString.cc \ tests/testHttpRequest.h \ tests/testHttpRequest.cc \ tests/testHttpRequestMethod.h \ @@ -1992,7 +1994,6 @@ StoreMetaURL.cc \ StoreMetaVary.cc \ StoreSwapLogData.cc \ - string_ext.cc \ tools.cc \ tunnel.cc \ SwapDir.cc \ @@ -2048,8 +2049,7 @@ SwapDir.cc \ authenticate.cc \ tests/stub_acl.cc tests/stub_cache_cf.cc \ - string_ext.cc \ - tests/stub_helper.cc cbdata.cc \ + tests/stub_helper.cc cbdata.cc SqString.cc \ tests/stub_comm.cc \ tests/stub_client_side_request.cc \ tests/stub_http.cc \ @@ -2102,6 +2102,24 @@ tests_testStore_LDFLAGS = $(LIBADD_DL) tests_testStore_DEPENDENCIES = $(top_builddir)/lib/libmiscutil.a \ @SQUID_CPPUNIT_LA@ +# string needs mem.cc. +tests_testString_SOURCES= \ + mem.cc \ + SqString.cc \ + tests/testMain.cc \ + tests/testString.cc \ + tests/testString.h \ + $(TESTSOURCES) \ + time.cc + +tests_testString_LDADD= \ + -L../lib -lmiscutil \ + @REGEXLIB@ \ + @SQUID_CPPUNIT_LIBS@ \ + @SSLLIB@ +tests_testString_LDFLAGS = $(LIBADD_DL) +tests_testString_DEPENDENCIES = $(top_builddir)/lib/libmiscutil.a \ + @SQUID_CPPUNIT_LA@ SWAP_TEST_SOURCES = \ tests/stub_store_rebuild.cc \ @@ -2199,6 +2217,7 @@ HttpRequestMethod.cc \ mem.cc \ RemovalPolicy.cc \ + SqString.cc \ tests/testURL.cc \ tests/testURL.h \ tests/testURLScheme.cc \ @@ -2309,7 +2328,6 @@ StoreMetaURL.cc \ StoreMetaVary.cc \ StoreSwapLogData.cc \ - string_ext.cc \ tools.cc \ tunnel.cc \ SwapDir.cc \ Index: squid3/src/SquidString.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/SquidString.h,v retrieving revision 1.8 retrieving revision 1.8.8.1 diff -u -r1.8 -r1.8.8.1 --- squid3/src/SquidString.h 29 May 2006 00:50:18 -0000 1.8 +++ squid3/src/SquidString.h 3 May 2007 10:05:11 -0000 1.8.8.1 @@ -1,6 +1,6 @@ /* - * $Id: SquidString.h,v 1.8 2006/05/29 00:50:18 squidadm Exp $ + * $Id: SquidString.h,v 1.8.8.1 2007/05/03 10:05:11 amosjeffries Exp $ * * DEBUG: section 67 String * AUTHOR: Duane Wessels @@ -33,112 +33,56 @@ * */ +/** + * + * To allow for easy future updates to the string handling within squid + * We adopt the std::string API as the basis for string operations. + * Then we typedef string (due to namespacing actually ::Squid::string) + * as the preferred string handling class. + * For Release 3.0 it is intended that the old String (no SquidString) + * Will be the default string type. + * For Release 3.1 it is expected that either std::string of another + * custom managed type will be defined as default. + * + * This has been done for several reasons: + * + * The initial String implementation was incomplete and non-standard + * std::string provides a better known API for string handling + * std::string or a derivative may be used in future within squid + * String is a defined alternative to std::string in some systems + * + * These changes: + * - move the old String class to SquidString making the + * internal definition explicit. + * - provide a global typedef of 'string' for use in variables. + * - migrate the custom functions: + * buf() -> c_str() + * clean() -> clear() + * + * - define standard string operators + * - define debugs stream operator + * + */ + #ifndef SQUID_STRING_H #define SQUID_STRING_H -/* forward decls */ - -class CacheManager; - -#define DEBUGSTRINGS 0 -#if DEBUGSTRINGS -#include "splay.h" - -class String; - -class StringRegistry -{ - -public: - static StringRegistry &Instance(); - - void add - (String const *); - - void registerWithCacheManager(CacheManager & manager); - - void remove - (String const *); - -private: - static OBJH Stat; - - static StringRegistry Instance_; + /* Provide standard 'string' type */ + /* class defined by the #include file MUST present the basic std::string API */ - static SplayNode::SPLAYWALKEE Stater; +#include "SqString.h" +typedef SqString string; - Splay entries; - bool registered; + /* Overload standard functions using the basic string API */ -}; - -class StoreEntry; -#endif - -class String -{ - -public: - _SQUID_INLINE_ String(); - String (char const *); - String (String const &); - ~String(); - - String &operator =(char const *); - String &operator =(String const &); - bool operator ==(String const &) const; - bool operator !=(String const &) const; - - _SQUID_INLINE_ int size() const; - _SQUID_INLINE_ char const * buf() const; - void buf(char *); - void init (char const *); - void initBuf(size_t sz); - void limitInit(const char *str, int len); - void clean(); - void reset(char const *str); - void append(char const *buf, int len); - void append(char const *buf); - void append(char const); - void append (String const &); - void absorb(String &old); - _SQUID_INLINE_ const char * pos(char const *) const; - _SQUID_INLINE_ const char * pos(char const ch) const; - _SQUID_INLINE_ const char * rpos(char const ch) const; - _SQUID_INLINE_ int cmp (char const *) const; - _SQUID_INLINE_ int cmp (char const *, size_t count) const; - _SQUID_INLINE_ int cmp (String const &) const; - _SQUID_INLINE_ int caseCmp (char const *) const; - _SQUID_INLINE_ int caseCmp (char const *, size_t count) const; - - _SQUID_INLINE_ void set - (char const *loc, char const ch); - - _SQUID_INLINE_ void cut (size_t newLength); - - _SQUID_INLINE_ void cutPointer (char const *loc); - -#if DEBUGSTRINGS - - void stat (StoreEntry *) const; - -#endif - -private: - /* never reference these directly! */ - unsigned short int size_; /* buffer size; 64K limit */ - - unsigned short int len_; /* current length */ - - char *buf_; -}; - -_SQUID_INLINE_ std::ostream & operator<<(std::ostream& os, String const &aString); - -#ifdef _USE_INLINE_ -#include "String.cci" -#endif +inline int strncasecmp(const string &lhs, const char *rhs, int len) { return strncasecmp(lhs.c_str(), rhs, len); } +inline int strncasecmp(const string &lhs, const string &rhs, int len) { return strncasecmp(lhs.c_str(), rhs.c_str(), len); } +inline int strcasecmp(const string &lhs, const char *rhs) { return strcasecmp(lhs.c_str(), rhs); } +inline int strcasecmp(const string &lhs, const string &rhs) { return strcasecmp(lhs.c_str(), rhs.c_str()); } +inline int strcmp(const string &lhs, const char *rhs) { return strcmp(lhs.c_str(), rhs); } +inline int strcmp(const string &lhs, const string &rhs) { return strcmp(lhs.c_str(), rhs.c_str()); } +inline int strpbrk(const string &lhs, ???? &rhs) { return strpbrk(lhs.c_str(), rhs); } +inline ostream& operator <<(const string &s, ostream &os) { os << s.c_str(); return os; } #endif /* SQUID_STRING_H */ - Index: squid3/src/access_log.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/access_log.cc,v retrieving revision 1.41.4.4 retrieving revision 1.41.4.5 diff -u -r1.41.4.4 -r1.41.4.5 --- squid3/src/access_log.cc 1 May 2007 16:09:27 -0000 1.41.4.4 +++ squid3/src/access_log.cc 3 May 2007 10:05:11 -0000 1.41.4.5 @@ -1,6 +1,6 @@ /* - * $Id: access_log.cc,v 1.41.4.4 2007/05/01 16:09:27 amosjeffries Exp $ + * $Id: access_log.cc,v 1.41.4.5 2007/05/03 10:05:11 amosjeffries Exp $ * * DEBUG: section 46 Access Log * AUTHOR: Duane Wessels @@ -882,7 +882,7 @@ if (fmt->space) mb.append(" ", 1); - sb = ""; + sb.clear(); if (dofree) safe_free(out); Index: squid3/src/cache_cf.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/cache_cf.cc,v retrieving revision 1.79.2.3 retrieving revision 1.79.2.4 diff -u -r1.79.2.3 -r1.79.2.4 --- squid3/src/cache_cf.cc 1 May 2007 16:09:27 -0000 1.79.2.3 +++ squid3/src/cache_cf.cc 3 May 2007 10:05:11 -0000 1.79.2.4 @@ -1,6 +1,6 @@ /* - * $Id: cache_cf.cc,v 1.79.2.3 2007/05/01 16:09:27 amosjeffries Exp $ + * $Id: cache_cf.cc,v 1.79.2.4 2007/05/03 10:05:11 amosjeffries Exp $ * * DEBUG: section 3 Configuration File Parsing * AUTHOR: Harvest Derived @@ -2201,14 +2201,14 @@ } void -ConfigParser::ParseString(string &var) +ConfigParser::ParseString(string *var) { char *token = strtok(NULL, w_space); if (token == NULL) self_destruct(); - var = token; + var->reset(token); } static void Index: squid3/src/client_side.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/client_side.cc,v retrieving revision 1.119.2.3 retrieving revision 1.119.2.4 diff -u -r1.119.2.3 -r1.119.2.4 --- squid3/src/client_side.cc 1 May 2007 16:09:27 -0000 1.119.2.3 +++ squid3/src/client_side.cc 3 May 2007 10:05:11 -0000 1.119.2.4 @@ -1,6 +1,6 @@ /* - * $Id: client_side.cc,v 1.119.2.3 2007/05/01 16:09:27 amosjeffries Exp $ + * $Id: client_side.cc,v 1.119.2.4 2007/05/03 10:05:11 amosjeffries Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -543,7 +543,7 @@ safe_free(uri); safe_free(log_uri); safe_free(redirect.location); - range_iter.boundary = ""; + range_iter.boundary.clear(); HTTPMSGUNLOCK(request); if (client_stream.tail) Index: squid3/src/client_side_request.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/client_side_request.cc,v retrieving revision 1.66.4.3 retrieving revision 1.66.4.4 diff -u -r1.66.4.3 -r1.66.4.4 --- squid3/src/client_side_request.cc 1 May 2007 16:09:27 -0000 1.66.4.3 +++ squid3/src/client_side_request.cc 3 May 2007 10:05:12 -0000 1.66.4.4 @@ -1,6 +1,6 @@ /* - * $Id: client_side_request.cc,v 1.66.4.3 2007/05/01 16:09:27 amosjeffries Exp $ + * $Id: client_side_request.cc,v 1.66.4.4 2007/05/03 10:05:12 amosjeffries Exp $ * * DEBUG: section 85 Client-side Request Routines * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c) @@ -726,9 +726,11 @@ } #if FORW_VIA_DB - fvdbCountVia(s.buf()); + fvdbCountVia(s.c_str()); #endif + + s.clear(); } #if USE_USERAGENT_LOG @@ -747,7 +749,7 @@ if (req_hdr->has(HDR_X_FORWARDED_FOR)) { String s = req_hdr->getList(HDR_X_FORWARDED_FOR); fvdbCountForw(s.buf()); - s.clean(); + s.clear(); } #endif Index: squid3/src/delay_pools.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/delay_pools.cc,v retrieving revision 1.20.8.2 retrieving revision 1.20.8.3 diff -u -r1.20.8.2 -r1.20.8.3 --- squid3/src/delay_pools.cc 1 May 2007 16:09:27 -0000 1.20.8.2 +++ squid3/src/delay_pools.cc 3 May 2007 10:05:12 -0000 1.20.8.3 @@ -1,6 +1,6 @@ /* - * $Id: delay_pools.cc,v 1.20.8.2 2007/05/01 16:09:27 amosjeffries Exp $ + * $Id: delay_pools.cc,v 1.20.8.3 2007/05/03 10:05:12 amosjeffries Exp $ * * DEBUG: section 77 Delay Pools * AUTHOR: Robert Collins @@ -52,7 +52,7 @@ #include "ConfigParser.h" #include "DelayId.h" #include "Array.h" -#include +#include "SquidString.h" #include "SquidTime.h" #include "CommonPool.h" #include "CompositePoolNode.h" Index: squid3/src/external_acl.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/external_acl.cc,v retrieving revision 1.52.4.3 retrieving revision 1.52.4.4 diff -u -r1.52.4.3 -r1.52.4.4 --- squid3/src/external_acl.cc 1 May 2007 16:09:27 -0000 1.52.4.3 +++ squid3/src/external_acl.cc 3 May 2007 10:05:12 -0000 1.52.4.4 @@ -1,6 +1,6 @@ /* - * $Id: external_acl.cc,v 1.52.4.3 2007/05/01 16:09:27 amosjeffries Exp $ + * $Id: external_acl.cc,v 1.52.4.4 2007/05/03 10:05:12 amosjeffries Exp $ * * DEBUG: section 82 External ACL * AUTHOR: Henrik Nordstrom, MARA Systems AB @@ -913,7 +913,7 @@ strwordquote(&mb, str); } - sb = ""; + sb.clear(); first = 0; } Index: squid3/src/ftp.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/ftp.cc,v retrieving revision 1.62.4.5 retrieving revision 1.62.4.6 diff -u -r1.62.4.5 -r1.62.4.6 --- squid3/src/ftp.cc 1 May 2007 16:09:28 -0000 1.62.4.5 +++ squid3/src/ftp.cc 3 May 2007 10:05:12 -0000 1.62.4.6 @@ -1,6 +1,6 @@ /* - * $Id: ftp.cc,v 1.62.4.5 2007/05/01 16:09:28 amosjeffries Exp $ + * $Id: ftp.cc,v 1.62.4.6 2007/05/03 10:05:12 amosjeffries Exp $ * * DEBUG: section 9 File Transfer Protocol (FTP) * AUTHOR: Harvest Derived @@ -443,9 +443,9 @@ safe_free(old_filepath); - title_url = ""; + title_url.clear(); - base_href = ""; + base_href.clear(); safe_free(filepath); @@ -1423,11 +1423,10 @@ { int l; - size_t t = request->urlpath.rfind(';'); - if (t != string::npos) { - if (strncasecmp(request->urlpath.substr(t+1).c_str(), "type=", 5) == 0) { - typecode = (char) xtoupper(request->urlpath.at(t+6)); - request->urlpath[t] = '\0'; + if ((t = request->urlpath.rpos(';')) != NULL) { + if (strncasecmp(t + 1, "type=", 5) == 0) { + typecode = (char) xtoupper(*(t + 6)); + request->urlpath.cutPointer(t); } } @@ -1438,7 +1437,7 @@ flags.isdir = 1; flags.root_dir = 1; flags.need_base_href = 1; /* Work around broken browsers */ - } else if (request->urlpath != "/%2f/") { + } else if (!request->urlpath.compare("/%2f/")) { /* UNIX root directory */ flags.isdir = 1; flags.root_dir = 1; @@ -1930,6 +1929,7 @@ static void ftpSendType(FtpStateData * ftpState) { + const char *t; const char *filename; char mode; /* @@ -1953,8 +1953,8 @@ if (ftpState->flags.isdir) { mode = 'A'; } else { - const size_t t = ftpState->request->urlpath.rfind('/'); - filename = t ? ftpState->request->urlpath.substr(t+1).c_str() : ftpState->request->urlpath.c_str(); + t = ftpState->request->urlpath.rpos('/'); + filename = t ? t + 1 : ftpState->request->urlpath.c_str(); mode = mimeGetTransferMode(filename); } @@ -2956,7 +2956,7 @@ if (!ftpState->flags.isdir && /* Not a directory */ !ftpState->flags.try_slash_hack && /* Not in slash hack */ ftpState->mdtm <= 0 && ftpState->size < 0 && /* Not known as a file */ - strncasecmp(ftpState->request->urlpath.c_str(),"/%2f", 4) != 0) { /* No slash encoded */ + strncasecmp(ftpState->request->urlpath, "/%2f", 4) != 0) { /* No slash encoded */ switch (ftpState->state) { @@ -3117,7 +3117,7 @@ const char *mime_enc = NULL; string urlpath = request->urlpath; const char *filename = NULL; - size_t t = 0; + const char *t = NULL; StoreEntry *e = entry; HttpReply *newrep = new HttpReply; @@ -3136,7 +3136,7 @@ e->buffer(); /* released when done processing current data payload */ - filename = (t = urlpath.rfind('/')) != urlpath.size()? urlpath.substr(t+1).c_str() : urlpath.c_str(); + filename = (t = urlpath.rpos('/')) ? t + 1 : urlpath.c_str(); if (flags.isdir) { mime_type = "text/html"; Index: squid3/src/gopher.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/gopher.cc,v retrieving revision 1.23.4.3 retrieving revision 1.23.4.4 diff -u -r1.23.4.3 -r1.23.4.4 --- squid3/src/gopher.cc 1 May 2007 16:09:28 -0000 1.23.4.3 +++ squid3/src/gopher.cc 3 May 2007 10:05:12 -0000 1.23.4.4 @@ -1,6 +1,6 @@ /* - * $Id: gopher.cc,v 1.23.4.3 2007/05/01 16:09:28 amosjeffries Exp $ + * $Id: gopher.cc,v 1.23.4.4 2007/05/03 10:05:12 amosjeffries Exp $ * * DEBUG: section 10 Gopher * AUTHOR: Harvest Derived @@ -696,7 +696,7 @@ entry->flush(); } - outbuf = ""; + outbuf.clear(); return; } Index: squid3/src/http.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/http.cc,v retrieving revision 1.99.2.4 retrieving revision 1.99.2.5 diff -u -r1.99.2.4 -r1.99.2.5 --- squid3/src/http.cc 1 May 2007 16:09:28 -0000 1.99.2.4 +++ squid3/src/http.cc 3 May 2007 10:05:12 -0000 1.99.2.5 @@ -1,6 +1,6 @@ /* - * $Id: http.cc,v 1.99.2.4 2007/05/01 16:09:28 amosjeffries Exp $ + * $Id: http.cc,v 1.99.2.5 2007/05/03 10:05:12 amosjeffries Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -432,6 +432,7 @@ if (hdr->has(HDR_PRAGMA)) { string s = hdr->getList(HDR_PRAGMA); const int no_cache = strListIsMember(&s, "no-cache", ','); + s.clear(); if (no_cache) { if (!REFRESH_OVERRIDE(ignore_no_cache)) @@ -587,7 +588,7 @@ int ilen; static string vstr; - vstr = ""; + vstr.clear(); vary = reply->header.getList(HDR_VARY); while (strListGetItem(&vary, ',', &item, &ilen, &pos)) { @@ -598,7 +599,7 @@ if (strcmp(name, "*") == 0) { /* Can not handle "Vary: *" withtout ETag support */ safe_free(name); - vstr = ""; + vstr.clear(); break; } @@ -614,10 +615,10 @@ vstr.append("\"", 1); } - hdr = ""; + hdr.clear(); } - vary = ""; + vary.clear(); #if X_ACCELERATOR_VARY pos = NULL; @@ -639,10 +640,10 @@ vstr.append("\"", 1); } - hdr = ""; + hdr.clear(); } - vary = ""; + vary.clear(); #endif debugs(11, 3, "httpMakeVaryMark: " << vstr); @@ -1394,6 +1395,7 @@ orig_request->http_ver.minor, ThisCache); strListAdd(&strVia, bbuf, ','); hdr_out->putStr(HDR_VIA, strVia.c_str()); + strVia.clear(); } #if ESI @@ -1417,7 +1419,7 @@ hdr_out->putStr(HDR_X_FORWARDED_FOR, strFwd.c_str()); - strFwd = ""; + strFwd.clear(); /* append Host if not there already */ if (!hdr_out->has(HDR_HOST)) { @@ -1559,7 +1561,7 @@ if (Config2.onoff.mangle_request_headers) httpHdrMangleList(hdr_out, request, ROR_REQUEST); - strConnection = ""; + strConnection.clear(); } void Index: squid3/src/redirect.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/redirect.cc,v retrieving revision 1.21.8.3 retrieving revision 1.21.8.4 diff -u -r1.21.8.3 -r1.21.8.4 --- squid3/src/redirect.cc 2 May 2007 00:09:51 -0000 1.21.8.3 +++ squid3/src/redirect.cc 3 May 2007 10:05:13 -0000 1.21.8.4 @@ -1,6 +1,6 @@ /* - * $Id: redirect.cc,v 1.21.8.3 2007/05/02 00:09:51 amosjeffries Exp $ + * $Id: redirect.cc,v 1.21.8.4 2007/05/03 10:05:13 amosjeffries Exp $ * * DEBUG: section 61 Redirector * AUTHOR: Duane Wessels @@ -136,7 +136,7 @@ if (http->request->auth_user_request) r->client_ident = http->request->auth_user_request->username(); - else if (http->request->extacl_user.c_str() != NULL) { + else if (!http->request->extacl_user.empty()) { r->client_ident = http->request->extacl_user.c_str(); } Index: squid3/src/stat.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/stat.cc,v retrieving revision 1.36.2.3 retrieving revision 1.36.2.4 diff -u -r1.36.2.3 -r1.36.2.4 --- squid3/src/stat.cc 2 May 2007 00:09:51 -0000 1.36.2.3 +++ squid3/src/stat.cc 3 May 2007 10:05:13 -0000 1.36.2.4 @@ -1,5 +1,5 @@ /* - * $Id: stat.cc,v 1.36.2.3 2007/05/02 00:09:51 amosjeffries Exp $ + * $Id: stat.cc,v 1.36.2.4 2007/05/03 10:05:13 amosjeffries Exp $ * * DEBUG: section 18 Cache Manager Statistics * AUTHOR: Harvest Derived @@ -1692,7 +1692,7 @@ if (http->request->auth_user_request) p = http->request->auth_user_request->username(); - else if (http->request->extacl_user.c_str() != NULL) { + else if (!http->request->extacl_user.empty()) { p = http->request->extacl_user.c_str(); } Index: squid3/src/store.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/store.cc,v retrieving revision 1.51.4.3 retrieving revision 1.51.4.4 diff -u -r1.51.4.3 -r1.51.4.4 --- squid3/src/store.cc 1 May 2007 16:09:28 -0000 1.51.4.3 +++ squid3/src/store.cc 3 May 2007 10:05:13 -0000 1.51.4.4 @@ -1,6 +1,6 @@ /* - * $Id: store.cc,v 1.51.4.3 2007/05/01 16:09:28 amosjeffries Exp $ + * $Id: store.cc,v 1.51.4.4 2007/05/03 10:05:13 amosjeffries Exp $ * * DEBUG: section 20 Storage Manager * AUTHOR: Harvest Derived @@ -696,7 +696,7 @@ if (vary.size()) { /* Again, we own this structure layout */ rep->header.putStr(HDR_VARY, vary.c_str()); - vary = ""; + vary.clear(); } #if X_ACCELERATOR_VARY @@ -705,7 +705,7 @@ if (vary.c_str()) { /* Again, we own this structure layout */ rep->header.putStr(HDR_X_ACCELERATOR_VARY, vary.c_str()); - vary = ""; + vary.clear(); } #endif Index: squid3/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/structs.h,v retrieving revision 1.105.2.2 retrieving revision 1.105.2.3 diff -u -r1.105.2.2 -r1.105.2.3 --- squid3/src/structs.h 1 May 2007 16:09:28 -0000 1.105.2.2 +++ squid3/src/structs.h 3 May 2007 10:05:13 -0000 1.105.2.3 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.105.2.2 2007/05/01 16:09:28 amosjeffries Exp $ + * $Id: structs.h,v 1.105.2.3 2007/05/03 10:05:13 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -837,6 +837,7 @@ MemBuf *mb; }; +#include "SquidString.h" /* http header extention field */ class HttpHdrExtField Index: squid3/src/tools.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/tools.cc,v retrieving revision 1.43.2.3 retrieving revision 1.43.2.4 diff -u -r1.43.2.3 -r1.43.2.4 --- squid3/src/tools.cc 2 May 2007 12:53:05 -0000 1.43.2.3 +++ squid3/src/tools.cc 3 May 2007 10:05:13 -0000 1.43.2.4 @@ -1,6 +1,6 @@ /* - * $Id: tools.cc,v 1.43.2.3 2007/05/02 12:53:05 amosjeffries Exp $ + * $Id: tools.cc,v 1.43.2.4 2007/05/03 10:05:13 amosjeffries Exp $ * * DEBUG: section 21 Misc Functions * AUTHOR: Harvest Derived @@ -1273,6 +1273,52 @@ return 0; /* NOT REACHED */ } + +/* + * Inverse of strwordtok. Quotes a word if needed + */ +void +strwordquote(MemBuf * mb, const char *str) +{ + int quoted = 0; + + if (strchr(str, ' ')) { + quoted = 1; + mb->append("\"", 1); + } + + while (*str) { + int l = strcspn(str, "\"\\\n\r"); + mb->append(str, l); + str += l; + + switch(*str) { + + case '\n': + mb->append("\\n", 2); + str++; + break; + + case '\r': + mb->append("\\r", 2); + str++; + break; + + case '\0': + break; + + default: + mb->append("\\", 1); + mb->append(str, 1); + str++; + break; + } + } + + if (quoted) + mb->append("\"", 1); +} + void keepCapabilities(void) { Index: squid3/src/typedefs.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/typedefs.h,v retrieving revision 1.44.8.1 retrieving revision 1.44.8.2 diff -u -r1.44.8.1 -r1.44.8.2 --- squid3/src/typedefs.h 1 May 2007 16:09:28 -0000 1.44.8.1 +++ squid3/src/typedefs.h 3 May 2007 10:05:14 -0000 1.44.8.2 @@ -1,6 +1,6 @@ /* - * $Id: typedefs.h,v 1.44.8.1 2007/05/01 16:09:28 amosjeffries Exp $ + * $Id: typedefs.h,v 1.44.8.2 2007/05/03 10:05:14 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -36,9 +36,6 @@ #ifndef SQUID_TYPEDEFS_H #define SQUID_TYPEDEFS_H -#include -typedef std::string string; - typedef unsigned int store_status_t; typedef unsigned int ping_status_t; typedef unsigned int swap_status_t; Index: squid3/src/urn.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/urn.cc,v retrieving revision 1.25.8.3 retrieving revision 1.25.8.4 diff -u -r1.25.8.3 -r1.25.8.4 --- squid3/src/urn.cc 2 May 2007 00:09:51 -0000 1.25.8.3 +++ squid3/src/urn.cc 3 May 2007 10:05:14 -0000 1.25.8.4 @@ -1,6 +1,6 @@ /* - * $Id: urn.cc,v 1.25.8.3 2007/05/02 00:09:51 amosjeffries Exp $ + * $Id: urn.cc,v 1.25.8.4 2007/05/03 10:05:14 amosjeffries Exp $ * * DEBUG: section 52 URN Parsing * AUTHOR: Kostas Anagnostakis @@ -177,12 +177,12 @@ UrnState::getHost (string &urlpath) { char * result; - size_t t; + char const *t; - if ((t = urlpath.find(':')) != urlpath.size() ) { - urlpath[t] = '\0'; + if ((t = urlpath.pos(':')) != NULL) { + urlpath.set(t, '\0'); result = xstrdup(urlpath.c_str()); - urlpath[t] = ':'; + urlpath.set(t, ':'); } else { result = xstrdup(urlpath.c_str()); } @@ -193,7 +193,7 @@ bool UrnState::RequestNeedsMenu(HttpRequest *r) { - return strncasecmp(r->urlpath.c_str(), "menu.", 5) == 0; + return strncasecmp(r->urlpath, "menu.", 5) == 0; } void Index: squid3/src/auth/digest/auth_digest.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/auth/digest/auth_digest.cc,v retrieving revision 1.29.4.2 retrieving revision 1.29.4.3 diff -u -r1.29.4.2 -r1.29.4.3 --- squid3/src/auth/digest/auth_digest.cc 1 May 2007 16:09:29 -0000 1.29.4.2 +++ squid3/src/auth/digest/auth_digest.cc 3 May 2007 10:05:14 -0000 1.29.4.3 @@ -1,6 +1,6 @@ /* - * $Id: auth_digest.cc,v 1.29.4.2 2007/05/01 16:09:29 amosjeffries Exp $ + * $Id: auth_digest.cc,v 1.29.4.3 2007/05/03 10:05:14 amosjeffries Exp $ * * DEBUG: section 29 Authenticator * AUTHOR: Robert Collins @@ -1208,7 +1208,7 @@ } } - temp = ""; + temp.clear(); /* now we validate the data given to us */