diff options
| author | nyamatongwe <unknown> | 2001-10-17 12:51:19 +0000 | 
|---|---|---|
| committer | nyamatongwe <unknown> | 2001-10-17 12:51:19 +0000 | 
| commit | 1645932a6f5cbaae6370c423b3654dfeb411c445 (patch) | |
| tree | 5fe80d78aacfdf92c20af44a1a26f17aee135234 /include/SString.h | |
| parent | 6e2d1edc3531bfe6e470802c14db3e52d99b537a (diff) | |
| download | scintilla-mirror-1645932a6f5cbaae6370c423b3654dfeb411c445.tar.gz | |
substitute and remove(string) return the number of changes made.
Diffstat (limited to 'include/SString.h')
| -rw-r--r-- | include/SString.h | 14 | 
1 files changed, 10 insertions, 4 deletions
| diff --git a/include/SString.h b/include/SString.h index 6ae65806a..e0354f401 100644 --- a/include/SString.h +++ b/include/SString.h @@ -279,17 +279,21 @@ public:  	bool contains(const char *sFind) {  		return search(sFind) >= 0;  	} -	void substitute(char chFind, char chReplace) { +	int substitute(char chFind, char chReplace) { +		int c = 0;  		char *t = s;  		while (t) {  			t = strchr(t, chFind);  			if (t) {  				*t = chReplace;  				t++; +				c++;  			}  		} +		return c;  	} -	void substitute(const char *sFind, const char *sReplace) { +	int substitute(const char *sFind, const char *sReplace) { +		int c = 0;  		int lenFind = strlen(sFind);  		int lenReplace = strlen(sReplace);  		int posFound = search(sFind); @@ -297,10 +301,12 @@ public:  			remove(posFound, lenFind);  			insert(posFound, sReplace, lenReplace);  			posFound = search(sFind, posFound + lenReplace); +			c++;  		} +		return c;  	} -	void remove(const char *sFind) { -		substitute(sFind, ""); +	int remove(const char *sFind) { +		return substitute(sFind, "");  	}  }; | 
