Skip to content

Commit 4ad1bd4

Browse files
committed
merge revision(s) r47591: [Backport ruby#10242]
* ext/pathname/lib/pathname.rb (SAME_PATHS): Pathname#relative_path_from uses String#casecmp to compare strings on case-insensitive filesystem platforms (e.g., Windows). This can return nil for strings with different encodings, and the code previously assumed that it always returned a Fixnum. [Fix rubyGH-713] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@47596 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 01cee45 commit 4ad1bd4

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

ChangeLog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
Mon Sep 15 22:34:39 2014 Natalie Weizenbaum <[email protected]>
2+
3+
* ext/pathname/lib/pathname.rb (SAME_PATHS):
4+
Pathname#relative_path_from uses String#casecmp to compare strings
5+
on case-insensitive filesystem platforms (e.g., Windows). This can
6+
return nil for strings with different encodings, and the code
7+
previously assumed that it always returned a Fixnum. [Fix GH-713]
8+
19
Mon Sep 15 22:31:33 2014 Sho Hashimoto <[email protected]>
210

311
* ext/fiddle/lib/fiddle/import.rb (Fiddle::Importer#sizeof): fix typo,

ext/pathname/lib/pathname.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ class Pathname
2222
end
2323

2424
SAME_PATHS = if File::FNM_SYSCASE.nonzero?
25-
proc {|a, b| a.casecmp(b).zero?}
25+
# Avoid #zero? here because #casecmp can return nil.
26+
proc {|a, b| a.casecmp(b) == 0}
2627
else
2728
proc {|a, b| a == b}
2829
end

test/pathname/test_pathname.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,4 +1322,17 @@ def test_file_join
13221322
assert_equal("foo/bar", File.join(Pathname.new("foo"), Pathname.new("bar").taint))
13231323
}.call
13241324
end
1325+
1326+
def test_relative_path_from_casefold
1327+
assert_separately([], <<-'end;') # do
1328+
module File::Constants
1329+
remove_const :FNM_SYSCASE
1330+
FNM_SYSCASE = FNM_CASEFOLD
1331+
end
1332+
require 'pathname'
1333+
foo = Pathname.new("fo\u{f6}")
1334+
bar = Pathname.new("b\u{e4}r".encode("ISO-8859-1"))
1335+
assert_instance_of(Pathname, foo.relative_path_from(bar))
1336+
end;
1337+
end
13251338
end

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#define RUBY_VERSION "2.1.2"
22
#define RUBY_RELEASE_DATE "2014-09-15"
3-
#define RUBY_PATCHLEVEL 239
3+
#define RUBY_PATCHLEVEL 240
44

55
#define RUBY_RELEASE_YEAR 2014
66
#define RUBY_RELEASE_MONTH 9

0 commit comments

Comments
 (0)