aboutsummaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-01-22 03:59:53 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-01-22 03:59:53 +0000
commit65a8185eb212639875ae8db14dfffb1fa06b71e9 (patch)
tree95b915e9c09bac1eaff6cc86b70d590a053c3ba4 /string.c
parent157664b9f3cfeb485abe1cf8298e82accef23acf (diff)
downloadruby-65a8185eb212639875ae8db14dfffb1fa06b71e9.tar.gz
* configure.in (MINIRUBY): remove -I$(EXTOUT)/$(arch) from
MINIRUBY since miniruby might not be able to load DLL. * test/ruby/test_m17n.rb: move tests from bootstrap test. * encoding.c (enc_find): should check name if ASCII compatible. * string.c (rb_str_end_with): should check character boundary. * encoding.c (rb_enc_compatible): encoding must be ASCII compatible before checking ENC_CODERANGE_7BIT. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15167 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/string.c b/string.c
index c963b7f434..7d716f0523 100644
--- a/string.c
+++ b/string.c
@@ -5522,14 +5522,19 @@ static VALUE
rb_str_end_with(int argc, VALUE *argv, VALUE str)
{
int i;
+ char *p, *s;
+ rb_encoding *enc;
for (i=0; i<argc; i++) {
VALUE tmp = rb_check_string_type(argv[i]);
if (NIL_P(tmp)) continue;
- rb_enc_check(str, tmp);
+ enc = rb_enc_check(str, tmp);
if (RSTRING_LEN(str) < RSTRING_LEN(tmp)) continue;
- if (memcmp(RSTRING_PTR(str) + RSTRING_LEN(str) - RSTRING_LEN(tmp),
- RSTRING_PTR(tmp), RSTRING_LEN(tmp)) == 0)
+ p = RSTRING_PTR(str);
+ s = p + RSTRING_LEN(str) - RSTRING_LEN(tmp);
+ if (rb_enc_left_char_head(p, s, enc) != s)
+ continue;
+ if (memcmp(s, p, RSTRING_LEN(tmp)) == 0)
return Qtrue;
}
return Qfalse;