diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-03-05 21:51:44 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-03-05 21:51:44 +0900 |
| commit | adc5b56c157a5572f10d8dfeb74e7dfc57038d58 (patch) | |
| tree | 3f4dc2e001d18cea2b4416b5de96d8537a78e315 /mrbgems/mruby-string-utf8/src/string.c | |
| parent | 640efb30158a5ae0ca458f0b28f5b64be80dcd05 (diff) | |
| download | mruby-adc5b56c157a5572f10d8dfeb74e7dfc57038d58.tar.gz mruby-adc5b56c157a5572f10d8dfeb74e7dfc57038d58.zip | |
use mrb_int instead of size_t since string length is represented by mrb_int; close #1810
Diffstat (limited to 'mrbgems/mruby-string-utf8/src/string.c')
| -rw-r--r-- | mrbgems/mruby-string-utf8/src/string.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/mrbgems/mruby-string-utf8/src/string.c b/mrbgems/mruby-string-utf8/src/string.c index 4f3833944..91183f7b8 100644 --- a/mrbgems/mruby-string-utf8/src/string.c +++ b/mrbgems/mruby-string-utf8/src/string.c @@ -19,11 +19,11 @@ static const char utf8len_codepage[256] = 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,1,1,1,1,1,1,1,1,1,1,1, }; -static size_t +static mrb_int utf8len(unsigned char* p) { - size_t len; - int i; + mrb_int len; + int i; if (*p == 0) return 1; @@ -34,10 +34,10 @@ utf8len(unsigned char* p) return len; } -static size_t +static mrb_int mrb_utf8_strlen(mrb_value str) { - size_t total = 0; + mrb_int total = 0; unsigned char* p = (unsigned char*) RSTRING_PTR(str); unsigned char* e = p + RSTRING_LEN(str); while (p<e) { @@ -50,7 +50,7 @@ mrb_utf8_strlen(mrb_value str) static mrb_value mrb_str_size(mrb_state *mrb, mrb_value str) { - size_t size = mrb_utf8_strlen(str); + mrb_int size = mrb_utf8_strlen(str); return mrb_fixnum_value(size); } @@ -136,7 +136,7 @@ static mrb_value str_substr(mrb_state *mrb, mrb_value str, mrb_int beg, mrb_int len) { mrb_value str2; - int len8 = RSTRING_LEN_UTF8(str); + mrb_int len8 = RSTRING_LEN_UTF8(str); if (len < 0) return mrb_nil_value(); if (len8 == 0) { @@ -250,10 +250,10 @@ mrb_str_aref_m(mrb_state *mrb, mrb_value str) static mrb_value mrb_str_reverse_bang(mrb_state *mrb, mrb_value str) { - int utf8_len = mrb_utf8_strlen(str); + mrb_int utf8_len = mrb_utf8_strlen(str); if (utf8_len > 1) { - int len = RSTRING_LEN(str); - char *buf = (char *)mrb_malloc(mrb, len); + mrb_int len = RSTRING_LEN(str); + char *buf = (char *)mrb_malloc(mrb, (size_t)len); unsigned char* p = (unsigned char*)buf; unsigned char* e = (unsigned char*)buf + len; unsigned char* r = (unsigned char*)RSTRING_END(str); @@ -262,7 +262,7 @@ mrb_str_reverse_bang(mrb_state *mrb, mrb_value str) mrb_str_modify(mrb, mrb_str_ptr(str)); while (p<e) { - int clen = utf8len(p); + mrb_int clen = utf8len(p); r -= clen; memcpy(r, p, clen); p += clen; @@ -284,7 +284,7 @@ mrb_fixnum_chr(mrb_state *mrb, mrb_value num) { mrb_int cp = mrb_fixnum(num); char utf8[4]; - int len; + mrb_int len; if (cp < 0 || 0x10FFFF < cp) { mrb_raisef(mrb, E_RANGE_ERROR, "%S out of char range", num); |
