From 5230f605e1afd4e3824aae069a5f1bead6f1647f 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:52 +0700 Subject: Import wildmatch from rsync MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These files are from rsync.git commit f92f5b166e3019db42bc7fe1aa2f1a9178cd215d, which was the last commit before rsync turned GPL-3. All files are imported as-is and no-op. Adaptation is done in a separate patch. rsync.git -> git.git lib/wildmatch.[ch] wildmatch.[ch] wildtest.txt t/t3070/wildtest.txt Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- wildmatch.h | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 wildmatch.h (limited to 'wildmatch.h') diff --git a/wildmatch.h b/wildmatch.h new file mode 100644 index 0000000000..e7f1a35f2a --- /dev/null +++ b/wildmatch.h @@ -0,0 +1,6 @@ +/* wildmatch.h */ + +int wildmatch(const char *pattern, const char *text); +int iwildmatch(const char *pattern, const char *text); +int wildmatch_array(const char *pattern, const char*const *texts, int where); +int litmatch_array(const char *string, const char*const *texts, int where); -- cgit v1.2.1 From b0e0287626d6257dd45df5502a07efd15a7255bc 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:53 +0700 Subject: wildmatch: remove unnecessary functions 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 --- wildmatch.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'wildmatch.h') diff --git a/wildmatch.h b/wildmatch.h index e7f1a35f2a..562faa35a5 100644 --- a/wildmatch.h +++ b/wildmatch.h @@ -2,5 +2,3 @@ int wildmatch(const char *pattern, const char *text); int iwildmatch(const char *pattern, const char *text); -int wildmatch_array(const char *pattern, const char*const *texts, int where); -int litmatch_array(const char *string, const char*const *texts, int where); -- 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 --- wildmatch.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'wildmatch.h') diff --git a/wildmatch.h b/wildmatch.h index 562faa35a5..e974f9abce 100644 --- a/wildmatch.h +++ b/wildmatch.h @@ -1,4 +1,3 @@ /* wildmatch.h */ -int wildmatch(const char *pattern, const char *text); -int iwildmatch(const char *pattern, const char *text); +int wildmatch(const char *pattern, const char *text, int flags); -- cgit v1.2.1 From 40bbee0ab07d0ee4f21b11d597c878245c1b05a6 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:26:00 +0700 Subject: wildmatch: adjust "**" behavior MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Standard wildmatch() sees consecutive asterisks as "*" that can also match slashes. But that may be hard to explain to users as "abc/**/def" can match "abcdef", "abcxyzdef", "abc/def", "abc/x/def", "abc/x/y/def"... This patch changes wildmatch so that users can do - "**/def" -> all paths ending with file/directory 'def' - "abc/**" - equivalent to "/abc/" - "abc/**/def" -> "abc/x/def", "abc/x/y/def"... - otherwise consider the pattern malformed if "**" is found Basically the magic of "**" only remains if it's wrapped around by slashes. Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- wildmatch.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'wildmatch.h') diff --git a/wildmatch.h b/wildmatch.h index e974f9abce..984a38cdc2 100644 --- a/wildmatch.h +++ b/wildmatch.h @@ -1,3 +1,9 @@ /* wildmatch.h */ +#define ABORT_MALFORMED 2 +#define NOMATCH 1 +#define MATCH 0 +#define ABORT_ALL -1 +#define ABORT_TO_STARSTAR -2 + int wildmatch(const char *pattern, const char *text, int flags); -- cgit v1.2.1 From 9b3497cab9986883ff2499722f8758795afa34b7 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, 1 Jan 2013 09:44:05 +0700 Subject: wildmatch: rename constants and update prototype MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - All exported constants now have a prefix WM_ - Do not rely on FNM_* constants, use the WM_ counterparts - Remove TRUE and FALSE to follow Git's coding style - While at it, turn flags type from int to unsigned int - Add an (unused yet) argument to carry extra information so that we don't have to change the prototype again later when we need to pass other stuff to wildmatch Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- wildmatch.h | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'wildmatch.h') diff --git a/wildmatch.h b/wildmatch.h index 984a38cdc2..1c814fd5ff 100644 --- a/wildmatch.h +++ b/wildmatch.h @@ -1,9 +1,17 @@ -/* wildmatch.h */ +#ifndef WILDMATCH_H +#define WILDMATCH_H -#define ABORT_MALFORMED 2 -#define NOMATCH 1 -#define MATCH 0 -#define ABORT_ALL -1 -#define ABORT_TO_STARSTAR -2 +#define WM_CASEFOLD 1 -int wildmatch(const char *pattern, const char *text, int flags); +#define WM_ABORT_MALFORMED 2 +#define WM_NOMATCH 1 +#define WM_MATCH 0 +#define WM_ABORT_ALL -1 +#define WM_ABORT_TO_STARSTAR -2 + +struct wildopts; + +int wildmatch(const char *pattern, const char *text, + unsigned int flags, + struct wildopts *wo); +#endif -- cgit v1.2.1 From c41244e702fd4fc1039f39a3915ae1e5f165bbf3 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, 1 Jan 2013 09:44:07 +0700 Subject: wildmatch: support "no FNM_PATHNAME" mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Junio C Hamano --- wildmatch.h | 1 + 1 file changed, 1 insertion(+) (limited to 'wildmatch.h') diff --git a/wildmatch.h b/wildmatch.h index 1c814fd5ff..4090c8f4bb 100644 --- a/wildmatch.h +++ b/wildmatch.h @@ -2,6 +2,7 @@ #define WILDMATCH_H #define WM_CASEFOLD 1 +#define WM_PATHNAME 2 #define WM_ABORT_MALFORMED 2 #define WM_NOMATCH 1 -- cgit v1.2.1