| author | "Tomas Zeman <tzeman@volny.cz>" |
| Wed, 16 Jan 2008 22:39:43 +0100 | |
| changeset 0 | 6f7a81934006 |
| permissions | -rw-r--r-- |
| 0 | 1 |
#include "mystring.h" |
2 |
#include <ctype.h> |
|
3 |
||
4 |
mystring mystring::upper() const |
|
5 |
{
|
|
6 |
const unsigned length = rep->length; |
|
7 |
char buf[length+1]; |
|
8 |
const char* in = rep->buf + length; |
|
9 |
bool changed = false; |
|
10 |
for(char* out = buf+length; out >= buf; in--, out--) |
|
11 |
if(isupper(*in)) {
|
|
12 |
*out = tolower(*in); |
|
13 |
changed = true; |
|
14 |
} |
|
15 |
else |
|
16 |
*out = *in; |
|
17 |
if(!changed) |
|
18 |
return *this; |
|
19 |
else |
|
20 |
return mystring(buf, length); |
|
21 |
} |