Commit c6551e03 authored by Jun Hiroe's avatar Jun Hiroe

Refactor mrb_str_capitalize_bang()

parent 5921dd19
...@@ -914,7 +914,7 @@ static mrb_value ...@@ -914,7 +914,7 @@ static mrb_value
mrb_str_capitalize_bang(mrb_state *mrb, mrb_value str) mrb_str_capitalize_bang(mrb_state *mrb, mrb_value str)
{ {
char *p, *pend; char *p, *pend;
int modify = 0; mrb_bool modify = FALSE;
struct RString *s = mrb_str_ptr(str); struct RString *s = mrb_str_ptr(str);
mrb_str_modify(mrb, s); mrb_str_modify(mrb, s);
...@@ -922,12 +922,12 @@ mrb_str_capitalize_bang(mrb_state *mrb, mrb_value str) ...@@ -922,12 +922,12 @@ mrb_str_capitalize_bang(mrb_state *mrb, mrb_value str)
p = STR_PTR(s); pend = STR_PTR(s) + STR_LEN(s); p = STR_PTR(s); pend = STR_PTR(s) + STR_LEN(s);
if (ISLOWER(*p)) { if (ISLOWER(*p)) {
*p = TOUPPER(*p); *p = TOUPPER(*p);
modify = 1; modify = TRUE;
} }
while (++p < pend) { while (++p < pend) {
if (ISUPPER(*p)) { if (ISUPPER(*p)) {
*p = TOLOWER(*p); *p = TOLOWER(*p);
modify = 1; modify = TRUE;
} }
} }
if (modify) return str; if (modify) return str;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment