diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-01-25 02:32:06 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-01-25 02:32:06 +0000 |
commit | ed469831e44f2b5a9384b18e660677b20a5ab664 (patch) | |
tree | 5bb8be2989daaec412e3b09b22034aab1007e9a4 /ext/pathname | |
parent | abd135d36bef0f340fd914405c8cfe0c0e579f86 (diff) |
* file.c (rb_enc_path_next, rb_enc_path_skip_prefix)
(rb_enc_path_last_separator, rb_enc_path_end)
(ruby_enc_find_basename, ruby_enc_find_extname): encoding-aware
path handling functions.
* file.c (rb_home_dir, file_expand_path, rb_realpath_internal)
(rb_file_s_basename, rb_file_dirname, rb_file_s_extname)
(rb_file_join): should respect the encodings of arguments than
file system encoding. [ruby-dev:45145] [Bug #5919]
* dir.c (check_dirname, ruby_glob0): ditto.
* ext/pathname/pathname.c (path_sub_ext): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34372 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/pathname')
-rw-r--r-- | ext/pathname/pathname.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/ext/pathname/pathname.c b/ext/pathname/pathname.c index bde58a3e21..84a2b5d61b 100644 --- a/ext/pathname/pathname.c +++ b/ext/pathname/pathname.c @@ -1,4 +1,5 @@ #include "ruby.h" +#include "ruby/encoding.h" static VALUE rb_cPathname; static ID id_at_path, id_to_path; @@ -184,15 +185,15 @@ path_sub_ext(VALUE self, VALUE repl) StringValue(repl); p = RSTRING_PTR(str); - ext = ruby_find_extname(p, &extlen); + extlen = RSTRING_LEN(str); + ext = ruby_enc_find_extname(p, &extlen, rb_enc_get(str)); if (ext == NULL) { ext = p + RSTRING_LEN(str); } else if (extlen <= 1) { ext += extlen; } - str2 = rb_str_dup(str); - rb_str_resize(str2, ext-p); + str2 = rb_str_subseq(str, 0, ext-p); rb_str_append(str2, repl); OBJ_INFECT(str2, str); return rb_class_new_instance(1, &str2, rb_obj_class(self)); |