Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/glob/glob_matcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -674,12 +674,10 @@ class PathMatcher {
}
const ptrdiff_t file_length = static_cast<ptrdiff_t>(file.size()) -
static_cast<ptrdiff_t>(file_tail_match);
{
size_t i = sections.size() - 1;
for (Section& s : sections) {
s.after = file_length - (static_cast<ptrdiff_t>(non_gs_sums[i--]) +
static_cast<ptrdiff_t>(s.end - s.begin));
}
// leave room for this section and every section after it
for (size_t i = 0; i < sections.size(); i++) {
sections[i].after =
file_length - static_cast<ptrdiff_t>(non_gs - non_gs_sums[i]);
}
return MatchBodySections(
file, pattern, sections, fi, 0, 0, file_tail_match != 0);
Expand Down
6 changes: 6 additions & 0 deletions test/parallel/test-path-glob.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ const globs = {
['foo\\bar\\baz\\boo', 'foo\\[bc-r]ar\\baz\\*', true], // Matches 'bar' or 'car' in 'foo\\bar'
['foo\\bar\\baz', 'foo/**', true], // Matches anything in 'foo'
['foo\\bar\\baz', '*', false], // No match
['a\\b\\c\\d\\e', '**/a/b/c/**/d/**', true], // Globstar sections of different lengths
['x\\a\\b\\c\\d\\e', '**/a/b/c/**/d/**/e', true], // Globstar sections of different lengths
['a\\b\\c\\d', '**/a/b/c/**/d/**', false], // Trailing globstar needs a segment
],
posix: [
['foo/bar/baz', 'foo/[bcr]ar/baz', true], // Matches 'bar' or 'car' in 'foo/bar'
Expand All @@ -28,6 +31,9 @@ const globs = {
['foo/bar/baz/boo', 'foo/[bc-r]ar/baz/*', true], // Matches 'bar' or 'car' in 'foo/bar'
['foo/bar/baz', 'foo/**', true], // Matches anything in 'foo'
['foo/bar/baz', '*', false], // No match
['a/b/c/d/e', '**/a/b/c/**/d/**', true], // Globstar sections of different lengths
['x/a/b/c/d/e', '**/a/b/c/**/d/**/e', true], // Globstar sections of different lengths
['a/b/c/d', '**/a/b/c/**/d/**', false], // Trailing globstar needs a segment
],
};

Expand Down
Loading