Project

General

Profile

Bug #15244 » multiple-leading-dot-basename-extname-15244.patch

jeremyevans0 (Jeremy Evans), 08/14/2019 01:08 AM

View differences:

file.c
#else
n = chompdirsep(p, end, enc) - p;
#endif
for (q = p; q - p < n && *q == '.'; q++);
q = p;
if (n > 0 && *q == '.') q++;
for (e = 0; q - p < n; Inc(q, end, enc)) {
if (*q == '.') e = q;
}
......
do name = ++p; while (isdirsep(*p));
e = 0;
while (*p && *p == '.') p++;
if (*p && *p == '.') p++;
while (*p) {
if (*p == '.' || istrailinggarbage(*p)) {
#if USE_NTFS
test/ruby/test_file_exhaustive.rb
assert_equal("foo", File.basename("foo", ".ext"))
assert_equal("foo", File.basename("foo.ext", ".ext"))
assert_equal("foo", File.basename("foo.ext", ".*"))
assert_equal(".", File.basename("..test", '.*'))
end
if NTFS
......
def test_extname
assert_equal(".test", File.extname(regular_file))
assert_equal(".test", File.extname(utf8_file))
assert_equal(".test", File.extname("..test"))
prefixes = ["", "/", ".", "/.", "bar/.", "/bar/."]
infixes = ["", " ", "."]
infixes2 = infixes + [".ext "]
(2-2/2)