diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-03-25 09:20:04 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-03-25 09:20:04 +0000 |
commit | 73a184cc3a4ead8a3242a8f04c4e65fa99026eef (patch) | |
tree | 4c8bc8980cda61fe0f90a3630a4fc758bd74c7ec /string.c | |
parent | 0c9f66eb400a78ef2e201a30a3904f59033d0439 (diff) | |
download | ruby-73a184cc3a4ead8a3242a8f04c4e65fa99026eef.tar.gz |
* string.c (tr_setup_table): fix multiple non latin argument for
non latin (over 256 characters) tr-like methods.
[ruby-core:43371] [Bug #6167]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35127 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -5332,18 +5332,19 @@ tr_setup_table(VALUE str, char stable[TR_TABLE_SIZE], int first, else { VALUE key = UINT2NUM(c); - if (!table) { - table = rb_hash_new(); + if (!table && (first || *tablep || stable[256])) { if (cflag) { ptable = *ctablep; + table = ptable ? ptable : rb_hash_new(); *ctablep = table; } else { + table = rb_hash_new(); ptable = *tablep; *tablep = table; } } - if (!ptable || !NIL_P(rb_hash_aref(ptable, key))) { + if (table && (!ptable || (cflag ^ !NIL_P(rb_hash_aref(ptable, key))))) { rb_hash_aset(table, key, Qtrue); } } @@ -5351,6 +5352,9 @@ tr_setup_table(VALUE str, char stable[TR_TABLE_SIZE], int first, for (i=0; i<256; i++) { stable[i] = stable[i] && buf[i]; } + if (!table && !cflag) { + *tablep = 0; + } } |