summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-26 03:01:41 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-26 03:01:41 +0000
commit0e6dcc7ab24e6e5b8ee3b9a532c0318eb5155e2e (patch)
tree10e9d00b89f6bb5b0d275ee4dbd6e35fe886b2ef /ext
parentc5b7d11e59cf8953d18ed6aba2c4df2b1eb29fd4 (diff)
merge revision(s) 32826,34732: [Backport #6681]
* 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. * util.c, include/ruby/util.h (ruby_add_suffix): remove the function. [Bug #5153] [ruby-core:38736] * io.c (argf_next_argv): remove the call of above function. * ext/-test-/add_suffix, test/-ext-/test_add_suffix.rb: remove the test extension module because this is only for testsing ruby_add_suffix(). * LEGAL: remove the mention about a part of util.c, because now we removed the part. * io.c (argf_next_argv): now the new filename is not guranteed to use, so should check the return value of rename(2). * test/ruby/test_argf.rb (TestArgf#test_inplace_rename_impossible): now we expect same result with other platforms on no_safe_rename platforms (=Windows). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@37330 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/-test-/add_suffix/bug.c32
-rw-r--r--ext/-test-/add_suffix/depend1
-rw-r--r--ext/-test-/add_suffix/extconf.rb4
-rw-r--r--ext/pathname/pathname.c7
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));