File: upper.cc

package info (click to toggle)
nullmailer 1%3A1.03-4
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,524 kB
  • ctags: 695
  • sloc: cpp: 4,484; sh: 4,123; makefile: 224; perl: 184
file content (21 lines) | stat: -rw-r--r-- 439 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "mystring.h"
#include <ctype.h>
			
mystring mystring::upper() const
{
  const unsigned length = rep->length;
  char buf[length+1];
  const char* in = rep->buf + length;
  bool changed = false;
  for(char* out = buf+length; out >= buf; in--, out--)
    if(isupper(*in)) {
      *out = tolower(*in);
      changed = true;
    }
    else
      *out = *in;
  if(!changed)
    return *this;
  else
    return mystring(buf, length);
}