]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/acl/IntRange.cc
SourceFormat Enforcement
[thirdparty/squid.git] / src / acl / IntRange.cc
index fb148298a05020d90cba201e9627918de1d52f17..557aa929a78ebffc33db8273efa38bfae9448721 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1996-2014 The Squid Software Foundation and contributors
+ * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
  *
  * Squid software is distributed under GPLv2+ license and includes
  * contributions from numerous individuals and organizations.
 #include "squid.h"
 #include "acl/IntRange.h"
 #include "cache_cf.h"
+#include "ConfigParser.h"
 #include "Debug.h"
+#include "fatal.h"
 #include "Parsing.h"
 
-/* explicit instantiation required for some systems */
-/** \cond AUTODOCS_IGNORE */
-template cbdata_type CbDataList< Range<int> >::CBDATA_CbDataList;
-/** \endcond */
-
 void
 ACLIntRange::parse()
 {
-    char *a;
-
-    while ((a = strtokFile())) {
+    while (char *a = ConfigParser::strtokFile()) {
         char *b = strchr(a, '-');
         unsigned short port1, port2;
 
@@ -41,9 +36,7 @@ ACLIntRange::parse()
             port2 = port1;
 
         if (port2 >= port1) {
-            RangeType temp (0,0);
-            temp.start = port1;
-            temp.end = port2+1;
+            RangeType temp(port1, port2+1);
             ranges.push_back(temp);
         } else {
             debugs(28, DBG_CRITICAL, "ACLIntRange::parse: Invalid port value");
@@ -61,12 +54,10 @@ ACLIntRange::empty() const
 bool
 ACLIntRange::match(int i)
 {
-    RangeType const toFind (i, i+1);
-    CbDataListIterator<RangeType> iter(ranges);
-
-    while (!iter.end()) {
-        const RangeType & element = iter.next();
-        RangeType result = element.intersection (toFind);
+    RangeType const toFind(i, i+1);
+    for (std::list<RangeType>::const_iterator iter = ranges.begin(); iter != ranges.end(); ++iter) {
+        const RangeType & element = *iter;
+        RangeType result = element.intersection(toFind);
 
         if (result.size())
             return true;
@@ -81,7 +72,7 @@ ACLIntRange::clone() const
     if (!ranges.empty())
         fatal("ACLIntRange::clone: attempt to clone used ACL");
 
-    return new ACLIntRange (*this);
+    return new ACLIntRange(*this);
 }
 
 ACLIntRange::~ACLIntRange()
@@ -91,11 +82,9 @@ SBufList
 ACLIntRange::dump() const
 {
     SBufList sl;
-    CbDataListIterator<RangeType> iter(ranges);
-
-    while (!iter.end()) {
+    for (std::list<RangeType>::const_iterator iter = ranges.begin(); iter != ranges.end(); ++iter) {
         SBuf sb;
-        const RangeType & element = iter.next();
+        const RangeType & element = *iter;
 
         if (element.size() == 1)
             sb.Printf("%d", element.start);