From: Amos Jeffries Date: Mon, 27 Jul 2015 05:21:06 +0000 (-0700) Subject: Shuffle RegexList.* to base/libbase RegexPattern.* X-Git-Tag: merge-candidate-3-v1~24^2~2^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8fcefb306298d6c81acf3bd989bef3eba11e6ebc;p=thirdparty%2Fsquid.git Shuffle RegexList.* to base/libbase RegexPattern.* Split the core regex pattern data fields out into a class RegexPattern for as a container node use in std::list or other constructions. Leave the custom linked-list operations under the name RegexList. As a child wrapper class for now so that old API members are still available. --- diff --git a/src/Makefile.am b/src/Makefile.am index c1c9668cda..9e5e6086eb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -985,8 +985,6 @@ tests_testHttpReply_SOURCES=\ HttpReply.h \ MasterXaction.cc \ MasterXaction.h \ - RegexList.h \ - RegexList.cc \ MemBuf.cc \ MemBuf.h \ mime_header.h \ diff --git a/src/RegexList.h b/src/RegexList.h deleted file mode 100644 index fe783b81e8..0000000000 --- a/src/RegexList.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 1996-2015 The Squid Software Foundation and contributors - * - * Squid software is distributed under GPLv2+ license and includes - * contributions from numerous individuals and organizations. - * Please see the COPYING and CONTRIBUTORS files for details. - */ - -#ifndef SQUID_REGEXLIST_H_ -#define SQUID_REGEXLIST_H_ - -#include "mem/forward.h" - -#include - -/// list of regular expressions. -class RegexList -{ - MEMPROXY_CLASS(RegexList); - -public: - RegexList() = delete; - RegexList(int aFlags, const char *aPattern) : flags(aFlags), pattern(xstrdup(aPattern)), next(nullptr) {} - RegexList(const RegexList &) = delete; - RegexList(const RegexList && o) = delete; - ~RegexList(); - - int flags; - char *pattern; - regex_t regex; - RegexList *next; -}; - -#endif /* SQUID_REGEXLIST_H_ */ - diff --git a/src/acl/RegexData.cc b/src/acl/RegexData.cc index 82b8b37d6e..52c83811d1 100644 --- a/src/acl/RegexData.cc +++ b/src/acl/RegexData.cc @@ -18,9 +18,9 @@ #include "acl/Acl.h" #include "acl/Checklist.h" #include "acl/RegexData.h" +#include "base/RegexPattern.h" #include "ConfigParser.h" #include "Debug.h" -#include "RegexList.h" #include "wordlist.h" ACLRegexData::~ACLRegexData() diff --git a/src/base/Makefile.am b/src/base/Makefile.am index 8643df4da2..72643db253 100644 --- a/src/base/Makefile.am +++ b/src/base/Makefile.am @@ -27,6 +27,8 @@ libbase_la_SOURCES = \ Lock.h \ LruMap.h \ Packable.h \ + RegexPattern.cc \ + RegexPattern.h \ RunnersRegistry.cc \ RunnersRegistry.h \ Subscription.h \ diff --git a/src/RegexList.cc b/src/base/RegexPattern.cc similarity index 89% rename from src/RegexList.cc rename to src/base/RegexPattern.cc index 13de2d0f08..37018d4804 100644 --- a/src/RegexList.cc +++ b/src/base/RegexPattern.cc @@ -7,13 +7,16 @@ */ #include "squid.h" -#include "RegexList.h" +#include "base/RegexPattern.h" -RegexList::~RegexList() +RegexPattern::~RegexPattern() { xfree(pattern); regfree(®ex); +} +RegexList::~RegexList() +{ // lists could be very long // iterate instead of recursing for (auto p = next; p; p = next) { diff --git a/src/base/RegexPattern.h b/src/base/RegexPattern.h new file mode 100644 index 0000000000..eb2fdd5d45 --- /dev/null +++ b/src/base/RegexPattern.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) 1996-2015 The Squid Software Foundation and contributors + * + * Squid software is distributed under GPLv2+ license and includes + * contributions from numerous individuals and organizations. + * Please see the COPYING and CONTRIBUTORS files for details. + */ + +#ifndef SQUID_SRC_BASE_REGEXPATTERN_H +#define SQUID_SRC_BASE_REGEXPATTERN_H + +#include "mem/forward.h" + +/** + * A regular expression, + * plain text and compiled representations + */ +class RegexPattern +{ + MEMPROXY_CLASS(RegexPattern); + +public: + RegexPattern() = delete; + RegexPattern(int aFlags, const char *aPattern) : flags(aFlags), pattern(xstrdup(aPattern)) {} + RegexPattern(const RegexPattern &) = delete; + RegexPattern(const RegexPattern && o) = delete; + ~RegexPattern(); + + int flags; + char *pattern; + regex_t regex; +}; + +/// list of regular expressions. +/// \deprecated use a std::list instead +class RegexList : public RegexPattern +{ + MEMPROXY_CLASS(RegexList); + +public: + RegexList() = delete; + RegexList(int aFlags, const char *aPattern) : RegexPattern(aFlags, aPattern), next(nullptr) {} + RegexList(const RegexList &) = delete; + RegexList(const RegexList && o) = delete; + ~RegexList(); + + RegexList *next; +}; + +#endif /* SQUID_SRC_BASE_REGEXPATTERN_H */ + diff --git a/src/mem/old_api.cc b/src/mem/old_api.cc index d154fba8a9..b01a2f3138 100644 --- a/src/mem/old_api.cc +++ b/src/mem/old_api.cc @@ -23,7 +23,6 @@ #include "MemBuf.h" #include "memMeter.h" #include "mgr/Registration.h" -#include "RegexList.h" #include "SquidConfig.h" #include "SquidList.h" #include "SquidTime.h"