diff options
Diffstat (limited to 'ext')
-rw-r--r-- | ext/-test-/add_suffix/bug.c | 32 | ||||
-rw-r--r-- | ext/-test-/add_suffix/depend | 1 | ||||
-rw-r--r-- | ext/-test-/add_suffix/extconf.rb | 4 | ||||
-rw-r--r-- | ext/pathname/pathname.c | 7 |
4 files changed, 4 insertions, 40 deletions
diff --git a/ext/-test-/add_suffix/bug.c b/ext/-test-/add_suffix/bug.c deleted file mode 100644 index 3dc1201b6e..0000000000 --- a/ext/-test-/add_suffix/bug.c +++ /dev/null @@ -1,32 +0,0 @@ -static unsigned long ruby_scan_oct(); -static unsigned long ruby_scan_hex(); -static unsigned long ruby_strtoul(); -static void ruby_qsort(); -static char *ruby_strdup(); -static char *ruby_getcwd(); -static double ruby_strtod(); -static char *ruby_dtoa(); -static void ruby_each_words(); -static char *ruby_hdtoa(); -#include "ruby.h" -#include "ruby/defines.h" -#include "ruby/util.h" -#ifndef HAVE_RUBY_ADD_SUFFIX -#define _WIN32 1 -#include "util.c" -#endif - -static VALUE -add_suffix(VALUE self, VALUE path, VALUE suffix) -{ - StringValueCStr(path); - ruby_add_suffix(path, StringValueCStr(suffix)); - return path; -} - -void -Init_bug(void) -{ - VALUE mBug = rb_define_module("Bug"); - rb_define_module_function(mBug, "add_suffix", add_suffix, 2); -} diff --git a/ext/-test-/add_suffix/depend b/ext/-test-/add_suffix/depend deleted file mode 100644 index 943d0d9f21..0000000000 --- a/ext/-test-/add_suffix/depend +++ /dev/null @@ -1 +0,0 @@ -bug.o: $(hdrdir)/ruby/util.h $(top_srcdir)/util.c diff --git a/ext/-test-/add_suffix/extconf.rb b/ext/-test-/add_suffix/extconf.rb deleted file mode 100644 index bffd1550f3..0000000000 --- a/ext/-test-/add_suffix/extconf.rb +++ /dev/null @@ -1,4 +0,0 @@ -unless have_func("ruby_add_suffix", "ruby/util.h") - $INCFLAGS << " -I$(top_srcdir)" -end -create_makefile("-test-/add_suffix/bug") diff --git a/ext/pathname/pathname.c b/ext/pathname/pathname.c index e1632c524b..e35c19d541 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)); |