upcase!()
public
Upcases the contents of str, returning nil if no changes
were made.
Show source
/*
* call-seq:
* str.upcase! => str or nil
*
* Upcases the contents of <i>str</i>, returning <code>nil</code> if no changes
* were made.
*/
static VALUE
rb_str_upcase_bang(str)
VALUE str;
{
char *s, *send;
int modify = 0;
rb_str_modify(str);
s = RSTRING(str)->ptr; send = s + RSTRING(str)->len;
while (s < send) {
if (ismbchar(*s)) {
s+=mbclen(*s) - 1;
}
else if (ISLOWER(*s)) {
*s = toupper(*s);
modify = 1;
}
s++;
}
if (modify) return str;
return Qnil;
}