summaryrefslogtreecommitdiff
path: root/ext/pathname/pathname.c
diff options
context:
space:
mode:
authorMichael Leibowitz <michael.leibowitz@intel.com>2013-08-15 15:02:54 -0700
committerMichael Leibowitz <michael.leibowitz@intel.com>2013-08-15 15:02:54 -0700
commit6b0e2a11aeccf2ebc707c22548a0c15c8c2bae06 (patch)
treed9d59f4b502927634d32832e963db76629ff5a2e /ext/pathname/pathname.c
parent3b35de2a90e26b99e2a6d4f61dc56d6ce7ded748 (diff)
downloadruby-upstream.tar.gz
ruby-upstream.tar.bz2
ruby-upstream.zip
Imported Upstream version 1.9.3.p448upstream/1.9.3.p448upstream
Diffstat (limited to 'ext/pathname/pathname.c')
-rw-r--r--ext/pathname/pathname.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/ext/pathname/pathname.c b/ext/pathname/pathname.c
index e1632c5..e35c19d 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));