summaryrefslogtreecommitdiffhomepage
path: root/src/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/string.c')
-rw-r--r--src/string.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/string.c b/src/string.c
index a9e0fca13..c9fac896d 100644
--- a/src/string.c
+++ b/src/string.c
@@ -927,6 +927,20 @@ mrb_str_chop(mrb_state *mrb, mrb_value self)
static mrb_value
mrb_str_downcase_bang(mrb_state *mrb, mrb_value str)
{
+ char *s, *send;
+ int modify = 0;
+
+ s = RSTRING_PTR(str);
+ send = RSTRING_END(str);
+ while (s < send) {
+ if (ISUPPER(*s)) {
+ *s = tolower(*s);
+ modify = 1;
+ }
+ s++;
+ }
+
+ if (modify) return str;
return mrb_nil_value();
}