diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-08-30 19:45:30 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-08-30 19:45:30 +0000 |
commit | d074ef4d60e389348d10dd1d81e76634c17acb2d (patch) | |
tree | f11e712b6564846cfda612cba73797920a59e224 /string.c | |
parent | 16ceba03968244e64e015965c2f3ec6a8f1836fb (diff) | |
download | ruby-d074ef4d60e389348d10dd1d81e76634c17acb2d.tar.gz |
* string.c (tr_setup_table): fix bug in r29146.
Initialize table even if cflag is 0; tr_find see whether
del is empty or not.
* string.c (tr_find): nodel can't be NULL; if NULL, it means
it is not specified.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29148 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -5095,6 +5095,11 @@ tr_setup_table(VALUE str, char stable[256], int first, ptable = *ctablep; *ctablep = table; } + else { + table = rb_hash_new(); + ptable = *tablep; + *tablep = table; + } if (first) { for (i=0; i<256; i++) { stable[i] = 1; @@ -5113,10 +5118,8 @@ tr_setup_table(VALUE str, char stable[256], int first, if (!table) { table = rb_hash_new(); - if (!cflag) { - ptable = *tablep; - *tablep = table; - } + ptable = *tablep; + *tablep = table; } if (!ptable || !NIL_P(rb_hash_aref(ptable, key))) { rb_hash_aset(table, key, Qtrue); @@ -5144,7 +5147,7 @@ tr_find(unsigned int c, char table[256], VALUE del, VALUE nodel) return TRUE; } } - else if (!nodel || NIL_P(rb_hash_lookup(nodel, v))) { + else if (nodel && NIL_P(rb_hash_lookup(nodel, v))) { return TRUE; } return FALSE; |