From: Francesco Chemolli Date: Wed, 11 Feb 2009 15:28:22 +0000 (+0100) Subject: Implemented printf-specific String::psize() X-Git-Tag: SQUID_3_2_0_1~1189^2~7 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=696a257c88b7ac5e630a7b2c2e2eca4e8aee173f;p=thirdparty%2Fsquid.git Implemented printf-specific String::psize() Fixed unit tests. --- diff --git a/src/HttpHeader.h b/src/HttpHeader.h index 9e7a1d4f5c..9ee36b60e0 100644 --- a/src/HttpHeader.h +++ b/src/HttpHeader.h @@ -33,12 +33,21 @@ #ifndef SQUID_HTTPHEADER_H #define SQUID_HTTPHEADER_H - /* because we pass a spec by value */ #include "HttpHeaderRange.h" /* HttpHeader holds a HttpHeaderMask */ #include "HttpHeaderMask.h" + +/* class forward declarations */ +class HttpVersion; +class HttpHdrContRange; +class HttpHdrCc; +class HttpHdrSc; +class HttpHdrRange; +class String; + + /* constant attributes of http header fields */ /** recognized or "known" header fields; @?@ add more! */ @@ -149,13 +158,6 @@ struct _HttpHeaderFieldAttrs { field_type type; }; -class HttpVersion; - -class HttpHdrContRange; - -class HttpHdrCc; - -class HttpHdrSc; /** Iteration for headers; use HttpHeaderPos as opaque type, do not interpret */ typedef ssize_t HttpHeaderPos; diff --git a/src/Makefile.am b/src/Makefile.am index 357d44a4bd..177d9b7b9a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1512,6 +1512,7 @@ nodist_tests_testDiskIO_SOURCES= \ $(SWAP_TEST_GEN_SOURCES) tests_testDiskIO_LDADD = \ ip/libip.la \ + libsquid.la \ @DISK_LIBS@ \ $(SWAP_TEST_LDADD) \ SquidConfig.o diff --git a/src/SquidString.h b/src/SquidString.h index 47e1194b21..7fe23b112e 100644 --- a/src/SquidString.h +++ b/src/SquidString.h @@ -36,8 +36,6 @@ #define SQUID_STRING_H #include "config.h" -#include "TextException.h" - /** todo checks to wrap this include properly */ #include @@ -104,7 +102,7 @@ public: _SQUID_INLINE_ size_type size() const; /// variant of size() suited to be used for printf-alikes. /// throws when size() > MAXINT - _SQUID_INLINE_ int psize() const; + int psize() const; _SQUID_INLINE_ char const * unsafeBuf() const; /** diff --git a/src/String.cc b/src/String.cc index bc129f14fa..dded212de9 100644 --- a/src/String.cc +++ b/src/String.cc @@ -35,6 +35,15 @@ #include "squid.h" #include "Store.h" +#include "TextException.h" + +int +String::psize() const +{ + Must(size() < INT_MAX); + return size(); +} + // low-level buffer allocation, // does not free old buffer and does not adjust or look at len_ diff --git a/src/String.cci b/src/String.cci index 751086aa59..263fd9931b 100644 --- a/src/String.cci +++ b/src/String.cci @@ -58,13 +58,6 @@ String::size() const return len_; } -int -String::psize() const -{ - Must(size() < INT_MAX); - return size(); -} - char const * String::unsafeBuf() const { diff --git a/src/protos.h b/src/protos.h index 4df70c98aa..eb906c5eef 100644 --- a/src/protos.h +++ b/src/protos.h @@ -179,6 +179,7 @@ class FwdState; SQUIDCEXTERN void ftpStart(FwdState *); class HttpRequest; +class HttpReply; /// \ingroup ServerProtocolFTPAPI SQUIDCEXTERN const char *ftpUrlWith2f(HttpRequest *); diff --git a/src/tests/testEvent.cc b/src/tests/testEvent.cc index fa03c48075..1cafcf5cc1 100644 --- a/src/tests/testEvent.cc +++ b/src/tests/testEvent.cc @@ -97,7 +97,7 @@ testEvent::testDump() /* loop over the strings, showing exactly where they differ (if at all) */ printf("Actual Text:\n"); /* TODO: these should really be just [] lookups, but String doesn't have those here yet. */ - for ( int i = 0; i < anEntry->_appended_text.size(); i++) { + for ( unsigned int i = 0; i < anEntry->_appended_text.size(); i++) { CPPUNIT_ASSERT( expect[i] ); CPPUNIT_ASSERT( anEntry->_appended_text[i] ); diff --git a/src/tests/testString.cc b/src/tests/testString.cc index f615b43a46..9b0df39333 100644 --- a/src/tests/testString.cc +++ b/src/tests/testString.cc @@ -65,5 +65,5 @@ void testString::testSubstr() String s("0123456789"); String check=s.substr(3,5); String ref("34"); - CPPUNIT_ASSERT(s1 == ref); + CPPUNIT_ASSERT(check == ref); }