From: Paul Eggert Date: Wed, 11 Aug 1999 12:47:01 +0000 (+0000) Subject: (_GNU_SOURCE): Define. X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=92a680ff64f378579e541a8b440980fd379cf00b;p=chaz%2Ftar (_GNU_SOURCE): Define. (): Include unconditionally. (excluded_name): New function, taking over duties of excluded_pathname. All uses changed. --- diff --git a/src/names.c b/src/names.c index 14c9c06..b627729 100644 --- a/src/names.c +++ b/src/names.c @@ -15,14 +15,16 @@ with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* Enable GNU extensions in fnmatch.h. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif + #include "system.h" #include #include - -#ifndef FNM_LEADING_DIR -# include -#endif +#include #include "common.h" @@ -805,3 +807,25 @@ new_name (const char *path, const char *name) sprintf (buffer, "%s/%s", path, name); return buffer; } + +/* Return nonzero if file NAME is excluded. Exclude a name if its + prefix matches a pattern that contains slashes, or if one of its + components matches a pattern that contains no slashes. */ +int +excluded_name (char const *name) +{ + char const *p; + name += FILESYSTEM_PREFIX_LEN (name); + + if (excluded_filename (excluded_with_slash, name, + FNM_FILE_NAME | FNM_LEADING_DIR)) + return 1; + + for (p = name; *p; p++) + if ((p == name || (ISSLASH (p[-1]) && !ISSLASH (p[0]))) + && excluded_filename (excluded_without_slash, p, + FNM_FILE_NAME | FNM_LEADING_DIR)) + return 1; + + return 0; +}