From feabcc173b7a5f55c2b1ec78f230276c63ae4d36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Mon, 15 Oct 2012 13:25:55 +0700 Subject: Integrate wildmatch to git MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- test-wildmatch.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 test-wildmatch.c (limited to 'test-wildmatch.c') diff --git a/test-wildmatch.c b/test-wildmatch.c new file mode 100644 index 0000000000..ac5642037d --- /dev/null +++ b/test-wildmatch.c @@ -0,0 +1,14 @@ +#include "cache.h" +#include "wildmatch.h" + +int main(int argc, char **argv) +{ + if (!strcmp(argv[1], "wildmatch")) + return wildmatch(argv[3], argv[2]) ? 0 : 1; + else if (!strcmp(argv[1], "iwildmatch")) + return iwildmatch(argv[3], argv[2]) ? 0 : 1; + else if (!strcmp(argv[1], "fnmatch")) + return !!fnmatch(argv[3], argv[2], FNM_PATHNAME); + else + return 1; +} -- cgit v1.2.1 From 3ae5396cf719000039c5d0d35f9bf934f647b030 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Mon, 15 Oct 2012 13:25:57 +0700 Subject: wildmatch: make wildmatch's return value compatible with fnmatch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit wildmatch returns non-zero if matched, zero otherwise. This patch makes it return zero if matches, non-zero otherwise, like fnmatch(). Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- test-wildmatch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test-wildmatch.c') diff --git a/test-wildmatch.c b/test-wildmatch.c index ac5642037d..77014e99dc 100644 --- a/test-wildmatch.c +++ b/test-wildmatch.c @@ -4,9 +4,9 @@ int main(int argc, char **argv) { if (!strcmp(argv[1], "wildmatch")) - return wildmatch(argv[3], argv[2]) ? 0 : 1; + return !!wildmatch(argv[3], argv[2]); else if (!strcmp(argv[1], "iwildmatch")) - return iwildmatch(argv[3], argv[2]) ? 0 : 1; + return !!iwildmatch(argv[3], argv[2]); else if (!strcmp(argv[1], "fnmatch")) return !!fnmatch(argv[3], argv[2], FNM_PATHNAME); else -- cgit v1.2.1 From 9b4edc0a49abd4b5c6505c63c8fa40d527df6ae8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Mon, 15 Oct 2012 13:25:58 +0700 Subject: wildmatch: remove static variable force_lower_case MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit One place less to worry about thread safety. Also combine wildmatch and iwildmatch into one. Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- test-wildmatch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test-wildmatch.c') diff --git a/test-wildmatch.c b/test-wildmatch.c index 77014e99dc..74c08644ee 100644 --- a/test-wildmatch.c +++ b/test-wildmatch.c @@ -4,9 +4,9 @@ int main(int argc, char **argv) { if (!strcmp(argv[1], "wildmatch")) - return !!wildmatch(argv[3], argv[2]); + return !!wildmatch(argv[3], argv[2], 0); else if (!strcmp(argv[1], "iwildmatch")) - return !!iwildmatch(argv[3], argv[2]); + return !!wildmatch(argv[3], argv[2], FNM_CASEFOLD); else if (!strcmp(argv[1], "fnmatch")) return !!fnmatch(argv[3], argv[2], FNM_PATHNAME); else -- cgit v1.2.1 From ef49841ddf98ed1eb40c60153072fa1a91fc2f18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Tue, 20 Nov 2012 08:02:39 +0100 Subject: test-wildmatch: avoid Windows path mangling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The MSYS bash mangles arguments that begin with a forward slash when they are passed to test-wildmatch. This causes tests to fail. Avoid mangling by prepending "XXX", which is removed by test-wildmatch before further processing. [J6t: reworded commit message] Reported-by: Johannes Sixt Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Johannes Sixt --- test-wildmatch.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test-wildmatch.c') diff --git a/test-wildmatch.c b/test-wildmatch.c index 74c08644ee..e384c8edb1 100644 --- a/test-wildmatch.c +++ b/test-wildmatch.c @@ -3,6 +3,14 @@ int main(int argc, char **argv) { + int i; + for (i = 2; i < argc; i++) { + if (argv[i][0] == '/') + die("Forward slash is not allowed at the beginning of the\n" + "pattern because Windows does not like it. Use `XXX/' instead."); + else if (!strncmp(argv[i], "XXX/", 4)) + argv[i] += 3; + } if (!strcmp(argv[1], "wildmatch")) return !!wildmatch(argv[3], argv[2], 0); else if (!strcmp(argv[1], "iwildmatch")) -- cgit v1.2.1