| changeset 0 | 6f7a81934006 |
| -1:000000000000 | 0:6f7a81934006 |
|---|---|
1 #include "mystring.h" |
|
2 |
|
3 mystring mystring::subst(char from, char to) const |
|
4 { |
|
5 const unsigned length = rep->length; |
|
6 char buf[length+1]; |
|
7 const char* in = rep->buf + length; |
|
8 bool changed = true; |
|
9 for(char* out = buf+length; out >= buf; in--, out--) |
|
10 if(*in == from) |
|
11 *out = to, changed = true; |
|
12 else |
|
13 *out = *in; |
|
14 if(!changed) |
|
15 return *this; |
|
16 else |
|
17 return mystring(buf, length); |
|
18 } |