mirror of
https://github.com/pocoproject/poco.git
synced 2025-04-24 00:57:06 +02:00
fixed GH #1581: Cannot find 'pcre.h' when using POCO_UNBUNDLED, a non-system PCRE, and CMake
Conflicts: Foundation/include/Poco/RegularExpression.h Foundation/src/RegularExpression.cpp
This commit is contained in:
parent
0fefd7d03a
commit
8557dc4469
@ -28,20 +28,6 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
|
||||||
#ifdef POCO_UNBUNDLED
|
|
||||||
#include <pcre.h>
|
|
||||||
#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 {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
@ -214,8 +200,10 @@ protected:
|
|||||||
std::string::size_type substOne(std::string& subject, std::string::size_type offset, const std::string& replacement, int options) const;
|
std::string::size_type substOne(std::string& subject, std::string::size_type offset, const std::string& replacement, int options) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
pcre* _pcre;
|
// Note: to avoid a dependency on the pcre.h header the following are
|
||||||
pcre_extra* _extra;
|
// 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*
|
||||||
|
|
||||||
GroupMap _groups;
|
GroupMap _groups;
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "pcre.h"
|
#include "pcre.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
@ -46,7 +47,7 @@ RegularExpression::RegularExpression(const std::string& pattern, int options, bo
|
|||||||
throw RegularExpressionException(msg.str());
|
throw RegularExpressionException(msg.str());
|
||||||
}
|
}
|
||||||
if (study)
|
if (study)
|
||||||
_extra = pcre_study(_pcre, 0, &error);
|
_extra = pcre_study(reinterpret_cast<pcre*>(_pcre), 0, &error);
|
||||||
|
|
||||||
pcre_fullinfo(_pcre, _extra, PCRE_INFO_NAMECOUNT, &nmcount);
|
pcre_fullinfo(_pcre, _extra, PCRE_INFO_NAMECOUNT, &nmcount);
|
||||||
pcre_fullinfo(_pcre, _extra, PCRE_INFO_NAMEENTRYSIZE, &nmentrysz);
|
pcre_fullinfo(_pcre, _extra, PCRE_INFO_NAMEENTRYSIZE, &nmentrysz);
|
||||||
@ -58,14 +59,13 @@ RegularExpression::RegularExpression(const std::string& pattern, int options, bo
|
|||||||
int n = pcre_get_stringnumber(_pcre, (char*) group);
|
int n = pcre_get_stringnumber(_pcre, (char*) group);
|
||||||
_groups[n] = std::string((char*) group);
|
_groups[n] = std::string((char*) group);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RegularExpression::~RegularExpression()
|
RegularExpression::~RegularExpression()
|
||||||
{
|
{
|
||||||
if (_pcre) pcre_free(_pcre);
|
if (_pcre) pcre_free(reinterpret_cast<pcre*>(_pcre));
|
||||||
if (_extra) pcre_free(_extra);
|
if (_extra) pcre_free(reinterpret_cast<struct pcre_extra*>(_extra));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ int RegularExpression::match(const std::string& subject, std::string::size_type
|
|||||||
poco_assert (offset <= subject.length());
|
poco_assert (offset <= subject.length());
|
||||||
|
|
||||||
int ovec[OVEC_SIZE];
|
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*>(_pcre), reinterpret_cast<struct pcre_extra*>(_extra), subject.c_str(), int(subject.size()), int(offset), options & 0xFFFF, ovec, OVEC_SIZE);
|
||||||
if (rc == PCRE_ERROR_NOMATCH)
|
if (rc == PCRE_ERROR_NOMATCH)
|
||||||
{
|
{
|
||||||
mtch.offset = std::string::npos;
|
mtch.offset = std::string::npos;
|
||||||
@ -108,7 +108,7 @@ int RegularExpression::match(const std::string& subject, std::string::size_type
|
|||||||
matches.clear();
|
matches.clear();
|
||||||
|
|
||||||
int ovec[OVEC_SIZE];
|
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*>(_pcre), reinterpret_cast<struct pcre_extra*>(_extra), subject.c_str(), int(subject.size()), int(offset), options & 0xFFFF, ovec, OVEC_SIZE);
|
||||||
if (rc == PCRE_ERROR_NOMATCH)
|
if (rc == PCRE_ERROR_NOMATCH)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
@ -230,7 +230,7 @@ std::string::size_type RegularExpression::substOne(std::string& subject, std::st
|
|||||||
if (offset >= subject.length()) return std::string::npos;
|
if (offset >= subject.length()) return std::string::npos;
|
||||||
|
|
||||||
int ovec[OVEC_SIZE];
|
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*>(_pcre), reinterpret_cast<struct pcre_extra*>(_extra), subject.c_str(), int(subject.size()), int(offset), options & 0xFFFF, ovec, OVEC_SIZE);
|
||||||
if (rc == PCRE_ERROR_NOMATCH)
|
if (rc == PCRE_ERROR_NOMATCH)
|
||||||
{
|
{
|
||||||
return std::string::npos;
|
return std::string::npos;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user