[前][次][番号順一覧][スレッド一覧]

ruby-changes:25278

From: usa <ko1@a...>
Date: Fri, 26 Oct 2012 12:02:07 +0900 (JST)
Subject: [ruby-changes:25278] usa:r37330 (ruby_1_9_3): merge revision(s) 32826,34732: [Backport #6681]

usa	2012-10-26 12:01:41 +0900 (Fri, 26 Oct 2012)

  New Revision: 37330

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=37330

  Log:
    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).

  Removed directories:
    branches/ruby_1_9_3/ext/-test-/add_suffix/
  Removed files:
    branches/ruby_1_9_3/test/-ext-/test_add_suffix.rb
  Modified files:
    branches/ruby_1_9_3/ChangeLog
    branches/ruby_1_9_3/LEGAL
    branches/ruby_1_9_3/dir.c
    branches/ruby_1_9_3/ext/pathname/pathname.c
    branches/ruby_1_9_3/file.c
    branches/ruby_1_9_3/include/ruby/encoding.h
    branches/ruby_1_9_3/include/ruby/intern.h
    branches/ruby_1_9_3/include/ruby/util.h
    branches/ruby_1_9_3/io.c
    branches/ruby_1_9_3/test/pathname/test_pathname.rb
    branches/ruby_1_9_3/test/ruby/test_argf.rb
    branches/ruby_1_9_3/test/ruby/test_file_exhaustive.rb
    branches/ruby_1_9_3/util.c
    branches/ruby_1_9_3/version.h

Index: ruby_1_9_3/include/ruby/intern.h
===================================================================
--- ruby_1_9_3/include/ruby/intern.h	(revision 37329)
+++ ruby_1_9_3/include/ruby/intern.h	(revision 37330)
@@ -402,15 +402,9 @@
 VALUE rb_find_file_safe(VALUE, int);
 int rb_find_file_ext(VALUE*, const char* const*);
 VALUE rb_find_file(VALUE);
-char *rb_path_next(const char *);
-char *rb_path_skip_prefix(const char *);
-char *rb_path_last_separator(const char *);
-char *rb_path_end(const char *);
 VALUE rb_file_directory_p(VALUE,VALUE);
 VALUE rb_str_encode_ospath(VALUE);
 int rb_is_absolute_path(const char *);
-const char *ruby_find_basename(const char *name, long *baselen, long *alllen);
-const char *ruby_find_extname(const char *name, long *len);
 /* gc.c */
 void ruby_set_stack_size(size_t);
 NORETURN(void rb_memerror(void));
Index: ruby_1_9_3/include/ruby/util.h
===================================================================
--- ruby_1_9_3/include/ruby/util.h	(revision 37329)
+++ ruby_1_9_3/include/ruby/util.h	(revision 37330)
@@ -54,10 +54,6 @@
 #define scan_hex(s,l,e) ((int)ruby_scan_hex((s),(l),(e)))
 unsigned long ruby_scan_hex(const char *, size_t, size_t *);
 
-#if defined(__CYGWIN32__) || defined(_WIN32)
-void ruby_add_suffix(VALUE str, const char *suffix);
-#endif
-
 void ruby_qsort(void *, const size_t, const size_t,
 		int (*)(const void *, const void *, void *), void *);
 
Index: ruby_1_9_3/include/ruby/encoding.h
===================================================================
--- ruby_1_9_3/include/ruby/encoding.h	(revision 37329)
+++ ruby_1_9_3/include/ruby/encoding.h	(revision 37330)
@@ -211,6 +211,12 @@
 void rb_enc_set_default_internal(VALUE encoding);
 VALUE rb_locale_charmap(VALUE klass);
 long rb_memsearch(const void*,long,const void*,long,rb_encoding*);
