mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* string.c (rb_str_chomp_bang): avoid unnecessary loop using
rb_enc_prev_char(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14392 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
923d3ea159
commit
3ec3412d83
2 changed files with 7 additions and 6 deletions
|
@ -2,6 +2,11 @@ Fri Dec 21 12:55:39 2007 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* lib/runit, lib/rubyunit.rb, test/testunit/runit: removed.
|
* lib/runit, lib/rubyunit.rb, test/testunit/runit: removed.
|
||||||
|
|
||||||
|
Fri Dec 21 12:45:49 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* string.c (rb_str_chomp_bang): avoid unnecessary loop using
|
||||||
|
rb_enc_prev_char().
|
||||||
|
|
||||||
Fri Dec 21 12:32:08 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Fri Dec 21 12:32:08 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* file.c (Init_File): File.exists? revived.
|
* file.c (Init_File): File.exists? revived.
|
||||||
|
|
8
string.c
8
string.c
|
@ -4538,12 +4538,8 @@ rb_str_chomp_bang(int argc, VALUE *argv, VALUE str)
|
||||||
if (p[len-1] == newline &&
|
if (p[len-1] == newline &&
|
||||||
(rslen <= 1 ||
|
(rslen <= 1 ||
|
||||||
memcmp(RSTRING_PTR(rs), pp, rslen) == 0)) {
|
memcmp(RSTRING_PTR(rs), pp, rslen) == 0)) {
|
||||||
if (rb_enc_mbmaxlen(enc) > 1) {
|
if (ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc,p,pp) != (const UChar*)pp)
|
||||||
while (p < pp) {
|
return Qnil;
|
||||||
p += rb_enc_mbclen(p, e, enc);
|
|
||||||
}
|
|
||||||
if (p != pp) return Qnil;
|
|
||||||
}
|
|
||||||
rb_str_modify(str);
|
rb_str_modify(str);
|
||||||
STR_SET_LEN(str, RSTRING_LEN(str) - rslen);
|
STR_SET_LEN(str, RSTRING_LEN(str) - rslen);
|
||||||
RSTRING_PTR(str)[RSTRING_LEN(str)] = '\0';
|
RSTRING_PTR(str)[RSTRING_LEN(str)] = '\0';
|
||||||
|
|
Loading…
Reference in a new issue