diff options
| author | Yukihiro Matsumoto <[email protected]> | 2012-04-20 22:25:04 +0900 |
|---|---|---|
| committer | Yukihiro Matsumoto <[email protected]> | 2012-04-20 22:25:04 +0900 |
| commit | 5622c977f441a91a7482d5956df96e60d71d90f9 (patch) | |
| tree | 675dae829232b63f635a532fc63f1a075fa916a8 /src/re.c | |
| parent | 673b3350feec30fc0ee6700da9baa441763c4c87 (diff) | |
| download | mruby-5622c977f441a91a7482d5956df96e60d71d90f9.tar.gz mruby-5622c977f441a91a7482d5956df96e60d71d90f9.zip | |
remove dependency to SIZEOF_VOIDP
Diffstat (limited to 'src/re.c')
| -rw-r--r-- | src/re.c | 49 |
1 files changed, 0 insertions, 49 deletions
@@ -1773,11 +1773,7 @@ static int pair_byte_cmp(const void *pair1, const void *pair2) { long diff = ((pair_t*)pair1)->byte_pos - ((pair_t*)pair2)->byte_pos; -#if SIZEOF_LONG > SIZEOF_INT return diff ? diff > 0 ? 1 : -1 : 0; -#else - return (int)diff; -#endif } static void @@ -2959,48 +2955,6 @@ mrb_backref_set(mrb_state *mrb, mrb_value val) #ifdef INCLUDE_ENCODING static inline long -mrb_memsearch_ss(const unsigned char *xs, long m, const unsigned char *ys, long n) -{ - const unsigned char *x = xs, *xe = xs + m; - const unsigned char *y = ys, *ye = ys + n; -#define SIZEOF_VOIDP 4 -#define SIZEOF_LONG 4 - -#ifndef VALUE_MAX -# if SIZEOF_VALUE == 8 -# define VALUE_MAX 0xFFFFFFFFFFFFFFFFULL -# elif SIZEOF_VALUE == 4 -# define VALUE_MAX 0xFFFFFFFFUL -# elif SIZEOF_LONG == SIZEOF_VOIDP -# define SIZEOF_VALUE 4 -# define VALUE_MAX 0xFFFFFFFFUL -# endif -#endif - int hx, hy, mask = VALUE_MAX >> ((SIZEOF_VALUE - m) * CHAR_BIT); - - if (m > SIZEOF_VALUE) - mrb_bug("!!too long pattern string!!"); - - /* Prepare hash value */ - for (hx = *x++, hy = *y++; x < xe; ++x, ++y) { - hx <<= CHAR_BIT; - hy <<= CHAR_BIT; - hx |= *x; - hy |= *y; - } - /* Searching */ - while (hx != hy) { - if (y == ye) - return -1; - hy <<= CHAR_BIT; - hy |= *y; - hy &= mask; - y++; - } - return y - ys - m; -} - -static inline long mrb_memsearch_qs(const unsigned char *xs, long m, const unsigned char *ys, long n) { const unsigned char *x = xs, *xe = xs + m; @@ -3094,9 +3048,6 @@ mrb_memsearch(mrb_state *mrb, const void *x0, int m, const void *y0, int n, mrb_ } return -1; } - else if (m <= SIZEOF_VALUE) { - return mrb_memsearch_ss(x0, m, y0, n); - } else if (enc == mrb_utf8_encoding(mrb)) { return mrb_memsearch_qs_utf8(x0, m, y0, n); } |