+char *rb_enc_path_next(const char *,const char *,rb_encoding*);
+char *rb_enc_path_skip_prefix(const char *,const char *,rb_encoding*);
+char *rb_enc_path_last_separator(const char *,const char *,rb_encoding*);
+char *rb_enc_path_end(const char *,const char *,rb_encoding*);
+const char *ruby_enc_find_basename(const char *name, long *baselen, long *alllen, rb_encoding *enc);
+const char *ruby_enc_find_extname(const char *name, long *len, rb_encoding *enc);
 
 RUBY_EXTERN VALUE rb_cEncoding;
 #define ENC_DUMMY_FLAG (1<<24)
Index: ruby_1_9_3/LEGAL
===================================================================
--- ruby_1_9_3/LEGAL	(revision 37329)
+++ ruby_1_9_3/LEGAL	(revision 37330)
@@ -148,7 +148,6 @@
     REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
     OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
 
-util.c (partly):
 win32/win32.[ch]:
 
   You can apply the Artistic License to these files. (or GPL,
Index: ruby_1_9_3/ChangeLog
===================================================================
--- ruby_1_9_3/ChangeLog	(revision 37329)
+++ ruby_1_9_3/ChangeLog	(revision 37330)
@@ -1,3 +1,39 @@
+Fri Oct 26 11:03:46 2012  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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.
+
+Fri Oct 26 11:03:46 2012  NAKAMURA Usaku  <usa@r...>
+
+	* 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).
+
 Thu Oct 25 18:16:25 2012  NARUSE, Yui  <naruse@r...>
 
 	* lib/rubygems/installer.rb (check_that_user_bin_dir_is_in_path):
Index: ruby_1_9_3/io.c
===================================================================
--- ruby_1_9_3/io.c	(revision 37329)
+++ ruby_1_9_3/io.c	(revision 37330)
@@ -35,10 +35,6 @@
 # define NO_SAFE_RENAME
 #endif
 
-#if defined(__CYGWIN__) || defined(_WIN32)
-# define NO_LONG_FNAME
-#endif
-
 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(sun) || defined(_nec_ews)
 # define USE_SETVBUF
 #endif
