1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* string.c (tr_find): wrong condition fixed.

* sprintf.c (rb_str_format): check encoding based on result, not
  the format string.

* string.c (rb_str_upto): add encoding check.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2007-12-17 05:01:47 +00:00
parent 17f4486abc
commit 5a41626dea
3 changed files with 18 additions and 5 deletions

View file

@ -1,3 +1,12 @@
Mon Dec 17 13:56:53 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (tr_find): wrong condition fixed.
* sprintf.c (rb_str_format): check encoding based on result, not
the format string.
* string.c (rb_str_upto): add encoding check.
Mon Dec 17 12:21:25 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* Makefile.in (RUNRUBY): added RUNRUBYOPT.

View file

@ -296,6 +296,7 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
blen = 0;
bsiz = 120;
result = rb_str_buf_new(bsiz);
rb_enc_copy(result, fmt);
buf = RSTRING_PTR(result);
for (; p < end; p++) {
@ -459,7 +460,7 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
str = rb_obj_as_string(arg);
if (OBJ_TAINTED(str)) tainted = 1;
len = RSTRING_LEN(str);
enc = rb_enc_check(fmt, str);
enc = rb_enc_check(result, str);
if (flags&(FPREC|FWIDTH)) {
slen = rb_enc_strlen(RSTRING_PTR(str),RSTRING_END(str),enc);
if (slen < 0) {
@ -497,6 +498,7 @@ rb_str_format(int argc, const VALUE *argv, VALUE fmt)
}
}
PUSH(RSTRING_PTR(str), len);
rb_enc_associate(result, enc);
}
break;

View file

@ -1945,6 +1945,7 @@ rb_str_upto(int argc, VALUE *argv, VALUE beg)
int n, excl;
rb_scan_args(argc, argv, "11", &end, &exclusive);
rb_enc_check(beg, end);
excl = RTEST(exclusive);
succ = rb_intern("succ");
StringValue(end);
@ -3741,11 +3742,12 @@ tr_find(int c, char table[256], VALUE del, VALUE nodel)
else {
VALUE v = INT2NUM(c);
if ((!del || !NIL_P(rb_hash_lookup(del, v))) &&
(!nodel || NIL_P(rb_hash_lookup(nodel, v)))) {
return Qtrue;
if (!del || NIL_P(rb_hash_lookup(del, v))) {
return Qfalse;
}
return Qfalse;
if (nodel && NIL_P(rb_hash_lookup(nodel, v)))
return Qfalse;
return Qtrue;
}
}