aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornyamatongwe <devnull@localhost>2001-10-17 12:51:19 +0000
committernyamatongwe <devnull@localhost>2001-10-17 12:51:19 +0000
commit2c20ea6f04080f0ffb63ff9740a7fd25cd5625ac (patch)
tree5fe80d78aacfdf92c20af44a1a26f17aee135234
parent7f9c088f5457d11062659fe66a165e90e31b00f7 (diff)
downloadscintilla-mirror-2c20ea6f04080f0ffb63ff9740a7fd25cd5625ac.tar.gz
substitute and remove(string) return the number of changes made.
-rw-r--r--include/SString.h14
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, "");
}
};