Fix Regex::searchAll to behave like global modifier

This commit is contained in:
Felipe Zimmerle 2017-02-15 16:04:59 -03:00 committed by Felipe Zimmerle
parent 4d66481bfa
commit 7aae5dc183
No known key found for this signature in database
GPG Key ID: E6DFB08CE8B11277

View File

@ -72,15 +72,15 @@ Regex::~Regex() {
std::list<SMatch> Regex::searchAll(const std::string& s) {
int ovector[OVECCOUNT];
std::list<SMatch> retList;
int i;
const char *subject = s.c_str();
int rc;
const std::string tmpString = std::string(s.c_str(), s.size());
int ovector[OVECCOUNT];
int rc, i, offset = 0;
std::list<SMatch> retList;
do {
rc = pcre_exec(m_pc, m_pce, subject,
s.size(), 0, 0, ovector, OVECCOUNT);
s.size() - offset, offset, 0, ovector, OVECCOUNT);
for (i = 0; i < rc; i++) {
SMatch match;
@ -93,8 +93,10 @@ std::list<SMatch> Regex::searchAll(const std::string& s) {
match.match = std::string(tmpString, start, len);
match.m_offset = start;
match.m_length = len;
offset = start + len;
retList.push_front(match);
}
} while (rc > 0);
return retList;
}