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:
parent
17f4486abc
commit
5a41626dea
3 changed files with 18 additions and 5 deletions
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
10
string.c
10
string.c
|
@ -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,12 +3742,13 @@ 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;
|
||||
}
|
||||
if (nodel && NIL_P(rb_hash_lookup(nodel, v)))
|
||||
return Qfalse;
|
||||
return Qtrue;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue