You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: a glob's **/ matches part of a name, so **/main.cpp selects src/domain.cpp #877
// src/main.cppintdomain_value();
intmain() { returndomain_value(); }
// src/app/domain.cpp
#ifdef ENTRY_ONLY
#error "ENTRY_ONLY reached domain.cpp, a file **/main.cpp does not name"
#endifintdomain_value() { return0; }
$ mcpp build
error: build failed in globrepro v0.1.0 (.)
failed: obj/domain.o
src/app/domain.cpp:2:2: error: "ENTRY_ONLY reached domain.cpp, a file **/main.cpp does not name"
relative_path_matches_glob (modules/manifest/src/glob.cppm) consumes **/ and then retries the rest of the pattern at every character of the path, not only where a path segment starts. So the rest of the pattern can match the tail of a file or directory name:
Glob
Path
Matches today
**/main.cpp
src/domain.cpp
yes
tests/**/test_*.cpp
tests/mytest_a.cpp
yes
**/modules/dnn/**/*.avx2.cpp
a/submodules/dnn/l.avx2.cpp
yes
The matcher is shared by every glob with the sources grammar: sources, [build] flags, [scan_overrides."<glob>"], test discover, [pack] include/exclude and rerun_if_changed_glob. So the extra files are compiled, get another file's flags or scan result, or are packed or left out.
Expected
**/ matches zero or more whole directories, as in gitignore, Cargo's include and other glob implementations. **/main.cpp matches main.cpp, src/main.cpp and src/a/b/main.cpp, and not src/domain.cpp.
Actual
What follows **/ may start in the middle of a name, so **/main.cpp also selects domain.cpp, xmain.cpp and so on.
Activity