diff options
| author | nyamatongwe <devnull@localhost> | 2001-04-29 13:32:10 +0000 | 
|---|---|---|
| committer | nyamatongwe <devnull@localhost> | 2001-04-29 13:32:10 +0000 | 
| commit | 09d42ffa21ce48f7ccd80c71674445bffe15cef1 (patch) | |
| tree | e5e81d31814afcd65759d81fd0ec7e375ca7603d /src/Document.cxx | |
| parent | 33ce86f2a9e5389f7dd9922eb387936b61364259 (diff) | |
| download | scintilla-mirror-09d42ffa21ce48f7ccd80c71674445bffe15cef1.tar.gz | |
Addition of new target methods - versions of ReplaceTarget that take counted
strings to allow for nulls, SearchInTarget and Get/SetSearchFlags to use a
series of calls rather than a structure.
Handling of \000 in search and replace.
Handling of /escapes within character ranges of regular expressions.
Some handling of bare ^ and $ regular expressions.
Diffstat (limited to 'src/Document.cxx')
| -rw-r--r-- | src/Document.cxx | 44 | 
1 files changed, 30 insertions, 14 deletions
| diff --git a/src/Document.cxx b/src/Document.cxx index 70ad061a5..ef9779016 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -826,7 +826,7 @@ long Document::FindText(int minPos, int maxPos, const char *s,  		startPos = MovePositionOutsideChar(startPos, 1, false);  		endPos = MovePositionOutsideChar(endPos, 1, false); -		const char *errmsg = pre->Compile(s, caseSensitive); +		const char *errmsg = pre->Compile(s, *length, caseSensitive);  		if (errmsg) {  			return -1;  		} @@ -841,6 +841,18 @@ long Document::FindText(int minPos, int maxPos, const char *s,  		char searchEnd = '\0';  		if (*s)  			searchEnd = s[strlen(s) - 1]; +		if (*length == 1) { +			// These produce empty selections so nudge them on if needed +			if (s[0] == '^') { +				if (startPos == LineStart(lineRangeStart)) +					startPos++; +			} else if (s[0] == '$') { +				if ((startPos == LineEnd(lineRangeStart)) && (lineRangeStart < lineRangeEnd)) +					startPos = LineStart(lineRangeStart+1); +			} +			lineRangeStart = LineFromPosition(startPos); +			lineRangeEnd = LineFromPosition(endPos); +		}  		for (int line = lineRangeStart; line <= lineRangeEnd; line++) {  			int startOfLine = LineStart(line);  			int endOfLine = LineEnd(line); @@ -855,7 +867,7 @@ long Document::FindText(int minPos, int maxPos, const char *s,  				endOfLine = endPos;  			}  			DocumentIndexer di(this, endOfLine); -			int success = pre->Execute(di, startOfLine); +			int success = pre->Execute(di, startOfLine, endOfLine);  			if (success) {  				pos = pre->bopat[0];  				lenRet = pre->eopat[0] - pre->bopat[0]; @@ -875,7 +887,9 @@ long Document::FindText(int minPos, int maxPos, const char *s,  		int endPos = MovePositionOutsideChar(maxPos, increment, false);  		// Compute actual search ranges needed -		int lengthFind = strlen(s); +		int lengthFind = *length; +		if (lengthFind == -1) +			lengthFind = strlen(s);  		int endSearch = endPos;  		if (startPos <= endPos) {  			endSearch = endPos - lengthFind + 1; @@ -929,7 +943,7 @@ long Document::FindText(int minPos, int maxPos, const char *s,  	return -1;  } -const char *Document::SubstituteByPosition(const char *text) { +const char *Document::SubstituteByPosition(const char *text, int *length) {  	if (!pre)  		return 0;  	delete []substituted; @@ -938,11 +952,11 @@ const char *Document::SubstituteByPosition(const char *text) {  	if (!pre->GrabMatches(di))  		return 0;  	unsigned int lenResult = 0; -	for (const char *t = text; *t; t++) { -		if ((*t == '\\') && (*(t + 1) >= '1' && *(t + 1) <= '9')) { -			unsigned int patNum = *(t + 1) - '0'; +	for (int i=0; i<*length; i++) { +		if ((text[i] == '\\') && (text[i+1] >= '1' && text[i+1] <= '9')) { +			unsigned int patNum = text[i+1] - '0';  			lenResult += pre->eopat[patNum] - pre->bopat[patNum]; -			t++; +			i++;  		} else {  			lenResult++;  		} @@ -951,18 +965,20 @@ const char *Document::SubstituteByPosition(const char *text) {  	if (!substituted)  		return 0;  	char *o = substituted; -	for (const char *s = text; *s; s++) { -		if ((*s == '\\') && (*(s + 1) >= '1' && *(s + 1) <= '9')) { -			unsigned int patNum = *(s + 1) - '0'; +	for (int j=0; j<*length; j++) { +		if ((text[j] == '\\') && (text[j+1] >= '1' && text[j+1] <= '9')) { +			unsigned int patNum = text[j+1] - '0';  			unsigned int len = pre->eopat[patNum] - pre->bopat[patNum]; -			strcpy(o, pre->pat[patNum]); +			if (pre->pat[patNum])	// Will be null if try for a match that did not occur +				memcpy(o, pre->pat[patNum], len);  			o += len; -			s++; +			j++;  		} else { -			*o++ = *s; +			*o++ = text[j];  		}  	}  	*o = '\0'; +	*length = lenResult;  	return substituted;  } | 
