aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Document.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/Document.cxx')
-rw-r--r--src/Document.cxx26
1 files changed, 11 insertions, 15 deletions
diff --git a/src/Document.cxx b/src/Document.cxx
index 2c04bbaae..5d9e10c40 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -3143,11 +3143,6 @@ bool MatchOnLines(const Document *doc, const Regex &regexp, const RESearchRange
for (size_t co = 0; co < match.size() && co < RESearch::MAXTAG; co++) {
search.bopat[co] = match[co].first.Pos();
search.eopat[co] = match[co].second.PosRoundUp();
- const Sci::Position lenMatch = search.eopat[co] - search.bopat[co];
- search.pat[co].resize(lenMatch);
- for (Sci::Position iPos = 0; iPos < lenMatch; iPos++) {
- search.pat[co][iPos] = doc->CharAt(iPos + search.bopat[co]);
- }
}
}
return matched;
@@ -3304,19 +3299,20 @@ Sci::Position BuiltinRegex::FindText(Document *doc, Sci::Position minPos, Sci::P
const char *BuiltinRegex::SubstituteByPosition(Document *doc, const char *text, Sci::Position *length) {
substituted.clear();
- const DocumentIndexer di(doc, doc->Length());
- search.GrabMatches(di);
for (Sci::Position j = 0; j < *length; j++) {
if (text[j] == '\\') {
- if (text[j + 1] >= '0' && text[j + 1] <= '9') {
- const unsigned int patNum = text[j + 1] - '0';
- const Sci::Position len = search.eopat[patNum] - search.bopat[patNum];
- 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++;
+ const char chNext = text[++j];
+ if (chNext >= '0' && chNext <= '9') {
+ const unsigned int patNum = chNext - '0';
+ const Sci::Position startPos = search.bopat[patNum];
+ const Sci::Position len = search.eopat[patNum] - startPos;
+ if (len > 0) { // Will be null if try for a match that did not occur
+ const size_t size = substituted.length();
+ substituted.resize(size + len);
+ doc->GetCharRange(substituted.data() + size, startPos, len);
+ }
} else {
- j++;
- switch (text[j]) {
+ switch (chNext) {
case 'a':
substituted.push_back('\a');
break;