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
4523 4523
#else
4524 4524
	n = chompdirsep(p, end, enc) - p;
4525 4525
#endif
4526
	for (q = p; q - p < n && *q == '.'; q++);
4526
        q = p;
4527
        if (n > 0 && *q == '.') q++;
4527 4528
	for (e = 0; q - p < n; Inc(q, end, enc)) {
4528 4529
	    if (*q == '.') e = q;
4529 4530
	}
......
4686 4687
	do name = ++p; while (isdirsep(*p));
4687 4688

  
4688 4689
    e = 0;
4689
    while (*p && *p == '.') p++;
4690
    if (*p && *p == '.') p++;
4690 4691
    while (*p) {
4691 4692
	if (*p == '.' || istrailinggarbage(*p)) {
4692 4693
#if USE_NTFS
test/ruby/test_file_exhaustive.rb
1227 1227
    assert_equal("foo", File.basename("foo", ".ext"))
1228 1228
    assert_equal("foo", File.basename("foo.ext", ".ext"))
1229 1229
    assert_equal("foo", File.basename("foo.ext", ".*"))
1230
    assert_equal(".", File.basename("..test", '.*'))
1230 1231
  end
1231 1232

  
1232 1233
  if NTFS
......
1306 1307
  def test_extname
1307 1308
    assert_equal(".test", File.extname(regular_file))
1308 1309
    assert_equal(".test", File.extname(utf8_file))
1310
    assert_equal(".test", File.extname("..test"))
1309 1311
    prefixes = ["", "/", ".", "/.", "bar/.", "/bar/."]
1310 1312
    infixes = ["", " ", "."]
1311 1313
    infixes2 = infixes + [".ext "]
1312
-