* 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
parent ec0187ef15
commit f6fb4b3e8e
2 changed files with 25 additions and 19 deletions

View File

@ -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> Wed Nov 7 15:07:51 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* enum.c (enum_each_with_index): make different arrays at each * enum.c (enum_each_with_index): make different arrays at each
iteration. [ruby-dev:32181] 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 * eval.c: fix typo in invoke_method documentation

View File

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