diff --git a/string.c b/string.c index dfb38e4e98..3dab48c701 100644 --- a/string.c +++ b/string.c @@ -7580,13 +7580,14 @@ rb_str_tr(VALUE str, VALUE src, VALUE repl) return str; } -#define TR_TABLE_SIZE 257 +#define TR_TABLE_MAX (UCHAR_MAX+1) +#define TR_TABLE_SIZE (TR_TABLE_MAX+1) static void tr_setup_table(VALUE str, char stable[TR_TABLE_SIZE], int first, VALUE *tablep, VALUE *ctablep, rb_encoding *enc) { const unsigned int errc = -1; - char buf[256]; + char buf[TR_TABLE_MAX]; struct tr tr; unsigned int c; VALUE table = 0, ptable = 0; @@ -7600,26 +7601,26 @@ tr_setup_table(VALUE str, char stable[TR_TABLE_SIZE], int first, tr.p += l; } if (first) { - for (i=0; i<256; i++) { + for (i=0; i