1 #include "mystring.h"
2 #include <ctype.h>
3 
upper() const4 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(islower(*in)) {
12       *out = toupper(*in);
13       changed = true;
14     }
15     else
16       *out = *in;
17   if(!changed)
18     return *this;
19   else
20     return mystring(buf, length);
21 }
22