From be2e93a378bd8e6f425185e80d106b26b7eb854a Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Sat, 4 May 2013 17:45:47 +1000 Subject: Replacing raw pointers and allocations with std::string. --- src/Document.cxx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/Document.cxx') diff --git a/src/Document.cxx b/src/Document.cxx index d5a677499..c290c9226 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -2227,15 +2227,14 @@ long BuiltinRegex::FindText(Document *doc, int minPos, int maxPos, const char *s const char *BuiltinRegex::SubstituteByPosition(Document *doc, const char *text, int *length) { substituted.clear(); DocumentIndexer di(doc, doc->Length()); - if (!search.GrabMatches(di)) - return 0; + search.GrabMatches(di); for (int j = 0; j < *length; j++) { if (text[j] == '\\') { if (text[j + 1] >= '0' && text[j + 1] <= '9') { unsigned int patNum = text[j + 1] - '0'; unsigned int len = search.eopat[patNum] - search.bopat[patNum]; - if (search.pat[patNum]) // Will be null if try for a match that did not occur - substituted.append(search.pat[patNum], len); + if (!search.pat[patNum].empty()) // Will be null if try for a match that did not occur + substituted.append(search.pat[patNum].c_str(), len); j++; } else { j++; -- cgit v1.2.3