diff --git a/Foundation/include/Poco/RegularExpression.h b/Foundation/include/Poco/RegularExpression.h index e891011da..99c7b11a2 100644 --- a/Foundation/include/Poco/RegularExpression.h +++ b/Foundation/include/Poco/RegularExpression.h @@ -27,20 +27,6 @@ #include -#if defined(POCO_UNBUNDLED) -#include -#else -// -// Copy these definitions from pcre.h -// to avoid pulling in the entire header file -// -extern "C" -{ - typedef struct real_pcre8_or_16 pcre; - struct pcre_extra; -} -#endif - namespace Poco { @@ -211,8 +197,10 @@ protected: std::string::size_type substOne(std::string& subject, std::string::size_type offset, const std::string& replacement, int options) const; private: - pcre* _pcre; - pcre_extra* _extra; + // Note: to avoid a dependency on the pcre.h header the following are + // declared as void* and casted to the correct type in the implementation file. + void* _pcre; // Actual type is pcre* + void* _extra; // Actual type is struct pcre_extra* static const int OVEC_SIZE; diff --git a/Foundation/src/RegularExpression.cpp b/Foundation/src/RegularExpression.cpp index 1fb0bdee9..2bc60a226 100644 --- a/Foundation/src/RegularExpression.cpp +++ b/Foundation/src/RegularExpression.cpp @@ -43,14 +43,14 @@ RegularExpression::RegularExpression(const std::string& pattern, int options, bo throw RegularExpressionException(msg.str()); } if (study) - _extra = pcre_study(_pcre, 0, &error); + _extra = pcre_study(reinterpret_cast(_pcre), 0, &error); } RegularExpression::~RegularExpression() { - if (_pcre) pcre_free(_pcre); - if (_extra) pcre_free(_extra); + if (_pcre) pcre_free(reinterpret_cast(_pcre)); + if (_extra) pcre_free(reinterpret_cast(_extra)); } @@ -59,7 +59,7 @@ int RegularExpression::match(const std::string& subject, std::string::size_type poco_assert (offset <= subject.length()); int ovec[OVEC_SIZE]; - int rc = pcre_exec(_pcre, _extra, subject.c_str(), int(subject.size()), int(offset), options & 0xFFFF, ovec, OVEC_SIZE); + int rc = pcre_exec(reinterpret_cast(_pcre), reinterpret_cast(_extra), subject.c_str(), int(subject.size()), int(offset), options & 0xFFFF, ovec, OVEC_SIZE); if (rc == PCRE_ERROR_NOMATCH) { mtch.offset = std::string::npos; @@ -93,7 +93,7 @@ int RegularExpression::match(const std::string& subject, std::string::size_type matches.clear(); int ovec[OVEC_SIZE]; - int rc = pcre_exec(_pcre, _extra, subject.c_str(), int(subject.size()), int(offset), options & 0xFFFF, ovec, OVEC_SIZE); + int rc = pcre_exec(reinterpret_cast(_pcre), reinterpret_cast(_extra), subject.c_str(), int(subject.size()), int(offset), options & 0xFFFF, ovec, OVEC_SIZE); if (rc == PCRE_ERROR_NOMATCH) { return 0; @@ -206,7 +206,7 @@ std::string::size_type RegularExpression::substOne(std::string& subject, std::st if (offset >= subject.length()) return std::string::npos; int ovec[OVEC_SIZE]; - int rc = pcre_exec(_pcre, _extra, subject.c_str(), int(subject.size()), int(offset), options & 0xFFFF, ovec, OVEC_SIZE); + int rc = pcre_exec(reinterpret_cast(_pcre), reinterpret_cast(_extra), subject.c_str(), int(subject.size()), int(offset), options & 0xFFFF, ovec, OVEC_SIZE); if (rc == PCRE_ERROR_NOMATCH) { return std::string::npos;