From: Francesco Chemolli Date: Mon, 30 Dec 2013 13:22:05 +0000 (+0100) Subject: Reverted multi-ranges as they require c++0x initializers X-Git-Tag: SQUID_3_5_0_1~217^2~21^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=decd2fc615ebdab7ce28b646a06d6cbde82cbd28;p=thirdparty%2Fsquid.git Reverted multi-ranges as they require c++0x initializers --- diff --git a/src/base/CharacterSet.cc b/src/base/CharacterSet.cc index 55a728b363..db9f31cd24 100644 --- a/src/base/CharacterSet.cc +++ b/src/base/CharacterSet.cc @@ -32,16 +32,11 @@ CharacterSet::add(const unsigned char c) } CharacterSet & -CharacterSet::addRange(const RangeSpec & v) +CharacterSet::addRange(unsigned char low, unsigned char high) { - for (RangeSpec::const_iterator i = v.begin(); i != v.end(); ++i) { - assert(i->first <= i->second); - unsigned char c = i->first; - unsigned char high = i->second; - while (c <= high) { - chars_[static_cast(c)] = 1; - ++c; - } + while (low <= high) { + chars_[static_cast(low)] = 1; + ++low; } return *this; } @@ -54,27 +49,27 @@ CharacterSet::CharacterSet(const char *label, const char * const c) add(c[i]); } -CharacterSet::CharacterSet(const char *label, const RangeSpec & ranges) +CharacterSet::CharacterSet(const char *label, unsigned char low, unsigned char high) : name(label == NULL ? "anonymous" : label), chars_(Storage(256,0)) { - addRange(ranges); + addRange(low,high); } const CharacterSet -CharacterSet::ALPHA("ALPHA", {{ 'a', 'z' }, { 'A', 'Z'}}), +CharacterSet::ALPHA("ALPHA", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), CharacterSet::BIT("BIT","01"), -CharacterSet::CHAR("CHAR",{{ 1, 127}}), CharacterSet::CR("CR","\r"), +CharacterSet::LF("LF","\n"), CharacterSet::CRLF("CRLF","\r\n"), CharacterSet::DIGIT("DIGIT","0123456789"), CharacterSet::DQUOTE("DQUOTE","\""), CharacterSet::HTAB("HTAB","\t"), CharacterSet::HEXDIG("HEXDIG","0123456789aAbBcCdDeEfF"), CharacterSet::SP("SP"," "), -CharacterSet::VCHAR("VCHAR",{{ 0x21, 0x7e }} ), +CharacterSet::VCHAR("VCHAR", 0x21, 0x7e), CharacterSet::WSP("WSP"," \t"), CharacterSet::TCHAR("TCHAR","!#$%&'*+-.^_`|~0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), CharacterSet::SPECIAL("SPECIAL","()<>@,;:\\\"/[]?={}") //,CharacterSet::QDTEXT("QDTEXT",{{9,9},{0x20,0x21},{0x23,0x5b},{0x5d,0x7e},{0x80,0xff}}) -//,CharacterSet::OBSTEXT("OBSTEXT",{{0x80,0xff}}) +//,CharacterSet::OBSTEXT("OBSTEXT",0x80,0xff) ; diff --git a/src/base/CharacterSet.h b/src/base/CharacterSet.h index 569ea84527..2d8088ab62 100644 --- a/src/base/CharacterSet.h +++ b/src/base/CharacterSet.h @@ -8,7 +8,6 @@ class CharacterSet { public: typedef std::vector Storage; - typedef std::vector > RangeSpec; /// define a character set with the given label ("anonymous" if NULL) /// with specified initial contents @@ -17,7 +16,7 @@ public: /// define a character set with the given label ("anonymous" if NULL) /// containing characters defined in the supplied ranges /// \see addRange - CharacterSet(const char *label, const RangeSpec &); + CharacterSet(const char *label, unsigned char low, unsigned char high); /// whether a given character exists in the set bool operator[](unsigned char c) const {return chars_[static_cast(c)] != 0;} @@ -25,12 +24,8 @@ public: /// add a given character to the character set CharacterSet & add(const unsigned char c); - /** add a list of character ranges, expressed as pairs [low,high] - * - * Both ends of the specified ranges are included in the added set - * e.g. addRange(RangeSpec( { { '0','9'}, { 'a', 'z' } ) ) - */ - CharacterSet & addRange(const RangeSpec &); + /// add a list of character ranges, expressed as pairs [low,high], including both ends + CharacterSet & addRange(unsigned char low, unsigned char high); /// add all characters from the given CharacterSet to this one CharacterSet &operator +=(const CharacterSet &src); @@ -46,10 +41,10 @@ public: static const CharacterSet ALPHA; // 0-1 static const CharacterSet BIT; - // any 7-bit US-ASCII character, except for NUL - static const CharacterSet CHAR; // carriage return static const CharacterSet CR; + // line feed + static const CharacterSet LF; // CRLF static const CharacterSet CRLF; // double quote diff --git a/src/base/testCharacterSet.cc b/src/base/testCharacterSet.cc index 73df3d774a..c1b71d3c3e 100644 --- a/src/base/testCharacterSet.cc +++ b/src/base/testCharacterSet.cc @@ -46,7 +46,7 @@ void testCharacterSet::CharacterSetAddRange() { CharacterSet t("test",""); - t.addRange(CharacterSet::RangeSpec( { { '0','9'} } ) ); + t.addRange('0','9'); CPPUNIT_ASSERT_EQUAL(true,t['0']); CPPUNIT_ASSERT_EQUAL(true,t['5']); CPPUNIT_ASSERT_EQUAL(true,t['9']);