diff options
| -rw-r--r-- | include/mruby.h | 2 | ||||
| -rw-r--r-- | src/string.c | 8 |
2 files changed, 6 insertions, 4 deletions
diff --git a/include/mruby.h b/include/mruby.h index 2f2f3753d..b741e6444 100644 --- a/include/mruby.h +++ b/include/mruby.h @@ -274,6 +274,8 @@ mrb_value mrb_check_funcall(mrb_state *mrb, mrb_value recv, mrb_sym mid, int arg #define ISALPHA(c) (ISASCII(c) && isalpha((int)(unsigned char)(c))) #define ISDIGIT(c) (ISASCII(c) && isdigit((int)(unsigned char)(c))) #define ISXDIGIT(c) (ISASCII(c) && isxdigit((int)(unsigned char)(c))) +#define TOUPPER(c) (ISASCII(c) ? toupper((int)(unsigned char)(c)) : (c)) +#define TOLOWER(c) (ISASCII(c) ? tolower((int)(unsigned char)(c)) : (c)) #endif mrb_value mrb_exc_new(mrb_state *mrb, struct RClass *c, const char *ptr, long len); diff --git a/src/string.c b/src/string.c index d8fe56790..7077e9dfd 100644 --- a/src/string.c +++ b/src/string.c @@ -866,12 +866,12 @@ mrb_str_capitalize_bang(mrb_state *mrb, mrb_value str) if (s->len == 0 || !s->ptr) return mrb_nil_value(); p = s->ptr; pend = s->ptr + s->len; if (ISLOWER(*p)) { - *p = toupper(*p); + *p = TOUPPER(*p); modify = 1; } while (++p < pend) { if (ISUPPER(*p)) { - *p = tolower(*p); + *p = TOLOWER(*p); modify = 1; } } @@ -1079,7 +1079,7 @@ mrb_str_downcase_bang(mrb_state *mrb, mrb_value str) pend = s->ptr + s->len; while (p < pend) { if (ISUPPER(*p)) { - *p = tolower(*p); + *p = TOLOWER(*p); modify = 1; } p++; @@ -2744,7 +2744,7 @@ mrb_str_upcase_bang(mrb_state *mrb, mrb_value str) pend = RSTRING_END(str); while (p < pend) { if (ISLOWER(*p)) { - *p = toupper(*p); + *p = TOUPPER(*p); modify = 1; } p++; |
