Skip to content

Commit 96d8e46

Browse files
committed
fix: drop leading garbage from exact glob pattern
Due to an unfortunate mixup of `resize()` vs. `reserve()` for the buffer containing the generated regex pattern for matching exact file paths, the buffer had garbage at the start leading to file searches not finding files if no wildcards were in effect.
1 parent b9118e2 commit 96d8e46

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

engine/system/win/sys_main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ bool GlobMatch(const std::filesystem::path& glob, const std::filesystem::path& f
150150
// If no wildcards are present, test file path verbatim.
151151
// We use a regex rather than string comparisons to make it case-insensitive.
152152
if (globStr.find_first_of("?*") == std::string::npos) {
153-
buf.resize(globStr.size());
153+
buf.reserve(globStr.size() * 3); // Decent estimate of final pattern size.
154+
154155
for (char ch : globStr) {
155156
fmt::format_to(fmt::appender(buf), "[{}]", ch);
156157
}

0 commit comments

Comments
 (0)