]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Reverted multi-ranges as they require c++0x initializers
authorFrancesco Chemolli <kinkie@squid-cache.org>
Mon, 30 Dec 2013 13:22:05 +0000 (14:22 +0100)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Mon, 30 Dec 2013 13:22:05 +0000 (14:22 +0100)
src/base/CharacterSet.cc
src/base/CharacterSet.h
src/base/testCharacterSet.cc

index 55a728b363d336665b0f878c313fdce9b4b60fc5..db9f31cd2441a40e8810b53f30c6466a39bc31d4 100644 (file)
@@ -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<uint8_t>(c)] = 1;
-            ++c;
-        }
+    while (low <= high) {
+        chars_[static_cast<uint8_t>(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)
 ;
index 569ea845272f71ca6115acb629ae4a145069630c..2d8088ab62ff0c1e0ad6047792f2a9968dabf316 100644 (file)
@@ -8,7 +8,6 @@ class CharacterSet
 {
 public:
     typedef std::vector<uint8_t> Storage;
-    typedef std::vector<std::pair<unsigned char, unsigned char> > 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<uint8_t>(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
index 73df3d774af2c551560cb57ab6d5a66f6509eb0c..c1b71d3c3e69b6220ea94f7c8099dcf1ed5fcacf 100644 (file)
@@ -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']);