* string.c (tr_setup_table, tr_trans): fix test failures in test/ruby/test_string.rb

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
davidflanagan 2007-11-07 22:07:13 +00:00
Родитель ec0187ef15
Коммит f6fb4b3e8e
2 изменённых файлов: 25 добавлений и 19 удалений

Просмотреть файл

@ -1,9 +1,13 @@
Thu Nov 8 07:04:31 UTC 2007 David Flanagan <davidflanagan@ruby-lang.org>
* string.c (tr_setup_table, tr_trans): fix test failures
in test/ruby/test_string.rb
Wed Nov 7 15:07:51 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* enum.c (enum_each_with_index): make different arrays at each
iteration. [ruby-dev:32181]
Tue Nov 7 05:17:24 2007 David Flanagan <davidflanagan@ruby-lang.org>
Wed Nov 7 05:17:24 2007 David Flanagan <davidflanagan@ruby-lang.org>
* eval.c: fix typo in invoke_method documentation

Просмотреть файл

@ -3450,10 +3450,10 @@ tr_trans(VALUE str, VALUE src, VALUE repl, int sflag)
tlen = rb_enc_codelen(c, enc);
modify = 1;
}
}
else if (cflag) {
save = c = last;
modify = 1;
else {
save = c = last;
modify = 1;
}
}
else {
save = -1;
@ -3482,10 +3482,10 @@ tr_trans(VALUE str, VALUE src, VALUE repl, int sflag)
*s = c;
modify = 1;
}
}
else if (cflag) {
*s = last;
modify = 1;
else {
*s = last;
modify = 1;
}
}
s++;
}
@ -3513,10 +3513,10 @@ tr_trans(VALUE str, VALUE src, VALUE repl, int sflag)
tlen = rb_enc_codelen(c, enc);
modify = 1;
}
}
else if (cflag) {
c = last;
modify = 1;
else {
c = last;
modify = 1;
}
}
while (t - buf + tlen >= max) {
offset = t - buf;
@ -3585,7 +3585,7 @@ rb_str_tr(VALUE str, VALUE src, VALUE repl)
}
static void
tr_setup_table(VALUE str, char stable[256],
tr_setup_table(VALUE str, char stable[256], int first,
VALUE *tablep, VALUE *ctablep, rb_encoding *enc)
{
char buf[256];
@ -3601,8 +3601,10 @@ tr_setup_table(VALUE str, char stable[256],
cflag = 1;
tr.p++;
}
for (i=0; i<256; i++) {
stable[i] = 1;
if (first) {
for (i=0; i<256; i++) {
stable[i] = 1;
}
}
for (i=0; i<256; i++) {
buf[i] = cflag;
@ -3680,7 +3682,7 @@ rb_str_delete_bang(int argc, VALUE *argv, VALUE str)
StringValue(s);
enc = rb_enc_check(str, s);
tr_setup_table(s, squeez, &del, &nodel, enc);
tr_setup_table(s, squeez, i==0, &del, &nodel, enc);
}
rb_str_modify(str);
@ -3758,7 +3760,7 @@ rb_str_squeeze_bang(int argc, VALUE *argv, VALUE str)
StringValue(s);
enc = rb_enc_check(str, s);
tr_setup_table(s, squeez, &del, &nodel, enc);
tr_setup_table(s, squeez, i==0, &del, &nodel, enc);
}
}
@ -3883,7 +3885,7 @@ rb_str_count(int argc, VALUE *argv, VALUE str)
StringValue(s);
enc = rb_enc_check(str, s);
tr_setup_table(s, table, &del, &nodel, enc);
tr_setup_table(s, table,i==0, &del, &nodel, enc);
}
s = RSTRING_PTR(str);