diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-06-07 22:16:16 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-06-07 22:16:16 +0900 |
| commit | 32e450166fd495ef3c238cc5e49e444585f05f1a (patch) | |
| tree | 5f63aa97ebb4fa9134163e9dd4fab14c4ab34be8 /mrbgems/mruby-string-utf8 | |
| parent | b0c90141d97d8c44cd6778d9c47eb785e128b777 (diff) | |
| download | mruby-32e450166fd495ef3c238cc5e49e444585f05f1a.tar.gz mruby-32e450166fd495ef3c238cc5e49e444585f05f1a.zip | |
move STR_* macros to mruby/string.h with renaming
Diffstat (limited to 'mrbgems/mruby-string-utf8')
| -rw-r--r-- | mrbgems/mruby-string-utf8/src/string.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/mrbgems/mruby-string-utf8/src/string.c b/mrbgems/mruby-string-utf8/src/string.c index 37abd30d5..874fa8dbb 100644 --- a/mrbgems/mruby-string-utf8/src/string.c +++ b/mrbgems/mruby-string-utf8/src/string.c @@ -7,12 +7,6 @@ #include <ctype.h> #include <string.h> -#define STR_EMBED_P(s) ((s)->flags & MRB_STR_EMBED) -#define STR_EMBED_LEN(s)\ - (mrb_int)(((s)->flags & MRB_STR_EMBED_LEN_MASK) >> MRB_STR_EMBED_LEN_SHIFT) -#define STR_PTR(s) ((STR_EMBED_P(s)) ? (s)->as.ary : (s)->as.heap.ptr) -#define STR_LEN(s) ((STR_EMBED_P(s)) ? STR_EMBED_LEN(s) : (mrb_int)(s)->as.heap.len) - static const char utf8len_codepage[256] = { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, @@ -250,17 +244,17 @@ str_rindex(mrb_state *mrb, mrb_value str, mrb_value sub, mrb_int pos) mrb_int len = RSTRING_LEN(sub); /* substring longer than string */ - if (STR_LEN(ps) < len) return -1; - if (STR_LEN(ps) - pos < len) { - pos = STR_LEN(ps) - len; + if (RSTR_LEN(ps) < len) return -1; + if (RSTR_LEN(ps) - pos < len) { + pos = RSTR_LEN(ps) - len; } - sbeg = STR_PTR(ps); - s = STR_PTR(ps) + pos; + sbeg = RSTR_PTR(ps); + s = RSTR_PTR(ps) + pos; t = RSTRING_PTR(sub); if (len) { while (sbeg <= s) { if (memcmp(s, t, len) == 0) { - return s - STR_PTR(ps); + return s - RSTR_PTR(ps); } s--; } |
