From 8bc9c724d51312906be6e965b45a7bc071cfb931 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 26 Jul 2007 22:05:56 +0000 Subject: Work around the fact that we may have regex support without having regex.h (e.g. from pcreposix.h/libpcreposix) and disabuse HAVE_REGEX_H, define and use HAVE_REGEX_SUPPORT instead, thanks Gary! (refs #3, merges [1677] [1678] [1679]) --- lib/common/BoxConfig-MSVC.h | 1 + lib/common/ExcludeList.cpp | 27 ++++++++++++++------------- lib/common/ExcludeList.h | 4 ++-- 3 files changed, 17 insertions(+), 15 deletions(-) (limited to 'lib') diff --git a/lib/common/BoxConfig-MSVC.h b/lib/common/BoxConfig-MSVC.h index 0f84f964..6ce496f5 100644 --- a/lib/common/BoxConfig-MSVC.h +++ b/lib/common/BoxConfig-MSVC.h @@ -178,6 +178,7 @@ /* Define to 1 if you have the header file. */ /* #undef HAVE_REGEX_H */ #define HAVE_PCREPOSIX_H 1 +#define HAVE_REGEX_SUPPORT 1 /* Define to 1 if you have the `setproctitle' function. */ /* #undef HAVE_SETPROCTITLE */ diff --git a/lib/common/ExcludeList.cpp b/lib/common/ExcludeList.cpp index a8d07dcc..b9f41634 100644 --- a/lib/common/ExcludeList.cpp +++ b/lib/common/ExcludeList.cpp @@ -9,11 +9,12 @@ #include "Box.h" -#ifdef HAVE_PCREPOSIX_H - #include - #define EXCLUDELIST_IMPLEMENTATION_REGEX_T_DEFINED -#elif defined HAVE_REGEX_H - #include +#ifdef HAVE_REGEX_SUPPORT + #ifdef HAVE_PCREPOSIX_H + #include + #else + #include + #endif #define EXCLUDELIST_IMPLEMENTATION_REGEX_T_DEFINED #endif @@ -49,7 +50,7 @@ ExcludeList::ExcludeList() // -------------------------------------------------------------------------- ExcludeList::~ExcludeList() { -#ifdef HAVE_REGEX_H +#ifdef HAVE_REGEX_SUPPORT // free regex memory while(mRegex.size() > 0) { @@ -167,7 +168,7 @@ void ExcludeList::AddDefiniteEntries(const std::string &rEntries) // -------------------------------------------------------------------------- void ExcludeList::AddRegexEntries(const std::string &rEntries) { -#ifdef HAVE_REGEX_H +#ifdef HAVE_REGEX_SUPPORT // Split strings up std::vector ens; @@ -252,7 +253,7 @@ bool ExcludeList::IsExcluded(const std::string &rTest) const } // Check against regular expressions -#ifdef HAVE_REGEX_H +#ifdef HAVE_REGEX_SUPPORT for(std::vector::const_iterator i(mRegex.begin()); i != mRegex.end(); ++i) { // Test against this expression @@ -308,7 +309,7 @@ void ExcludeList::Deserialize(Archive & rArchive) // mDefinite.clear(); -#ifdef HAVE_REGEX_H +#ifdef HAVE_REGEX_SUPPORT // free regex memory while(mRegex.size() > 0) { @@ -349,7 +350,7 @@ void ExcludeList::Deserialize(Archive & rArchive) // // // -#ifdef HAVE_REGEX_H +#ifdef HAVE_REGEX_SUPPORT rArchive.Read(iCount); if (iCount > 0) @@ -386,7 +387,7 @@ void ExcludeList::Deserialize(Archive & rArchive) } } } -#endif // HAVE_REGEX_H +#endif // HAVE_REGEX_SUPPORT // // @@ -441,7 +442,7 @@ void ExcludeList::Serialize(Archive & rArchive) const // // // -#ifdef HAVE_REGEX_H +#ifdef HAVE_REGEX_SUPPORT // don't even try to save compiled regular expressions, // use string copies instead. ASSERT(mRegex.size() == mRegexStr.size()); @@ -454,7 +455,7 @@ void ExcludeList::Serialize(Archive & rArchive) const { rArchive.Write(*i); } -#endif // HAVE_REGEX_H +#endif // HAVE_REGEX_SUPPORT // // diff --git a/lib/common/ExcludeList.h b/lib/common/ExcludeList.h index 522ee370..3c41bd11 100644 --- a/lib/common/ExcludeList.h +++ b/lib/common/ExcludeList.h @@ -50,7 +50,7 @@ public: // Mainly for tests unsigned int SizeOfDefiniteList() const {return mDefinite.size();} unsigned int SizeOfRegexList() const -#ifdef HAVE_REGEX_H +#ifdef HAVE_REGEX_SUPPORT {return mRegex.size();} #else {return 0;} @@ -58,7 +58,7 @@ public: private: std::set mDefinite; -#ifdef HAVE_REGEX_H +#ifdef HAVE_REGEX_SUPPORT std::vector mRegex; std::vector mRegexStr; // save original regular expression string-based source for Serialize #endif -- cgit v1.2.3