wildmatch: support "no FNM_PATHNAME" mode

So far, wildmatch() has always honoured directory boundary and there
was no way to turn it off. Make it behave more like fnmatch() by
requiring all callers that want the FNM_PATHNAME behaviour to pass
that in the equivalent flag WM_PATHNAME. Callers that do not specify
WM_PATHNAME will get wildcards like ? and * in their patterns matched
against '/', just like not passing FNM_PATHNAME to fnmatch().

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Nguyễn Thái Ngọc Duy
2013-01-01 09:44:07 +07:00
committed by Junio C Hamano
parent 0c528168da
commit c41244e702
5 changed files with 42 additions and 7 deletions

2
dir.c
View File

@ -595,7 +595,7 @@ int match_pathname(const char *pathname, int pathlen,
}
return wildmatch(pattern, name,
ignore_case ? WM_CASEFOLD : 0,
WM_PATHNAME | (ignore_case ? WM_CASEFOLD : 0),
NULL) == 0;
}