downcase!()
public
Downcases the contents of str, returning nil if no
changes were made.
Show source
/*
* call-seq:
* str.downcase! => str or nil
*
* Downcases the contents of <i>str</i>, returning <code>nil</code> if no
* changes were made.
*/
static VALUE
rb_str_downcase_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 (ISUPPER(*s)) {
*s = tolower(*s);
modify = 1;
}
s++;
}
if (modify) return str;
return Qnil;
}