@@ -7198,15 +7194,15 @@
 		    fstat(fr, &st);
 		    if (*ARGF.inplace) {
 			str = rb_str_new2(fn);
-#ifdef NO_LONG_FNAME
-                        ruby_add_suffix(str, ARGF.inplace);
-#else
 			rb_str_cat2(str, ARGF.inplace);
-#endif
 #ifdef NO_SAFE_RENAME
 			(void)close(fr);
 			(void)unlink(RSTRING_PTR(str));
-			(void)rename(fn, RSTRING_PTR(str));
+			if (rename(fn, RSTRING_PTR(str)) < 0) {
+			    rb_warn("Can't rename %s to %s: %s, skipping file",
+				    fn, RSTRING_PTR(str), strerror(errno));
+			    goto retry;
+			}
 			fr = rb_sysopen(str, O_RDONLY, 0);
 #else
 			if (rename(fn, RSTRING_PTR(str)) < 0) {
Index: ruby_1_9_3/dir.c
===================================================================
--- ruby_1_9_3/dir.c	(revision 37329)
+++ ruby_1_9_3/dir.c	(revision 37330)
@@ -910,11 +910,16 @@
 {
     VALUE d = *dir;
     char *path, *pend;
+    long len;
+    rb_encoding *enc;
 
     rb_secure(2);
     FilePathValue(d);
-    path = RSTRING_PTR(d);
-    if (path && *(pend = rb_path_end(rb_path_skip_prefix(path)))) {
+    enc = rb_enc_get(d);
+    RSTRING_GETMEM(d, path, len);
+    pend = path + len;
+    pend = rb_enc_path_end(rb_enc_path_skip_prefix(path, pend, enc), pend, enc);
+    if (pend - path < len) {
 	d = rb_str_subseq(d, 0, pend - path);
     }
     *dir = rb_str_encode_ospath(d);
@@ -1494,7 +1499,7 @@
     start = root = path;
     flags |= FNM_SYSCASE;
 #if defined DOSISH
-    root = rb_path_skip_prefix(root);
+    root = rb_enc_path_skip_prefix(root, root + strlen(root), enc);
 #endif
 
     if (root && *root == '/') root++;
Index: ruby_1_9_3/util.c
===================================================================
--- ruby_1_9_3/util.c	(revision 37329)
+++ ruby_1_9_3/util.c	(revision 37330)
@@ -184,185 +184,7 @@
 #   define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
 #endif
 
-#if defined(__CYGWIN32__) || defined(_WIN32)
-/*
- *  Copyright (c) 1993, Intergraph Corporation
- *
- *  You may distribute under the terms of either the GNU General Public
- *  License or the Artistic License, as specified in the perl README file.
- *
- *  Various Unix compatibility functions and NT specific functions.
- *
- *  Some of this code was derived from the MSDOS port(s) and the OS/2 port.
- *
- */
 
-
-/*
- * Suffix appending for in-place editing under MS-DOS and OS/2 (and now NT!).
- *
- * Here are the rules:
- *
- * Style 0:  Append the suffix exactly as standard perl would do it.
- *           If the filesystem groks it, use it.  (HPFS will always
- *           grok it.  So will NTFS. FAT will rarely accept it.)
- *
- * Style 1:  The suffix begins with a '.'.  The extension is replaced.
- *           If the name matches the original name, use the fallback method.
- *
- * Style 2:  The suffix is a single character, not a '.'.  Try to add the
- *           suffix to the following places, using the first one that works.
- *               [1] Append to extension.
- *               [2] Append to filename,
- *               [3] Replace end of extension,
- *               [4] Replace end of filename.
- *           If the name matches the original name, use the fallback method.
- *
- * Style 3:  Any other case:  Ignore the suffix completely and use the
- *           fallback method.
- *
- * Fallback method:  Change the extension to ".$$$".  If that matches the
- *           original name, then change the extension to ".~~~".
- *
- * If filename is more than 1000 characters long, we die a horrible
- * death.  Sorry.
- *
- * The filename restriction is a cheat so that we can use buf[] to store
- * assorted temporary goo.
- *
- * Examples, assuming style 0 failed.
- *
- * suffix = ".bak" (style 1)
- *                foo.bar => foo.bak
- *                foo.bak => foo.$$$	(fallback)
- *                makefile => makefile.bak
- * suffix = ".$$$" (style 1)
- *                foo.$$$ => foo.~~~	(fallback)
- *
- * suffix = "~" (style 2)
- *                foo.c => foo.c~
- *                foo.c~ => foo.c~~
- *                foo.c~~ => foo~.c~~
- *                foo~.c~~ => foo~~.c~~
- *                foo~~~~~.c~~ => foo~~~~~.$$$ (fallback)
- *
- *                foo.pas => foo~.pas
- *                makefile => makefile.~
- *                longname.fil => longname.fi~
- *                longname.fi~ => longnam~.fi~
- *                longnam~.fi~ => longnam~.$$$
- *
- */
-
-
-static int valid_filename(const char *s);
-
-static const char suffix1[] = ".$$$";
-static const char suffix2[] = ".~~~";
-
-#define strEQ(s1,s2) (strcmp((s1),(s2)) == 0)
-
-void
-ruby_add_suffix(VALUE str, const char *suffix)
-{
-    long baselen;
-    long extlen = strlen(suffix);
-    long slen;
-    char buf[1024];
-    const char *name;
-    const char *ext;
-    long len;
-
-    name = StringValueCStr(str);
-    slen = strlen(name);
-    if (slen > (long)(sizeof(buf) - 1))
-	rb_fatal("Cannot do inplace edit on long filename (%ld characters)",
-		 slen);
-
-    /* Style 0 */
-    rb_str_cat(str, suffix, extlen);
-    if (valid_filename(RSTRING_PTR(str))) return;
-
-    /* Fooey, style 0 failed.  Fix str before continuing. */
-    rb_str_resize(str, slen);
-    name = StringValueCStr(str);
-    ext = ruby_find_extname(name, &len);
-
-    if (*suffix == '.') {        /* Style 1 */
-	if (ext) {
-	    if (strEQ(ext, suffix)) {
-		extlen = sizeof(suffix1) - 1; /* suffix2 must be same length */
-		suffix = strEQ(suffix, suffix1) ? suffix2 : suffix1;
-	    }
-	    slen = ext - name;
-	}
-	rb_str_resize(str, slen);
-	rb_str_cat(str, suffix, extlen);
-    }
-    else {
-	char *p = buf, *q;
-	strncpy(buf, name, slen);
-	if (ext)
-	    p += (ext - name);
-	else
-	    p += slen;
-	p[len] = '\0';
-	if (suffix[1] == '\0') {  /* Style 2 */
-	    q = (char *)ruby_find_basename(buf, &baselen, 0);
-	    if (len <= 3) {
-		if (len == 0 && baselen >= 8 && p + 3 <= buf + sizeof(buf)) p[len++] = '.'; /* DOSISH */
-		p[len] = *suffix;
-		p[++len] = '\0';
-	    }
-	    else if (q && baselen < 8) {
-		q += baselen;
-		*q++ = *suffix;
-		if (ext) {
-		    strncpy(q, ext, ext - name);
-		    q[ext - name + 1] = '\0';
-		}
-		else
-		    *q = '\0';
-	    }
-	    else if (len == 4 && p[3] != *suffix)
-		p[3] = *suffix;
-	    else if (baselen == 8 && q[7] != *suffix)
-		q[7] = *suffix;
-	    else
-		goto fallback;
-	}
-	else { /* Style 3:  Panic */
-	  fallback:
-	    (void)memcpy(p, !ext || strEQ(ext, suffix1) ? suffix2 : suffix1, 5);
-	}
-	rb_str_resize(str, strlen(buf));
-	memcpy(RSTRING_PTR(str), buf, RSTRING_LEN(str));
-    }
-}
-
-static int
-valid_filename(const char *s)
-{
-    int fd;
-
-    /*
-    // It doesn't exist, so see if we can open it.
-    */
-
-    if ((fd = open(s, O_CREAT|O_EXCL, 0666)) >= 0) {
-	close(fd);
-	unlink(s);	/* don't leave it laying around */
-	return 1;
-    }
-    else if (errno == EEXIST) {
-	/* if the file exists, then it's a valid filename! */
-	return 1;
-    }
-    return 0;
-}
-#endif
-
-
 /* mm.c */
 
 #define A ((int*)a)
Index: ruby_1_9_3/ext/pathname/pathname.c
===================================================================
--- ruby_1_9_3/ext/pathname/pathname.c	(revision 37329)
+++ ruby_1_9_3/ext/pathname/pathname.c	(revision 37330)
@@ -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 @@
 
     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));
Index: ruby_1_9_3/version.h
===================================================================
--- ruby_1_9_3/version.h	(revision 37329)
+++ ruby_1_9_3/version.h	(revision 37330)
@@ -1,5 +1,5 @@
 #define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 302
+#define RUBY_PATCHLEVEL 303
 
 #define RUBY_RELEASE_DATE "2012-10-26"
 #define RUBY_RELEASE_YEAR 2012
Index: ruby_1_9_3/test/ruby/test_argf.rb
===================================================================
--- ruby_1_9_3/test/ruby/test_argf.rb	(revision 37329)
+++ ruby_1_9_3/test/ruby/test_argf.rb	(revision 37330)
@@ -201,21 +201,14 @@
     t = make_tempfile
 
     assert_in_out_err(["-", t.path], <<-INPUT) do |r, e|
-      ARGF.inplace_mode = '/\\\\'
+      ARGF.inplace_mode = '/\\\\:'
       while line = ARGF.gets
         puts line.chomp + '.new'
       end
     INPUT
-      if no_safe_rename
-        assert_equal([], e)
-        assert_equal([], r)
-        assert_equal("foo.new\nbar.new\nbaz.new\n", File.read(t.path))
-        File.unlink(t.path + ".~~~") rescue nil
-      else
-        assert_match(/Can't rename .* to .*: .*. skipping file/, e.first) #'
-        assert_equal([], r)
-        assert_equal("foo\nbar\nbaz\n", File.read(t.path))
-      end
+      assert_match(/Can't rename .* to .*: .*. skipping file/, e.first) #'
+      assert_equal([], r)
+      assert_equal("foo\nbar\nbaz\n", File.read(t.path))
     end
   end
 
Index: ruby_1_9_3/test/ruby/test_file_exhaustive.rb
===================================================================
--- ruby_1_9_3/test/ruby/test_file_exhaustive.rb	(revision 37329)
+++ ruby_1_9_3/test/ruby/test_file_exhaustive.rb	(revision 37330)
@@ -403,10 +403,10 @@
       assert_match(/\Ac:\//i, File.expand_path('c:foo', 'd:/bar'))
       assert_match(%r'\Ac:/bar/foo\z'i, File.expand_path('c:foo', 'c:/bar'))
     end
-    if drive = Dir.pwd[%r'\A(?:[a-z]:|//[^/]+/[^/]+)'i]
+    if DRIVE
       assert_match(%r"\Az:/foo\z"i, File.expand_path('/foo', "z:/bar"))
       assert_match(%r"\A//host/share/foo\z"i, File.expand_path('/foo', "//host/share/bar"))
-      assert_match(%r"\A#{drive}/foo\z"i, File.expand_path('/foo'))
+      assert_match(%r"\A#{DRIVE}/foo\z"i, File.expand_path('/foo'))
     else
       assert_equal("/foo", File.expand_path('/foo'))
     end
@@ -477,7 +477,6 @@
       ENV["HOMEPATH"] = home_path
       ENV["USERPROFILE"] = user_profile
     end
-    assert_incompatible_encoding {|d| File.expand_path(d)}
   end
 
   def test_expand_path_remove_trailing_alternative_data
@@ -683,16 +682,31 @@
       assert_equal(basename, File.basename(@file + ".", ".*"))
       assert_equal(basename, File.basename(@file + "::$DATA", ".*"))
     end
+    if File::ALT_SEPARATOR == '\\'
+      a = "foo/\225\\\\"
+      [%W"cp437 \225", %W"cp932 \225\\"].each do |cp, expected|
+        assert_equal(expected.force_encoding(cp), File.basename(a.dup.force_encoding(cp)), cp)
+      end
+    end
 
     assert_incompatible_encoding {|d| File.basename(d)}
     assert_incompatible_encoding {|d| File.basename(d, ".*")}
     assert_raise(Encoding::CompatibilityError) {File.basename("foo.ext", ".*".encode("utf-16le"))}
+
+    s = "foo\x93_a".force_encoding("cp932")
+    assert_equal(s, File.basename(s, "_a"))
   end
 
   def test_dirname
     assert(@file.start_with?(File.dirname(@file)))
     assert_equal(".", File.dirname(""))
     assert_incompatible_encoding {|d| File.dirname(d)}
+    if File::ALT_SEPARATOR == '\\'
+      a = "\225\\\\foo"
+      [%W"cp437 \225", %W"cp932 \225\\"].each do |cp, expected|
+        assert_equal(expected.force_encoding(cp), File.dirname(a.dup.force_encoding(cp)), cp)
+      end
+    end
   end
 
   def test_extname
@@ -736,6 +750,13 @@
     def o.to_path; "foo"; end
     assert_equal(s, File.join(o, "bar", "baz"))
     assert_equal(s, File.join("foo" + File::SEPARATOR, "bar", File::SEPARATOR + "baz"))
+    if File::ALT_SEPARATOR == '\\'
+      a = "\225\\"
+      b = "foo"
+      [%W"cp437 \225\\foo", %W"cp932 \225\\/foo"].each do |cp, expected|
+        assert_equal(expected.force_encoding(cp), File.join(a.dup.force_encoding(cp), b.dup.force_encoding(cp)), cp)
+      end
+    end
   end
 
   def test_truncate
Index: ruby_1_9_3/test/-ext-/test_add_suffix.rb
===================================================================
--- ruby_1_9_3/test/-ext-/test_add_suffix.rb	(revision 37329)
+++ ruby_1_9_3/test/-ext-/test_add_suffix.rb	(revision 37330)
@@ -1,47 +0,0 @@
-require 'test/unit'
-require_relative '../ruby/envutil'
-require "-test-/add_suffix/bug"
-
-class Test_AddSuffix < Test::Unit::TestCase
-  Dir = "/dev/null/".freeze
-  Style_1 = (Dir+"foo").freeze
-
-  def test_style_0
-    assert_equal("a.x.y", Bug.add_suffix("a.x", ".y"))
-  end
-
-  def test_style_1
-    assert_equal(Style_1+".y", Bug.add_suffix(Style_1+".c", ".y"))
-    suffix = ".bak".freeze
-    assert_equal(Style_1+suffix, Bug.add_suffix(Style_1.dup, suffix))
-    assert_equal(Style_1+suffix, Bug.add_suffix(Style_1+".bar", suffix))
-    assert_equal(Style_1+".$$$", Bug.add_suffix(Style_1+suffix, suffix))
-    assert_equal(Style_1+suffix, Bug.add_suffix(Style_1+".$$$", suffix))
-    assert_equal(Style_1+".~~~", Bug.add_suffix(Style_1+".$$$", ".$$$"))
-    assert_equal(Dir+"makefile"+suffix, Bug.add_suffix(Dir+"makefile", suffix))
-  end
-
-  def test_style_2
-    suffix = "~"
-    assert_equal(Style_1+"~", Bug.add_suffix(Style_1.dup, suffix))
-    assert_equal(Style_1+".c~", Bug.add_suffix(Style_1+".c", suffix))
-    assert_equal(Style_1+".c~~", Bug.add_suffix(Style_1+".c~", suffix))
-    assert_equal(Style_1+"~.c~~", Bug.add_suffix(Style_1+".c~~", suffix))
-    assert_equal(Style_1+"~~.c~~", Bug.add_suffix(Style_1+"~.c~~", suffix))
-    assert_equal(Style_1+"~~~~~.cc~", Bug.add_suffix(Style_1+"~~~~~.ccc", suffix))
-    assert_equal(Style_1+"~~~~~.$$$", Bug.add_suffix(Style_1+"~~~~~.c~~", suffix))
-    assert_equal(Dir+"foo~.pas", Bug.add_suffix(Dir+"foo.pas", suffix))
-    assert_equal(Dir+"makefile.~", Bug.add_suffix(Dir+"makefile", suffix))
-    assert_equal(Dir+"longname.fi~", Bug.add_suffix(Dir+"longname.fil", suffix))
-    assert_equal(Dir+"longnam~.fi~", Bug.add_suffix(Dir+"longname.fi~", suffix))
-    assert_equal(Dir+"longnam~.$$$", Bug.add_suffix(Dir+"longnam~.fi~", suffix))
-  end
-
-  def test_style_3
-    base = "a"*1000
-    suffix = "-"+"b"*1000
-    assert_equal(base+".~~~", Bug.add_suffix(base, suffix))
-    assert_equal(base+".~~~", Bug.add_suffix(base+".$$$", suffix))
-    assert_equal(base+".$$$", Bug.add_suffix(base+".~~~", suffix))
-  end
-end
Index: ruby_1_9_3/test/pathname/test_pathname.rb
===================================================================
--- ruby_1_9_3/test/pathname/test_pathname.rb	(revision 37329)
+++ ruby_1_9_3/test/pathname/test_pathname.rb	(revision 37330)
@@ -1,5 +1,3 @@
-#!/usr/bin/env ruby
-
 require 'test/unit'
 require 'pathname'
 
@@ -185,10 +183,8 @@
 
   if DOSISH
     defassert(:del_trailing_separator, "a", "a\\")
-    require 'Win32API'
-    if Win32API.new('kernel32', 'GetACP', nil, 'L').call == 932
-      defassert(:del_trailing_separator, "\225\\", "\225\\\\") # SJIS
-    end
+    defassert(:de (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]