From patchwork Tue Aug 22 18:21:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 110695 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp3056195qge; Tue, 22 Aug 2017 11:21:50 -0700 (PDT) X-Received: by 10.99.125.88 with SMTP id m24mr43742pgn.430.1503426110346; Tue, 22 Aug 2017 11:21:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503426110; cv=none; d=google.com; s=arc-20160816; b=Y147oPzF2LfRPqxbS3bPxWDr+C9+p4uK15i38f+3afzbIczmun7Ldo7w4I3Dmfr1Q1 1FPfHlzEjbxADc2GscQeDE9V5LtuwWamRJOne90cTJhUEgU33XoPueg4M0yqX8fr8uyz C+t7pcKpCp7EEQZYRxddOwnZLL2Z22hv3+TDnHZ1Kq/OVetzmkZ4Mb5zRYwUeyu5Ndu6 CnnZ04KF+t+JEiYAfGvsBE2h+cIo4zjyF9nW7E+ZGyOCrLEtN1mZf+y/T+dn9XJWGAsQ JAmy3GoDqcfLrIC8s+YNNF8PMFC5YbBel9SembHDEmAAmGVq3fUas9SYEDpIRle+Kv45 ocZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :delivered-to:sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=FQh/GXPDEzz4bqE0YcAK3Z/0488wwc8RWzEd8kF1u4g=; b=zNfz7ru9kTpd+FaAk32YhHL2HUUZkeezPKlNgmjsQ+A2gnbs6GVLbmm4CN+8MnijVg NGMdoteJa9wCsGmqaOKoakt40y9AzY3hEFMVr259Go0dUoHvVeyfCZjKt7LGonFav3OH FGsgHmc0xWQmkQHM3tstGTesuT/LnTEkGEuGXpErKXf6QuRxy9emPPo0MezoeFRFgFTt aFOpLGCigoEaEQzzYD/2Qy7sYvM5RGkCX80Ulo25U83B9pb3w/JqcRdIjHZOTGuKvnMp wACCyIXLQsDGWhnBjLxsxlv51HD/YiAtd84qu3jHDKi71BKDQ05Rtbfre2wOv0UZfoEj OFhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=U8PF1MY4; spf=pass (google.com: domain of libc-alpha-return-83665-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-83665-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id e61si10256840plb.200.2017.08.22.11.21.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Aug 2017 11:21:50 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-83665-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=U8PF1MY4; spf=pass (google.com: domain of libc-alpha-return-83665-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-83665-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=PuZ4isgrHMi58fteuHIjwuQs95YR7LA 17S+HIB3lf0ReHtjrykrN4A2z/Ggp0FnLgN8oKcBVjAt9wKpGo6/RRVN9jEgxX9Y AkT/kJYCg5DX5rcj7lLVOZy2Gw7759mnAGy/ICOXSoXP4ruVnaF32OdqydbF5zhV w+qKNCQYJ0QQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=AYZO3+IYI5N4ynSntBd+VCjKco8=; b=U8PF1 MY4BMmLBA5j3osI/AIfaVZ3dNl71VYXenYUSNbY52E9ZJmPQnjROuQ8Fn0FMF5Gs 4m7gdqQJT5bl/ZoVEY7jTa01B6Ejr6paJH1fPL0vZiKP5YpZ+ehD+kC8m68lIPjr UV5Z42RyhN9gPywDS0OZowQA+YY/BVDIwQUYT8= Received: (qmail 70283 invoked by alias); 22 Aug 2017 18:21:23 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 70087 invoked by uid 89); 22 Aug 2017 18:21:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=Stick X-HELO: mail-qk0-f171.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FQh/GXPDEzz4bqE0YcAK3Z/0488wwc8RWzEd8kF1u4g=; b=qwkPLzdRt4YAM3JV17qS70Pc8Ee1HIFYAbdNayQpbSBZuzhwhWPu282DCZvTfJPb3T Y4upfUBiNbDGWykxCbYvsK5cVl7GNKZhIqvJaUOasd/dHyNRRyfWnTa60lENu3ThmdO+ VESQadsO4rEO+FKi18bZS4swF7OgwcdxbHSQ1a0osAyOU0pwLIcWKdlDO8wRlP79cMs5 /Rh4hw/92WL+gDR7pBb7x2Bjyc1iujU0axXZjjy63SzXVxCwV2mzU1GOXzSl0WwJXa2R 5zxCthDJJzyTH023yS257hUTuRJ3H8OxTLiwScaE/1QHu5Vczj7bj3i3zVo9DFgudTfH 2a3w== X-Gm-Message-State: AHYfb5gibd8EuHAYsPoa5Fpepz/znwTMeg7FhAI6fMaQY8+ehgNAwc7d UT/EggCjID1TWcQpARKd8g== X-Received: by 10.55.78.6 with SMTP id c6mr73600qkb.286.1503426071413; Tue, 22 Aug 2017 11:21:11 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Paul Eggert Subject: [PATCH 1/3] posix: Sync glob with gnulib [BZ #1062] Date: Tue, 22 Aug 2017 15:21:02 -0300 Message-Id: <1503426064-2827-2-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1503426064-2827-1-git-send-email-adhemerval.zanella@linaro.org> References: <1503426064-2827-1-git-send-email-adhemerval.zanella@linaro.org> This patch syncs posix/glob.c implementation with gnulib version 1dc82a77fa606e18edf. The main differences to gnulib code: 1. Commit 44c637c (Properly initialize glob structure with GLOB_BRACE|GLOB_DOOFFS) which fixes BZ# 20707. 2. No inclusion of flexmember.h header and its usage on glob. The code is meant to be rewritten and header is unrequired in following patches in this set. 3. An additional define (GLOB_COMPAT_BUILD) to avoid building size_and_wrapv and gblo_use_alloca twice on some configurations (i368 compat code) due multiple inclusion. The main changes are: - Header organization mostly due gnulib requirements. It leads to some simplification and less conditional includes. - Use of glob_use_alloca with wraps up __libc_use_alloca with saturated math for the total size calculation. - Simplify some size allocation overflow calculation. - Some fixed on non supported glibc systems. - Some comments adjustments. The changes does not alter current glob internal semantic. I also added a missing globfree on posix/globtest.c (it helps silence some valgrind or other memory profilers). Note I haven't sync with f320c1ebec mainly because I intend to send fixes that make this change not required (the glob_in_dir names will be handled by a dynarray structure instead). [BZ #1062] * posix/glob.c: Sync with gnulib. * posix/globtest.c (main): Add final globfree. * sysdeps/unix/sysv/linux/i386/glob64.c (GLOB_COMPAT_BUILD): Define. --- posix/glob.c | 526 ++++++++++++++++++++-------------- posix/globtest.c | 3 + sysdeps/unix/sysv/linux/i386/glob64.c | 2 + 3 files changed, 322 insertions(+), 209 deletions(-) -- 2.7.4 diff --git a/posix/glob.c b/posix/glob.c index c653809..5e4b7fc 100644 --- a/posix/glob.c +++ b/posix/glob.c @@ -15,7 +15,10 @@ License along with the GNU C Library; if not, see . */ -#ifdef HAVE_CONFIG_H +#ifndef _LIBC +/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc + optimizes away the pattern == NULL || pglob == NULL tests below. */ +# define _GL_ARG_NONNULL(params) # include #endif @@ -34,22 +37,19 @@ #include /* Needed on stupid SunOS for assert. */ -#if !defined _LIBC || !defined GLOB_ONLY_P -#if defined HAVE_UNISTD_H || defined _LIBC -# include -# ifndef POSIX -# ifdef _POSIX_VERSION -# define POSIX -# endif -# endif +#ifndef GLOB_ONLY_P + +#include +#if !defined POSIX && defined _POSIX_VERSION +# define POSIX #endif -#include +#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +# define WINDOWS32 +#endif -#if defined HAVE_STDINT_H || defined _LIBC -# include -#elif !defined UINTPTR_MAX -# define UINTPTR_MAX (~((size_t) 0)) +#ifndef WINDOWS32 +# include #endif #include @@ -57,24 +57,7 @@ # define __set_errno(val) errno = (val) #endif -#if defined HAVE_DIRENT_H || defined __GNU_LIBRARY__ -# include -#else -# define dirent direct -# ifdef HAVE_SYS_NDIR_H -# include -# endif -# ifdef HAVE_SYS_DIR_H -# include -# endif -# ifdef HAVE_NDIR_H -# include -# endif -# ifdef HAVE_VMSDIR_H -# include "vmsdir.h" -# endif /* HAVE_VMSDIR_H */ -#endif - +#include #include #include #include @@ -93,17 +76,16 @@ # endif # define struct_stat64 struct stat64 #else /* !_LIBC */ -# include "getlogin_r.h" -# include "mempcpy.h" -# include "stat-macros.h" -# include "strdup.h" -# define __stat64(fname, buf) stat (fname, buf) -# define struct_stat64 struct stat -# define __stat(fname, buf) stat (fname, buf) -# define __alloca alloca -# define __readdir readdir -# define __readdir64 readdir64 -# define __glob_pattern_p glob_pattern_p +# define __getlogin_r(buf, len) getlogin_r (buf, len) +# define __stat64(fname, buf) stat (fname, buf) +# define __fxstatat64(_, d, f, st, flag) fstatat (d, f, st, flag) +# define struct_stat64 struct stat +# ifndef __MVS__ +# define __alloca alloca +# endif +# define __readdir readdir +# define __glob_pattern_p glob_pattern_p +# define COMPILE_GLOB64 #endif /* _LIBC */ #include @@ -186,7 +168,7 @@ readdir_result_might_be_dir (struct readdir_result d) D_INO_TO_RESULT (source) \ } -#endif /* !defined _LIBC || !defined GLOB_ONLY_P */ +#endif /* !defined GLOB_ONLY_P */ /* Call gl_readdir on STREAM. This macro can be overridden to reduce type safety if an old interface version needs to be supported. */ @@ -230,13 +212,74 @@ convert_dirent64 (const struct dirent64 *source) # define attribute_hidden #endif +#ifndef __attribute_noinline__ +# if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 1) +# define __attribute_noinline__ /* Ignore */ +#else +# define __attribute_noinline__ __attribute__ ((__noinline__)) +# endif +#endif + +#ifndef __glibc_unlikely +# define __glibc_unlikely(expr) __builtin_expect (expr, 0) +#endif + +#ifndef _LIBC +/* The results of opendir() in this file are not used with dirfd and fchdir, + and we do not leak fds to any single-threaded code that could use stdio, + therefore save some unnecessary recursion in fchdir.c and opendir_safer.c. + FIXME - if the kernel ever adds support for multi-thread safety for + avoiding standard fds, then we should use opendir_safer. */ +# ifdef GNULIB_defined_opendir +# undef opendir +# endif +# ifdef GNULIB_defined_closedir +# undef closedir +# endif + +/* Just use malloc. */ +# define __libc_use_alloca(n) false +# define alloca_account(len, avar) ((void) (len), (void) (avar), (void *) 0) +# define extend_alloca_account(buf, len, newlen, avar) \ + ((void) (buf), (void) (len), (void) (newlen), (void) (avar), (void *) 0) +#endif + +/* Set *R = A + B. Return true if the answer is mathematically + incorrect due to overflow; in this case, *R is the low order + bits of the correct answer.. */ + +static bool size_add_wrapv (size_t a, size_t b, size_t *r); +static bool glob_use_alloca (size_t alloca_used, size_t len); + +/* We must not compile this function twice. */ +#ifndef GLOB_COMPAT_BUILD +static bool +size_add_wrapv (size_t a, size_t b, size_t *r) +{ +#if 5 <= __GNUC__ + return __builtin_add_overflow (a, b, r); +#else + *r = a + b; + return *r < a; +#endif +} + +static bool +glob_use_alloca (size_t alloca_used, size_t len) +{ + size_t size; + return (!size_add_wrapv (alloca_used, len, &size) + && __libc_use_alloca (size)); +} +#endif + static int glob_in_dir (const char *pattern, const char *directory, int flags, int (*errfunc) (const char *, int), glob_t *pglob, size_t alloca_used); extern int __glob_pattern_type (const char *pattern, int quote) attribute_hidden; -#if !defined _LIBC || !defined GLOB_ONLY_P +#ifndef GLOB_ONLY_P static int prefix_array (const char *prefix, char **array, size_t n) __THROWNL; static int collated_compare (const void *, const void *) __THROWNL; @@ -265,16 +308,16 @@ next_brace_sub (const char *cp, int flags) return *cp != '\0' ? cp : NULL; } -#endif /* !defined _LIBC || !defined GLOB_ONLY_P */ +#endif /* !defined GLOB_ONLY_P */ /* Do glob searching for PATTERN, placing results in PGLOB. The bits defined above may be set in FLAGS. If a directory cannot be opened or read and ERRFUNC is not nil, it is called with the pathname that caused the error, and the - `errno' value from the failing call; if it returns non-zero - `glob' returns GLOB_ABORTED; if it returns zero, the error is ignored. + 'errno' value from the failing call; if it returns non-zero + 'glob' returns GLOB_ABORTED; if it returns zero, the error is ignored. If memory cannot be allocated for PGLOB, GLOB_NOSPACE is returned. - Otherwise, `glob' returns zero. */ + Otherwise, 'glob' returns zero. */ int #ifdef GLOB_ATTRIBUTE GLOB_ATTRIBUTE @@ -292,9 +335,7 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), int malloc_dirname = 0; glob_t dirs; int retval = 0; -#ifdef _LIBC size_t alloca_used = 0; -#endif if (pattern == NULL || pglob == NULL || (flags & ~__GLOB_FLAGS) != 0) { @@ -308,7 +349,7 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), flags |= GLOB_ONLYDIR; if (!(flags & GLOB_DOOFFS)) - /* Have to do this so `globfree' knows where to start freeing. It + /* Have to do this so 'globfree' knows where to start freeing. It also makes all the code that uses gl_offs simpler. */ pglob->gl_offs = 0; @@ -363,7 +404,7 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), if (begin != NULL) { /* Allocate working buffer large enough for our work. Note that - we have at least an opening and closing brace. */ + we have at least an opening and closing brace. */ size_t firstc; char *alt_start; const char *p; @@ -372,16 +413,21 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), size_t rest_len; char *onealt; size_t pattern_len = strlen (pattern) - 1; -#ifdef _LIBC - int alloca_onealt = __libc_use_alloca (alloca_used + pattern_len); + int alloca_onealt = glob_use_alloca (alloca_used, pattern_len); if (alloca_onealt) onealt = alloca_account (pattern_len, alloca_used); else -#endif { - onealt = (char *) malloc (pattern_len); + onealt = malloc (pattern_len); if (onealt == NULL) - return GLOB_NOSPACE; + { + if (!(flags & GLOB_APPEND)) + { + pglob->gl_pathc = 0; + pglob->gl_pathv = NULL; + } + return GLOB_NOSPACE; + } } /* We know the prefix for all sub-patterns. */ @@ -392,14 +438,11 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), next = next_brace_sub (begin + 1, flags); if (next == NULL) { - /* It is an illegal expression. */ + /* It is an invalid expression. */ illegal_brace: -#ifdef _LIBC if (__glibc_unlikely (!alloca_onealt)) -#endif free (onealt); - flags &= ~GLOB_BRACE; - goto no_brace; + return glob (pattern, flags & ~GLOB_BRACE, errfunc, pglob); } /* Now find the end of the whole brace expression. */ @@ -437,9 +480,7 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), /* If we got an error, return it. */ if (result && result != GLOB_NOMATCH) { -#ifdef _LIBC if (__glibc_unlikely (!alloca_onealt)) -#endif free (onealt); if (!(flags & GLOB_APPEND)) { @@ -458,9 +499,7 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), assert (next != NULL); } -#ifdef _LIBC if (__glibc_unlikely (!alloca_onealt)) -#endif free (onealt); if (pglob->gl_pathc != firstc) @@ -471,7 +510,6 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), } } - no_brace: oldcount = pglob->gl_pathc + pglob->gl_offs; /* Find the filename. */ @@ -536,22 +574,20 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), char *drive_spec; ++dirlen; - drive_spec = (char *) __alloca (dirlen + 1); + drive_spec = __alloca (dirlen + 1); *((char *) mempcpy (drive_spec, pattern, dirlen)) = '\0'; /* For now, disallow wildcards in the drive spec, to prevent infinite recursion in glob. */ if (__glob_pattern_p (drive_spec, !(flags & GLOB_NOESCAPE))) return GLOB_NOMATCH; - /* If this is "d:pattern", we need to copy `:' to DIRNAME + /* If this is "d:pattern", we need to copy ':' to DIRNAME as well. If it's "d:/pattern", don't remove the slash from "d:/", since "d:" and "d:/" are not the same.*/ } #endif -#ifdef _LIBC - if (__libc_use_alloca (alloca_used + dirlen + 1)) + if (glob_use_alloca (alloca_used, dirlen + 1)) newp = alloca_account (dirlen + 1, alloca_used); else -#endif { newp = malloc (dirlen + 1); if (newp == NULL) @@ -572,6 +608,7 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), /* "pattern/". Expand "pattern", appending slashes. */ { int orig_flags = flags; + int val; if (!(flags & GLOB_NOESCAPE) && dirname[dirlen - 1] == '\\') { /* "pattern\\/". Remove the final backslash if it hasn't @@ -585,7 +622,7 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), flags &= ~(GLOB_NOCHECK | GLOB_NOMAGIC); } } - int val = glob (dirname, flags | GLOB_MARK, errfunc, pglob); + val = glob (dirname, flags | GLOB_MARK, errfunc, pglob); if (val == 0) pglob->gl_flags = ((pglob->gl_flags & ~GLOB_MARK) | (flags & GLOB_MARK)); @@ -602,7 +639,6 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), } } -#ifndef VMS if ((flags & (GLOB_TILDE|GLOB_TILDE_CHECK)) && dirname[0] == '~') { if (dirname[1] == '\0' || dirname[1] == '/' @@ -617,95 +653,129 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), home_dir = "SYS:"; # else # ifdef WINDOWS32 + /* Windows NT defines HOMEDRIVE and HOMEPATH. But give preference + to HOME, because the user can change HOME. */ if (home_dir == NULL || home_dir[0] == '\0') - home_dir = "c:/users/default"; /* poor default */ + { + const char *home_drive = getenv ("HOMEDRIVE"); + const char *home_path = getenv ("HOMEPATH"); + + if (home_drive != NULL && home_path != NULL) + { + size_t home_drive_len = strlen (home_drive); + size_t home_path_len = strlen (home_path); + char *mem = alloca (home_drive_len + home_path_len + 1); + + memcpy (mem, home_drive, home_drive_len); + memcpy (mem + home_drive_len, home_path, home_path_len + 1); + home_dir = mem; + } + else + home_dir = "c:/users/default"; /* poor default */ + } # else if (home_dir == NULL || home_dir[0] == '\0') { int success; char *name; + int malloc_name = 0; size_t buflen = GET_LOGIN_NAME_MAX () + 1; if (buflen == 0) /* `sysconf' does not support _SC_LOGIN_NAME_MAX. Try a moderate value. */ buflen = 20; - name = alloca_account (buflen, alloca_used); + if (glob_use_alloca (alloca_used, buflen)) + name = alloca_account (buflen, alloca_used); + else + { + name = malloc (buflen); + if (name == NULL) + { + retval = GLOB_NOSPACE; + goto out; + } + malloc_name = 1; + } success = __getlogin_r (name, buflen) == 0; if (success) { struct passwd *p; -# if defined HAVE_GETPWNAM_R || defined _LIBC - long int pwbuflen = GETPW_R_SIZE_MAX (); + char *malloc_pwtmpbuf = NULL; char *pwtmpbuf; +# if defined HAVE_GETPWNAM_R || defined _LIBC + long int pwbuflenmax = GETPW_R_SIZE_MAX (); + size_t pwbuflen = pwbuflenmax; struct passwd pwbuf; - int malloc_pwtmpbuf = 0; int save = errno; # ifndef _LIBC - if (pwbuflen == -1) + if (! (0 < pwbuflenmax && pwbuflenmax <= SIZE_MAX)) /* `sysconf' does not support _SC_GETPW_R_SIZE_MAX. Try a moderate value. */ pwbuflen = 1024; # endif - if (__libc_use_alloca (alloca_used + pwbuflen)) + if (glob_use_alloca (alloca_used, pwbuflen)) pwtmpbuf = alloca_account (pwbuflen, alloca_used); else { pwtmpbuf = malloc (pwbuflen); if (pwtmpbuf == NULL) { + if (__glibc_unlikely (malloc_name)) + free (name); retval = GLOB_NOSPACE; goto out; } - malloc_pwtmpbuf = 1; + malloc_pwtmpbuf = pwtmpbuf; } while (getpwnam_r (name, &pwbuf, pwtmpbuf, pwbuflen, &p) != 0) { + size_t newlen; + bool v; if (errno != ERANGE) { p = NULL; break; } - - if (!malloc_pwtmpbuf - && __libc_use_alloca (alloca_used - + 2 * pwbuflen)) + v = size_add_wrapv (pwbuflen, pwbuflen, &newlen); + if (!v && malloc_pwtmpbuf == NULL + && glob_use_alloca (alloca_used, newlen)) pwtmpbuf = extend_alloca_account (pwtmpbuf, pwbuflen, - 2 * pwbuflen, - alloca_used); + newlen, alloca_used); else { - char *newp = realloc (malloc_pwtmpbuf - ? pwtmpbuf : NULL, - 2 * pwbuflen); + char *newp = (v ? NULL + : realloc (malloc_pwtmpbuf, newlen)); if (newp == NULL) { - if (__glibc_unlikely (malloc_pwtmpbuf)) - free (pwtmpbuf); + free (malloc_pwtmpbuf); + if (__glibc_unlikely (malloc_name)) + free (name); retval = GLOB_NOSPACE; goto out; } - pwtmpbuf = newp; - pwbuflen = 2 * pwbuflen; - malloc_pwtmpbuf = 1; + malloc_pwtmpbuf = pwtmpbuf = newp; } + pwbuflen = newlen; __set_errno (save); } # else p = getpwnam (name); # endif + if (__glibc_unlikely (malloc_name)) + free (name); if (p != NULL) { - if (!malloc_pwtmpbuf) + if (malloc_pwtmpbuf == NULL) home_dir = p->pw_dir; else { size_t home_dir_len = strlen (p->pw_dir) + 1; - if (__libc_use_alloca (alloca_used + home_dir_len)) + if (glob_use_alloca (alloca_used, home_dir_len)) home_dir = alloca_account (home_dir_len, alloca_used); else @@ -720,23 +790,30 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), malloc_home_dir = 1; } memcpy (home_dir, p->pw_dir, home_dir_len); - - free (pwtmpbuf); } } + free (malloc_pwtmpbuf); + } + else + { + if (__glibc_unlikely (malloc_name)) + free (name); } } if (home_dir == NULL || home_dir[0] == '\0') { + if (__glibc_unlikely (malloc_home_dir)) + free (home_dir); if (flags & GLOB_TILDE_CHECK) { - if (__glibc_unlikely (malloc_home_dir)) - free (home_dir); retval = GLOB_NOMATCH; goto out; } else - home_dir = (char *) "~"; /* No luck. */ + { + home_dir = (char *) "~"; /* No luck. */ + malloc_home_dir = 0; + } } # endif /* WINDOWS32 */ # endif @@ -754,8 +831,7 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), { char *newp; size_t home_len = strlen (home_dir); - int use_alloca = __libc_use_alloca (alloca_used - + home_len + dirlen); + int use_alloca = glob_use_alloca (alloca_used, home_len + dirlen); if (use_alloca) newp = alloca_account (home_len + dirlen, alloca_used); else @@ -779,6 +855,9 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), dirname = newp; dirlen += home_len - 1; malloc_dirname = !use_alloca; + + if (__glibc_unlikely (malloc_home_dir)) + free (home_dir); } dirname_modified = 1; } @@ -806,7 +885,7 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), else { char *newp; - if (__libc_use_alloca (alloca_used + (end_name - dirname))) + if (glob_use_alloca (alloca_used, end_name - dirname)) newp = alloca_account (end_name - dirname, alloca_used); else { @@ -851,20 +930,21 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), /* Look up specific user's home directory. */ { struct passwd *p; + char *malloc_pwtmpbuf = NULL; # if defined HAVE_GETPWNAM_R || defined _LIBC - long int buflen = GETPW_R_SIZE_MAX (); + long int buflenmax = GETPW_R_SIZE_MAX (); + size_t buflen = buflenmax; char *pwtmpbuf; - int malloc_pwtmpbuf = 0; struct passwd pwbuf; int save = errno; # ifndef _LIBC - if (buflen == -1) - /* `sysconf' does not support _SC_GETPW_R_SIZE_MAX. Try a + if (! (0 <= buflenmax && buflenmax <= SIZE_MAX)) + /* Perhaps 'sysconf' does not support _SC_GETPW_R_SIZE_MAX. Try a moderate value. */ buflen = 1024; # endif - if (__libc_use_alloca (alloca_used + buflen)) + if (glob_use_alloca (alloca_used, buflen)) pwtmpbuf = alloca_account (buflen, alloca_used); else { @@ -877,32 +957,32 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), retval = GLOB_NOSPACE; goto out; } - malloc_pwtmpbuf = 1; + malloc_pwtmpbuf = pwtmpbuf; } while (getpwnam_r (user_name, &pwbuf, pwtmpbuf, buflen, &p) != 0) { + size_t newlen; + bool v; if (errno != ERANGE) { p = NULL; break; } - if (!malloc_pwtmpbuf - && __libc_use_alloca (alloca_used + 2 * buflen)) + v = size_add_wrapv (buflen, buflen, &newlen); + if (!v && malloc_pwtmpbuf == NULL + && glob_use_alloca (alloca_used, newlen)) pwtmpbuf = extend_alloca_account (pwtmpbuf, buflen, - 2 * buflen, alloca_used); + newlen, alloca_used); else { - char *newp = realloc (malloc_pwtmpbuf ? pwtmpbuf : NULL, - 2 * buflen); + char *newp = v ? NULL : realloc (malloc_pwtmpbuf, newlen); if (newp == NULL) { - if (__glibc_unlikely (malloc_pwtmpbuf)) - free (pwtmpbuf); + free (malloc_pwtmpbuf); goto nomem_getpw; } - pwtmpbuf = newp; - malloc_pwtmpbuf = 1; + malloc_pwtmpbuf = pwtmpbuf = newp; } __set_errno (save); } @@ -923,7 +1003,7 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), free (dirname); malloc_dirname = 0; - if (__libc_use_alloca (alloca_used + home_len + rest_len + 1)) + if (glob_use_alloca (alloca_used, home_len + rest_len + 1)) dirname = alloca_account (home_len + rest_len + 1, alloca_used); else @@ -931,8 +1011,7 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), dirname = malloc (home_len + rest_len + 1); if (dirname == NULL) { - if (__glibc_unlikely (malloc_pwtmpbuf)) - free (pwtmpbuf); + free (malloc_pwtmpbuf); retval = GLOB_NOSPACE; goto out; } @@ -944,24 +1023,24 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), dirlen = home_len + rest_len; dirname_modified = 1; - if (__glibc_unlikely (malloc_pwtmpbuf)) - free (pwtmpbuf); + free (malloc_pwtmpbuf); } else { - if (__glibc_unlikely (malloc_pwtmpbuf)) - free (pwtmpbuf); + free (malloc_pwtmpbuf); if (flags & GLOB_TILDE_CHECK) + { /* We have to regard it as an error if we cannot find the home directory. */ - return GLOB_NOMATCH; + retval = GLOB_NOMATCH; + goto out; + } } } } # endif /* Not Amiga && not WINDOWS32. */ } -#endif /* Not VMS. */ /* Now test whether we looked for "~" or "~NAME". In this case we can give the answer now. */ @@ -980,19 +1059,18 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), size_t newcount = pglob->gl_pathc + pglob->gl_offs; char **new_gl_pathv; - if (newcount > UINTPTR_MAX - (1 + 1) - || newcount + 1 + 1 > ~((size_t) 0) / sizeof (char *)) + if (newcount > SIZE_MAX / sizeof (char *) - 2) { nospace: free (pglob->gl_pathv); pglob->gl_pathv = NULL; pglob->gl_pathc = 0; - return GLOB_NOSPACE; + retval = GLOB_NOSPACE; + goto out; } - new_gl_pathv - = (char **) realloc (pglob->gl_pathv, - (newcount + 1 + 1) * sizeof (char *)); + new_gl_pathv = realloc (pglob->gl_pathv, + (newcount + 2) * sizeof (char *)); if (new_gl_pathv == NULL) goto nospace; pglob->gl_pathv = new_gl_pathv; @@ -1006,12 +1084,19 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), p = mempcpy (pglob->gl_pathv[newcount], dirname, dirlen); p[0] = '/'; p[1] = '\0'; + if (__glibc_unlikely (malloc_dirname)) + free (dirname); } else { - pglob->gl_pathv[newcount] = strdup (dirname); - if (pglob->gl_pathv[newcount] == NULL) - goto nospace; + if (__glibc_unlikely (malloc_dirname)) + pglob->gl_pathv[newcount] = dirname; + else + { + pglob->gl_pathv[newcount] = strdup (dirname); + if (pglob->gl_pathv[newcount] == NULL) + goto nospace; + } } pglob->gl_pathv[++newcount] = NULL; ++pglob->gl_pathc; @@ -1021,7 +1106,8 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), } /* Not found. */ - return GLOB_NOMATCH; + retval = GLOB_NOMATCH; + goto out; } meta = __glob_pattern_type (dirname, !(flags & GLOB_NOESCAPE)); @@ -1067,7 +1153,10 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), if (status != 0) { if ((flags & GLOB_NOCHECK) == 0 || status != GLOB_NOMATCH) - return status; + { + retval = status; + goto out; + } goto no_matches; } @@ -1078,7 +1167,7 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), { size_t old_pathc; -#ifdef SHELL +#ifdef SHELL { /* Make globbing interruptible in the bash shell. */ extern int interrupt_state; @@ -1086,7 +1175,8 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), if (interrupt_state) { globfree (&dirs); - return GLOB_ABORTED; + retval = GLOB_ABORTED; + goto out; } } #endif /* SHELL. */ @@ -1105,7 +1195,8 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), globfree (&dirs); globfree (pglob); pglob->gl_pathc = 0; - return status; + retval = status; + goto out; } /* Stick the directory on the front of each name. */ @@ -1116,7 +1207,8 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), globfree (&dirs); globfree (pglob); pglob->gl_pathc = 0; - return GLOB_NOSPACE; + retval = GLOB_NOSPACE; + goto out; } } @@ -1134,28 +1226,28 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), size_t newcount = pglob->gl_pathc + pglob->gl_offs; char **new_gl_pathv; - if (newcount > UINTPTR_MAX - 2 - || newcount + 2 > ~((size_t) 0) / sizeof (char *)) + if (newcount > SIZE_MAX / sizeof (char *) - 2) { nospace2: globfree (&dirs); - return GLOB_NOSPACE; + retval = GLOB_NOSPACE; + goto out; } - new_gl_pathv = (char **) realloc (pglob->gl_pathv, - (newcount + 2) - * sizeof (char *)); + new_gl_pathv = realloc (pglob->gl_pathv, + (newcount + 2) * sizeof (char *)); if (new_gl_pathv == NULL) goto nospace2; pglob->gl_pathv = new_gl_pathv; - pglob->gl_pathv[newcount] = __strdup (pattern); + pglob->gl_pathv[newcount] = strdup (pattern); if (pglob->gl_pathv[newcount] == NULL) { globfree (&dirs); globfree (pglob); pglob->gl_pathc = 0; - return GLOB_NOSPACE; + retval = GLOB_NOSPACE; + goto out; } ++pglob->gl_pathc; @@ -1167,7 +1259,8 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), else { globfree (&dirs); - return GLOB_NOMATCH; + retval = GLOB_NOMATCH; + goto out; } } @@ -1213,7 +1306,8 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), flags = orig_flags; goto no_matches; } - return status; + retval = status; + goto out; } if (dirlen > 0) @@ -1225,7 +1319,8 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), { globfree (pglob); pglob->gl_pathc = 0; - return GLOB_NOSPACE; + retval = GLOB_NOSPACE; + goto out; } } } @@ -1250,7 +1345,8 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), { globfree (pglob); pglob->gl_pathc = 0; - return GLOB_NOSPACE; + retval = GLOB_NOSPACE; + goto out; } strcpy (&new[len - 2], "/"); pglob->gl_pathv[i] = new; @@ -1276,7 +1372,7 @@ libc_hidden_def (glob) #endif -#if !defined _LIBC || !defined GLOB_ONLY_P +#ifndef GLOB_ONLY_P /* Free storage allocated in PGLOB by a previous `glob' call. */ void @@ -1300,8 +1396,8 @@ libc_hidden_def (globfree) static int collated_compare (const void *a, const void *b) { - const char *const s1 = *(const char *const * const) a; - const char *const s2 = *(const char *const * const) b; + char *const *ps1 = a; char *s1 = *ps1; + char *const *ps2 = b; char *s2 = *ps2; if (s1 == s2) return 0; @@ -1351,7 +1447,7 @@ prefix_array (const char *dirname, char **array, size_t n) for (i = 0; i < n; ++i) { size_t eltlen = strlen (array[i]) + 1; - char *new = (char *) malloc (dirlen + 1 + eltlen); + char *new = malloc (dirlen + 1 + eltlen); if (new == NULL) { while (i > 0) @@ -1373,7 +1469,7 @@ prefix_array (const char *dirname, char **array, size_t n) /* We must not compile this function twice. */ -#if !defined _LIBC || !defined NO_GLOB_PATTERN_P +#ifndef NO_GLOB_PATTERN_P int __glob_pattern_type (const char *pattern, int quote) { @@ -1421,50 +1517,57 @@ weak_alias (__glob_pattern_p, glob_pattern_p) # endif #endif -#endif /* !GLOB_ONLY_P */ - /* We put this in a separate function mainly to allow the memory allocated with alloca to be recycled. */ -#if !defined _LIBC || !defined GLOB_ONLY_P static int __attribute_noinline__ -link_exists2_p (const char *dir, size_t dirlen, const char *fname, +link_stat (const char *dir, size_t dirlen, const char *fname, glob_t *pglob -# ifndef _LIBC +# if !defined _LIBC && !HAVE_FSTATAT , int flags # endif ) { size_t fnamelen = strlen (fname); - char *fullname = (char *) __alloca (dirlen + 1 + fnamelen + 1); + char *fullname = __alloca (dirlen + 1 + fnamelen + 1); struct stat st; -# ifndef _LIBC - struct_stat64 st64; -# endif mempcpy (mempcpy (mempcpy (fullname, dir, dirlen), "/", 1), fname, fnamelen + 1); -# ifdef _LIBC - return (*pglob->gl_stat) (fullname, &st) == 0; -# else - return ((__builtin_expect (flags & GLOB_ALTDIRFUNC, 0) - ? (*pglob->gl_stat) (fullname, &st) - : __stat64 (fullname, &st64)) == 0); +# if !defined _LIBC && !HAVE_FSTATAT + if (__builtin_expect ((flags & GLOB_ALTDIRFUNC) == 0, 1)) + { + struct_stat64 st64; + return __stat64 (fullname, &st64); + } # endif + return (*pglob->gl_stat) (fullname, &st); } -# ifdef _LIBC -# define link_exists_p(dfd, dirname, dirnamelen, fname, pglob, flags) \ - (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0) \ - ? link_exists2_p (dirname, dirnamelen, fname, pglob) \ - : ({ struct stat64 st64; \ - __fxstatat64 (_STAT_VER, dfd, fname, &st64, 0) == 0; })) + +/* Return true if DIR/FNAME exists. */ +static int +link_exists_p (int dfd, const char *dir, size_t dirlen, const char *fname, + glob_t *pglob, int flags) +{ + int status; +# if defined _LIBC || HAVE_FSTATAT + if (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0)) + status = link_stat (dir, dirlen, fname, pglob); + else + { + /* dfd cannot be -1 here, because dirfd never returns -1 on + glibc, or on hosts that have fstatat. */ + struct_stat64 st64; + status = __fxstatat64 (_STAT_VER, dfd, fname, &st64, 0); + } # else -# define link_exists_p(dfd, dirname, dirnamelen, fname, pglob, flags) \ - link_exists2_p (dirname, dirnamelen, fname, pglob, flags) + status = link_stat (dir, dirlen, fname, pglob, flags); # endif -#endif + return status == 0 || errno == EOVERFLOW; +} +#endif /* !defined GLOB_ONLY_P */ /* Like `glob', but PATTERN is a final pathname component, @@ -1492,6 +1595,7 @@ glob_in_dir (const char *pattern, const char *directory, int flags, size_t cur = 0; int meta; int save; + int result; alloca_used += sizeof (init_names); @@ -1516,14 +1620,16 @@ glob_in_dir (const char *pattern, const char *directory, int flags, struct_stat64 st64; } ust; size_t patlen = strlen (pattern); - int alloca_fullname = __libc_use_alloca (alloca_used - + dirlen + 1 + patlen + 1); + size_t fullsize; + bool alloca_fullname + = (! size_add_wrapv (dirlen + 1, patlen + 1, &fullsize) + && glob_use_alloca (alloca_used, fullsize)); char *fullname; if (alloca_fullname) - fullname = alloca_account (dirlen + 1 + patlen + 1, alloca_used); + fullname = alloca_account (fullsize, alloca_used); else { - fullname = malloc (dirlen + 1 + patlen + 1); + fullname = malloc (fullsize); if (fullname == NULL) return GLOB_NOSPACE; } @@ -1531,9 +1637,11 @@ glob_in_dir (const char *pattern, const char *directory, int flags, mempcpy (mempcpy (mempcpy (fullname, directory, dirlen), "/", 1), pattern, patlen + 1); - if ((__builtin_expect (flags & GLOB_ALTDIRFUNC, 0) + if (((__builtin_expect (flags & GLOB_ALTDIRFUNC, 0) ? (*pglob->gl_stat) (fullname, &ust.st) - : __stat64 (fullname, &ust.st64)) == 0) + : __stat64 (fullname, &ust.st64)) + == 0) + || errno == EOVERFLOW) /* We found this file to be existing. Now tell the rest of the function to copy this name into the result. */ flags |= GLOB_NOCHECK; @@ -1555,10 +1663,8 @@ glob_in_dir (const char *pattern, const char *directory, int flags, } else { -#ifdef _LIBC int dfd = (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0) ? -1 : dirfd ((DIR *) stream)); -#endif int fnm_flags = ((!(flags & GLOB_PERIOD) ? FNM_PERIOD : 0) | ((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0) #if defined _AMIGA || defined VMS @@ -1607,7 +1713,7 @@ glob_in_dir (const char *pattern, const char *directory, int flags, size_t size = (sizeof (struct globnames) + ((count - INITIAL_COUNT) * sizeof (char *))); - if (__libc_use_alloca (alloca_used + size)) + if (glob_use_alloca (alloca_used, size)) newnames = names_alloca = alloca_account (size, alloca_used); else if ((newnames = malloc (size)) @@ -1623,6 +1729,8 @@ glob_in_dir (const char *pattern, const char *directory, int flags, goto memory_error; ++cur; ++nfound; + if (SIZE_MAX - pglob->gl_offs <= nfound) + goto memory_error; } } } @@ -1633,36 +1741,35 @@ glob_in_dir (const char *pattern, const char *directory, int flags, { size_t len = strlen (pattern); nfound = 1; - names->name[cur] = (char *) malloc (len + 1); + names->name[cur] = malloc (len + 1); if (names->name[cur] == NULL) goto memory_error; *((char *) mempcpy (names->name[cur++], pattern, len)) = '\0'; } - int result = GLOB_NOMATCH; + result = GLOB_NOMATCH; if (nfound != 0) { + char **new_gl_pathv; result = 0; - if (pglob->gl_pathc > UINTPTR_MAX - pglob->gl_offs - || pglob->gl_pathc + pglob->gl_offs > UINTPTR_MAX - nfound - || pglob->gl_pathc + pglob->gl_offs + nfound > UINTPTR_MAX - 1 - || (pglob->gl_pathc + pglob->gl_offs + nfound + 1 - > UINTPTR_MAX / sizeof (char *))) + if (SIZE_MAX / sizeof (char *) - pglob->gl_pathc + < pglob->gl_offs + nfound + 1) goto memory_error; - char **new_gl_pathv; new_gl_pathv - = (char **) realloc (pglob->gl_pathv, - (pglob->gl_pathc + pglob->gl_offs + nfound + 1) - * sizeof (char *)); + = realloc (pglob->gl_pathv, + (pglob->gl_pathc + pglob->gl_offs + nfound + 1) + * sizeof (char *)); + if (new_gl_pathv == NULL) { memory_error: while (1) { struct globnames *old = names; - for (size_t i = 0; i < cur; ++i) + size_t i; + for (i = 0; i < cur; ++i) free (names->name[i]); names = names->next; /* NB: we will not leak memory here if we exit without @@ -1687,7 +1794,8 @@ glob_in_dir (const char *pattern, const char *directory, int flags, while (1) { struct globnames *old = names; - for (size_t i = 0; i < cur; ++i) + size_t i; + for (i = 0; i < cur; ++i) new_gl_pathv[pglob->gl_offs + pglob->gl_pathc++] = names->name[i]; names = names->next; diff --git a/posix/globtest.c b/posix/globtest.c index 878ae33..7ffcb91 100644 --- a/posix/globtest.c +++ b/posix/globtest.c @@ -114,5 +114,8 @@ main (int argc, char *argv[]) g.gl_pathv[i] ? g.gl_pathv[i] : "(null)", quotes ? "'" : ""); } + + globfree (&g); + return 0; } diff --git a/sysdeps/unix/sysv/linux/i386/glob64.c b/sysdeps/unix/sysv/linux/i386/glob64.c index 956cb04..e825b7c 100644 --- a/sysdeps/unix/sysv/linux/i386/glob64.c +++ b/sysdeps/unix/sysv/linux/i386/glob64.c @@ -71,6 +71,8 @@ libc_hidden_proto (__old_glob64); #define GLOB_ONLY_P 1 +#define GLOB_COMPAT_BUILD 1 + #include libc_hidden_def (__old_glob64); From patchwork Tue Aug 22 18:21:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 110694 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp3055976qge; Tue, 22 Aug 2017 11:21:37 -0700 (PDT) X-Received: by 10.98.218.28 with SMTP id c28mr85487pfh.4.1503426096997; Tue, 22 Aug 2017 11:21:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503426096; cv=none; d=google.com; s=arc-20160816; b=pOCGzlSNhiXanejVcMPM4MaXfjzFY85k7jKHKRmzzh055mmhabkGPcecyMI/GN7tjo HOjGVKY6lpSrf15Cvan6B8iEk5EmW5rP8TfoaYQuDipnJLtmJ20p5QZObcqNpIsQbRL4 HEgYSCHzYF+eVyMOZbdo36HSCV2dKPGmfSQevSLOTvqieNgeBBfWj8YCqr1ZXgE7X79Z +w1o39yQBriZSUM1Kk2Mhh3DyW4xF8aM3dtX6Xpr3wGPIzESmSQcRsYrtnZ4dWjtWktY 59nsDkt2TdCuW4l7OnTEC4NFim9FuuoRi4LhZklZuqiuCTVJZn8CMopmv9nrVYx2DLLf cDHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :delivered-to:sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=3GCBBRcmB3PVH6fgyiIybp4cUeuO4mDRZFOaZelLC40=; b=nr08/rV3jmk16d+PWv/0cY1e0ETIpr6BzHTDSRHfN47QNIMi073bGUg34W26s/1E1O QLxDTI3bwb05d98Trb1gXwm999LqQ90W64NsqpmtKt2/P50C1ec8/DEpKzkU8fQSkY0q no1P+jnnFcmKNnns5S3RyKUzvALgYfWyTgJ5iugj6RQukLFK4J3jEqcrEmhvdL1waaZx zWKvl5dQWkGvioT/I8bk1Kr4jsKoHPEydH4mFxfkijwkcYl3ohZia1oHPt/t1dz0kJ84 3WHw4mVlEOJ225eak1ektAXsKgr7ymQ7CdVV+b9tkMwDWraIEcMAiN0MUu4PYk+x2UKP kYcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=Mcr0BF1v; spf=pass (google.com: domain of libc-alpha-return-83664-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-83664-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id s65si6333471pfd.524.2017.08.22.11.21.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Aug 2017 11:21:36 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-83664-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=Mcr0BF1v; spf=pass (google.com: domain of libc-alpha-return-83664-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-83664-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=LKDBl/0rf2JKNN+lmBZNYmFFI0DF1Or blHvymQrcua1Y2hIgMwq3YPj4ujldR9BgTOuaAsQv/Y+A5OKPgrwvmRV5l0ngeaR cHCxUr/6/X81FBfyAs80DR/KznuoGwN7tBHMASZWeZaJrXiKzxivVt9Pdhrl8rj0 vFPXjeuGpZkA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=LyAW8EywJMQSECZD1z/BQS969eE=; b=Mcr0B F1vxC2baM492gfR3IvGu04E94zHZkdnVi6nV0D67/nyhm+xuf1qUEZYqfsY8u8Tl zp+QmuCWdod8pFrw2cY8ViDPdduxLDVd0FVAGYzSXYhlo21Ai8eaujsaCGWDoX1p FE4hw9qAiTqE2SG+p2txiJj0nUbSnjMVr6b4BA= Received: (qmail 70072 invoked by alias); 22 Aug 2017 18:21:21 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 69990 invoked by uid 89); 22 Aug 2017 18:21:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qk0-f173.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3GCBBRcmB3PVH6fgyiIybp4cUeuO4mDRZFOaZelLC40=; b=BJuu7TSQFT7lN9VKwwpIUdAiaDSDxymAqgopzCYOVlhuh8Iyi1LGnLNFqr7O7h5uZr PDKCArJY7Hnn1NIkXX1E7AiawknFIeJjcZ7OvOihWTCgsZi+V8b2G8V7RwOu/4h/SM1m ezNpTwO4dUBSTXxXT2fSoCC63Lt/Hgo6+hKmK7q4gWs/N8YN1B2WJuS4w7xwlJBSRVZ0 RLXMb2Ex2R/BGy4ynA55tpw7WT4RCW9Qy+10K4Oc6+NZtl9MUyy7RF2iPGEuiZrr/BPX 92rKd1a4gjRJTJgFwqxZ4NUSH07XwDEnmOwuSBxryHMNPwPFb7a+rf9nB0TVXtgb4lAu xbPQ== X-Gm-Message-State: AHYfb5h4xOa/ujFPZyYkrjK3GH1P6gJdV3kDIXXH7/VFgFPpg8cJ+HJq Uxxg6PCTD7ldmZP3KIk5hQ== X-Received: by 10.55.128.1 with SMTP id b1mr119286qkd.76.1503426073368; Tue, 22 Aug 2017 11:21:13 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Paul Eggert Subject: [PATCH 2/3] posix: De-couple code from gnulib Date: Tue, 22 Aug 2017 15:21:03 -0300 Message-Id: <1503426064-2827-3-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1503426064-2827-1-git-send-email-adhemerval.zanella@linaro.org> References: <1503426064-2827-1-git-send-email-adhemerval.zanella@linaro.org> This patch removed unecessary code for non-supported platforms and modes (basically windows and amiga) from glob. It also fixes some ifdef indentations. No code change is expected. Tested on x86_64-linux-gnu. * posix/glob.c (glob_in_dir): Remove win32 and amiga support. (glob): Likewise. (prefix_array): Likewise. (glob_in_dir): Likewise. --- posix/glob.c | 296 ++++++++++++++++------------------------------------------- 1 file changed, 78 insertions(+), 218 deletions(-) -- 2.7.4 diff --git a/posix/glob.c b/posix/glob.c index 5e4b7fc..d33f9ab 100644 --- a/posix/glob.c +++ b/posix/glob.c @@ -15,91 +15,71 @@ License along with the GNU C Library; if not, see . */ -#ifndef _LIBC -/* Don't use __attribute__ __nonnull__ in this compilation unit. Otherwise gcc - optimizes away the pattern == NULL || pglob == NULL tests below. */ -# define _GL_ARG_NONNULL(params) -# include -#endif - #include - #include #include #include #include #include #include - -/* Outcomment the following line for production quality code. */ -/* #define NDEBUG 1 */ #include -#include /* Needed on stupid SunOS for assert. */ - #ifndef GLOB_ONLY_P +# include +# if !defined POSIX && defined _POSIX_VERSION +# define POSIX +# endif -#include -#if !defined POSIX && defined _POSIX_VERSION -# define POSIX -#endif +# include -#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ -# define WINDOWS32 -#endif +# include +# ifndef __set_errno +# define __set_errno(val) errno = (val) +# endif -#ifndef WINDOWS32 -# include -#endif +# include +# include +# include +# include -#include -#ifndef __set_errno -# define __set_errno(val) errno = (val) -#endif +# ifdef _LIBC +# undef strdup +# define strdup(str) __strdup (str) +# define sysconf(id) __sysconf (id) +# define closedir(dir) __closedir (dir) +# define opendir(name) __opendir (name) +# define readdir(str) __readdir64 (str) +# define getpwnam_r(name, bufp, buf, len, res) \ + __getpwnam_r (name, bufp, buf, len, res) +# ifndef __stat64 +# define __stat64(fname, buf) __xstat64 (_STAT_VER, fname, buf) +# endif +# define struct_stat64 struct stat64 +# else /* !_LIBC */ +# define __getlogin_r(buf, len) getlogin_r (buf, len) +# define __stat64(fname, buf) stat (fname, buf) +# define __fxstatat64(_, d, f, st, flag) fstatat (d, f, st, flag) +# define struct_stat64 struct stat +# ifndef __MVS__ +# define __alloca alloca +# endif +# define __readdir readdir +# define __glob_pattern_p glob_pattern_p +# define COMPILE_GLOB64 +# endif /* _LIBC */ + +# include -#include -#include -#include -#include - -#ifdef _LIBC -# undef strdup -# define strdup(str) __strdup (str) -# define sysconf(id) __sysconf (id) -# define closedir(dir) __closedir (dir) -# define opendir(name) __opendir (name) -# define readdir(str) __readdir64 (str) -# define getpwnam_r(name, bufp, buf, len, res) \ - __getpwnam_r (name, bufp, buf, len, res) -# ifndef __stat64 -# define __stat64(fname, buf) __xstat64 (_STAT_VER, fname, buf) +# ifdef _SC_GETPW_R_SIZE_MAX +# define GETPW_R_SIZE_MAX() sysconf (_SC_GETPW_R_SIZE_MAX) +# else +# define GETPW_R_SIZE_MAX() (-1) # endif -# define struct_stat64 struct stat64 -#else /* !_LIBC */ -# define __getlogin_r(buf, len) getlogin_r (buf, len) -# define __stat64(fname, buf) stat (fname, buf) -# define __fxstatat64(_, d, f, st, flag) fstatat (d, f, st, flag) -# define struct_stat64 struct stat -# ifndef __MVS__ -# define __alloca alloca +# ifdef _SC_LOGIN_NAME_MAX +# define GET_LOGIN_NAME_MAX() sysconf (_SC_LOGIN_NAME_MAX) +# else +# define GET_LOGIN_NAME_MAX() (-1) # endif -# define __readdir readdir -# define __glob_pattern_p glob_pattern_p -# define COMPILE_GLOB64 -#endif /* _LIBC */ - -#include - -#ifdef _SC_GETPW_R_SIZE_MAX -# define GETPW_R_SIZE_MAX() sysconf (_SC_GETPW_R_SIZE_MAX) -#else -# define GETPW_R_SIZE_MAX() (-1) -#endif -#ifdef _SC_LOGIN_NAME_MAX -# define GET_LOGIN_NAME_MAX() sysconf (_SC_LOGIN_NAME_MAX) -#else -# define GET_LOGIN_NAME_MAX() (-1) -#endif static const char *next_brace_sub (const char *begin, int flags) __THROWNL; @@ -151,7 +131,7 @@ readdir_result_might_be_dir (struct readdir_result d) # endif /* defined _DIRENT_HAVE_D_TYPE || defined HAVE_STRUCT_DIRENT_D_TYPE */ -# if (defined POSIX || defined WINDOWS32) && !defined __GNU_LIBRARY__ +# if defined _LIBC || defined D_INO_IN_DIRENT /* Initializer for skip_entry. POSIX does not require that the d_ino field be present, and some systems do not provide it. */ # define D_INO_TO_RESULT(source) false, @@ -161,20 +141,20 @@ readdir_result_might_be_dir (struct readdir_result d) /* Construct an initializer for a struct readdir_result object from a struct dirent *. No copy of the name is made. */ -#define READDIR_RESULT_INITIALIZER(source) \ +# define READDIR_RESULT_INITIALIZER(source) \ { \ source->d_name, \ D_TYPE_TO_RESULT (source) \ D_INO_TO_RESULT (source) \ } -#endif /* !defined GLOB_ONLY_P */ +# endif /* !defined GLOB_ONLY_P */ /* Call gl_readdir on STREAM. This macro can be overridden to reduce type safety if an old interface version needs to be supported. */ -#ifndef GL_READDIR -# define GL_READDIR(pglob, stream) ((pglob)->gl_readdir (stream)) -#endif +# ifndef GL_READDIR +# define GL_READDIR(pglob, stream) ((pglob)->gl_readdir (stream)) +# endif /* Extract name and type from directory entry. No copy of the name is made. If SOURCE is NULL, result name is NULL. Keep in sync with @@ -191,7 +171,7 @@ convert_dirent (const struct dirent *source) return result; } -#ifndef COMPILE_GLOB64 +# ifndef COMPILE_GLOB64 /* Like convert_dirent, but works on struct dirent64 instead. Keep in sync with convert_dirent above. */ static struct readdir_result @@ -205,44 +185,27 @@ convert_dirent64 (const struct dirent64 *source) struct readdir_result result = READDIR_RESULT_INITIALIZER (source); return result; } -#endif - - -#ifndef attribute_hidden -# define attribute_hidden -#endif - -#ifndef __attribute_noinline__ -# if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 1) -# define __attribute_noinline__ /* Ignore */ -#else -# define __attribute_noinline__ __attribute__ ((__noinline__)) # endif -#endif - -#ifndef __glibc_unlikely -# define __glibc_unlikely(expr) __builtin_expect (expr, 0) -#endif -#ifndef _LIBC +# ifndef _LIBC /* The results of opendir() in this file are not used with dirfd and fchdir, and we do not leak fds to any single-threaded code that could use stdio, therefore save some unnecessary recursion in fchdir.c and opendir_safer.c. FIXME - if the kernel ever adds support for multi-thread safety for avoiding standard fds, then we should use opendir_safer. */ -# ifdef GNULIB_defined_opendir -# undef opendir -# endif -# ifdef GNULIB_defined_closedir -# undef closedir -# endif +# ifdef GNULIB_defined_opendir +# undef opendir +# endif +# ifdef GNULIB_defined_closedir +# undef closedir +# endif /* Just use malloc. */ -# define __libc_use_alloca(n) false -# define alloca_account(len, avar) ((void) (len), (void) (avar), (void *) 0) -# define extend_alloca_account(buf, len, newlen, avar) \ +# define __libc_use_alloca(n) false +# define alloca_account(len, avar) ((void) (len), (void) (avar), (void *) 0) +# define extend_alloca_account(buf, len, newlen, avar) \ ((void) (buf), (void) (len), (void) (newlen), (void) (avar), (void *) 0) -#endif +# endif /* Set *R = A + B. Return true if the answer is mathematically incorrect due to overflow; in this case, *R is the low order @@ -252,16 +215,16 @@ static bool size_add_wrapv (size_t a, size_t b, size_t *r); static bool glob_use_alloca (size_t alloca_used, size_t len); /* We must not compile this function twice. */ -#ifndef GLOB_COMPAT_BUILD +# ifndef GLOB_COMPAT_BUILD static bool size_add_wrapv (size_t a, size_t b, size_t *r) { -#if 5 <= __GNUC__ +# if 5 <= __GNUC__ return __builtin_add_overflow (a, b, r); -#else +# else *r = a + b; return *r < a; -#endif +# endif } static bool @@ -271,7 +234,7 @@ glob_use_alloca (size_t alloca_used, size_t len) return (!size_add_wrapv (alloca_used, len, &size) && __libc_use_alloca (size)); } -#endif +#endif /* GLOB_ONLY_P */ static int glob_in_dir (const char *pattern, const char *directory, int flags, int (*errfunc) (const char *, int), @@ -514,14 +477,6 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), /* Find the filename. */ filename = strrchr (pattern, '/'); -#if defined __MSDOS__ || defined WINDOWS32 - /* The case of "d:pattern". Since `:' is not allowed in - file names, we can safely assume that wherever it - happens in pattern, it signals the filename part. This - is so we could some day support patterns like "[a-z]:foo". */ - if (filename == NULL) - filename = strchr (pattern, ':'); -#endif /* __MSDOS__ || WINDOWS32 */ dirname_modified = 0; if (filename == NULL) { @@ -546,11 +501,7 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), } filename = pattern; -#ifdef _AMIGA - dirname = (char *) ""; -#else dirname = (char *) "."; -#endif dirlen = 0; } } @@ -567,24 +518,6 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), { char *newp; dirlen = filename - pattern; -#if defined __MSDOS__ || defined WINDOWS32 - if (*filename == ':' - || (filename > pattern + 1 && filename[-1] == ':')) - { - char *drive_spec; - - ++dirlen; - drive_spec = __alloca (dirlen + 1); - *((char *) mempcpy (drive_spec, pattern, dirlen)) = '\0'; - /* For now, disallow wildcards in the drive spec, to - prevent infinite recursion in glob. */ - if (__glob_pattern_p (drive_spec, !(flags & GLOB_NOESCAPE))) - return GLOB_NOMATCH; - /* If this is "d:pattern", we need to copy ':' to DIRNAME - as well. If it's "d:/pattern", don't remove the slash - from "d:/", since "d:" and "d:/" are not the same.*/ - } -#endif if (glob_use_alloca (alloca_used, dirlen + 1)) newp = alloca_account (dirlen + 1, alloca_used); else @@ -598,13 +531,7 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), dirname = newp; ++filename; - if (filename[0] == '\0' -#if defined __MSDOS__ || defined WINDOWS32 - && dirname[dirlen - 1] != ':' - && (dirlen < 3 || dirname[dirlen - 2] != ':' - || dirname[dirlen - 1] != '/') -#endif - && dirlen > 1) + if (filename[0] == '\0' && dirlen > 1) /* "pattern/". Expand "pattern", appending slashes. */ { int orig_flags = flags; @@ -648,32 +575,6 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), /* Look up home directory. */ char *home_dir = getenv ("HOME"); int malloc_home_dir = 0; -# ifdef _AMIGA - if (home_dir == NULL || home_dir[0] == '\0') - home_dir = "SYS:"; -# else -# ifdef WINDOWS32 - /* Windows NT defines HOMEDRIVE and HOMEPATH. But give preference - to HOME, because the user can change HOME. */ - if (home_dir == NULL || home_dir[0] == '\0') - { - const char *home_drive = getenv ("HOMEDRIVE"); - const char *home_path = getenv ("HOMEPATH"); - - if (home_drive != NULL && home_path != NULL) - { - size_t home_drive_len = strlen (home_drive); - size_t home_path_len = strlen (home_path); - char *mem = alloca (home_drive_len + home_path_len + 1); - - memcpy (mem, home_drive, home_drive_len); - memcpy (mem + home_drive_len, home_path, home_path_len + 1); - home_dir = mem; - } - else - home_dir = "c:/users/default"; /* poor default */ - } -# else if (home_dir == NULL || home_dir[0] == '\0') { int success; @@ -815,8 +716,6 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), malloc_home_dir = 0; } } -# endif /* WINDOWS32 */ -# endif /* Now construct the full directory. */ if (dirname[1] == '\0') { @@ -861,7 +760,6 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), } dirname_modified = 1; } -# if !defined _AMIGA && !defined WINDOWS32 else { char *end_name = strchr (dirname, '/'); @@ -1039,7 +937,6 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), } } } -# endif /* Not Amiga && not WINDOWS32. */ } /* Now test whether we looked for "~" or "~NAME". In this case we @@ -1167,20 +1064,6 @@ glob (const char *pattern, int flags, int (*errfunc) (const char *, int), { size_t old_pathc; -#ifdef SHELL - { - /* Make globbing interruptible in the bash shell. */ - extern int interrupt_state; - - if (interrupt_state) - { - globfree (&dirs); - retval = GLOB_ABORTED; - goto out; - } - } -#endif /* SHELL. */ - old_pathc = pglob->gl_pathc; status = glob_in_dir (filename, dirs.gl_pathv[i], ((flags | GLOB_APPEND) @@ -1387,9 +1270,9 @@ globfree (glob_t *pglob) pglob->gl_pathv = NULL; } } -#if defined _LIBC && !defined globfree +# if defined _LIBC && !defined globfree libc_hidden_def (globfree) -#endif +# endif /* Do a collated comparison of A and B. */ @@ -1418,31 +1301,12 @@ prefix_array (const char *dirname, char **array, size_t n) { size_t i; size_t dirlen = strlen (dirname); -#if defined __MSDOS__ || defined WINDOWS32 - int sep_char = '/'; -# define DIRSEP_CHAR sep_char -#else # define DIRSEP_CHAR '/' -#endif if (dirlen == 1 && dirname[0] == '/') /* DIRNAME is just "/", so normal prepending would get us "//foo". We want "/foo" instead, so don't prepend any chars from DIRNAME. */ dirlen = 0; -#if defined __MSDOS__ || defined WINDOWS32 - else if (dirlen > 1) - { - if (dirname[dirlen - 1] == '/' && dirname[dirlen - 2] == ':') - /* DIRNAME is "d:/". Don't prepend the slash from DIRNAME. */ - --dirlen; - else if (dirname[dirlen - 1] == ':') - { - /* DIRNAME is "d:". Use `:' instead of `/'. */ - --dirlen; - sep_char = ':'; - } - } -#endif for (i = 0; i < n; ++i) { @@ -1469,7 +1333,7 @@ prefix_array (const char *dirname, char **array, size_t n) /* We must not compile this function twice. */ -#ifndef NO_GLOB_PATTERN_P +# ifndef NO_GLOB_PATTERN_P int __glob_pattern_type (const char *pattern, int quote) { @@ -1512,10 +1376,10 @@ __glob_pattern_p (const char *pattern, int quote) { return __glob_pattern_type (pattern, quote) == 1; } -# ifdef _LIBC +# ifdef _LIBC weak_alias (__glob_pattern_p, glob_pattern_p) +# endif # endif -#endif /* We put this in a separate function mainly to allow the memory @@ -1666,11 +1530,7 @@ glob_in_dir (const char *pattern, const char *directory, int flags, int dfd = (__builtin_expect (flags & GLOB_ALTDIRFUNC, 0) ? -1 : dirfd ((DIR *) stream)); int fnm_flags = ((!(flags & GLOB_PERIOD) ? FNM_PERIOD : 0) - | ((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0) -#if defined _AMIGA || defined VMS - | FNM_CASEFOLD -#endif - ); + | ((flags & GLOB_NOESCAPE) ? FNM_NOESCAPE : 0)); flags |= GLOB_MAGCHAR; while (1) From patchwork Tue Aug 22 18:21:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 110696 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp3056487qge; Tue, 22 Aug 2017 11:22:06 -0700 (PDT) X-Received: by 10.84.140.235 with SMTP id 98mr94523plt.30.1503426126716; Tue, 22 Aug 2017 11:22:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503426126; cv=none; d=google.com; s=arc-20160816; b=E08eg+5D4nKArzIvQjSwEq6++xdAm7mKgqAe9Jyvj6WdwkGk0MN9aJoLsIECNleykC iXtcrr16FwiL9QrZ/gDSuqaD45w0a+TBGs8oshesyuZkcePpLCdYDG0Rh3m9VvObIfv9 +jrL/0wh2imbN3ME/s1K3ozvB+FTd1eXkxqh9X6sD21QyxRKNM2BGWtkKfWQyfaZX1eI Gj/W1EZK106trkiA9s3qSv8DSCRvT1FMuHn54gny2RfqQG7j7g2q/mZcJz07eaioHJLR CEI14VgOSy1/lTG61AsSaC8dTL5iewkTqdyZu6A50jSof9dezregEeeOmjTNLU1y+EoL Ap0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :delivered-to:sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=qM3EFX0AXyMeuU1j2JXP9I0Qirfga7a6p6xsSAp8m6U=; b=0SDvYGN0KPG0HSi2DkTj+3dBp7R4Xt+7Ba0B3aB4+TlUeCxest7LoTZ/3y2yLFG9oD oxnLj5V7TkAuSfaDlIcEpq3MIEwfgk00dZToYHJLxaoGWfuUlJgOGAYqLZH2ren2kVjd Dik5G43xRpZnUtJvN6G/Up3yEfD8zjee7m0o3zvJ8yaofv3hljYeepuefODkot6QB09O Xi/4ulE2Jm2wWzMZR6pN8aP++eIzMFj4fVTRxAMqqgIERQh4dkYpruDQMG8vqnl1PBgV 3SHqo8GQg9gGVAQRE9bCROZG0tSzJ72Xpd7jbRtcyp5BFTl+9cnK3TeF3kbVLfWqqiP/ Oi2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=Bcwui+lt; spf=pass (google.com: domain of libc-alpha-return-83666-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-83666-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id s10si10061160plj.120.2017.08.22.11.22.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Aug 2017 11:22:06 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-83666-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=Bcwui+lt; spf=pass (google.com: domain of libc-alpha-return-83666-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-83666-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=dVaJaijtPSA8nu7NAxQK6y2IvgAf55M I3xWwKyZOZBMxvybAwwyq+or0yYCS2wkOfMaiQVhhVgsOb7eO5PYZFKqEACjalTh S1Z8ktFakpBBxALgsQIJxhKeeVbeQgG35dp4jAHe4vzqNgJx9ECMyHE+Rp+TO3/C Ua2XfCMBc3dw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=mNusTqq7yQPVaFT8kgwXFEtiq8k=; b=Bcwui +lt813p0eFwhyAzgWOXwWvMcyZNPEG3qlVzIBuPZ/fE2RTlQtQ91ErrZQwQWjNey C5ggvxjARrIryTGHjc/7hu/PzkPsrnvKsRRdB/8vIQ0TJE7Z3XSwB4fxnyUDx7+t 3SN9bmnknLuLlemUMsL+9sBT+hHPXp86JRnxMU= Received: (qmail 71191 invoked by alias); 22 Aug 2017 18:21:30 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 70652 invoked by uid 89); 22 Aug 2017 18:21:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS, UNWANTED_LANGUAGE_BODY autolearn=ham version=3.3.2 spammy= X-HELO: mail-qk0-f175.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=qM3EFX0AXyMeuU1j2JXP9I0Qirfga7a6p6xsSAp8m6U=; b=hFIWzcULGwZxcUTIURjO+OY7xmlNoTrUGcoKE+dwXyMoZS0ICwj6zuv92h6T3Khe+7 zI0AwWROw+6oT9B1AaKoYK3f4ZuF55xkrtCOujGM3Rf/36WvEm6AJRHl2f+x0NvNzOk8 kvr8khbVa+OrwQEke8+moyKA/JghtorRWiLtTO61VYdaMMopQdT+sV7FRzmi6EobNgQf 7s92ayoikJvWvabo0juWWvRGa0OGEg75vwMWJc8pB6asUGcQyhH+CkSgK+rdwv168JUa cCLYUXet+X9dVFnU5opcJ6UzBZv38WgpXut9jDkEQ6wd2bzpwh7qClYAL65uC6IyKruW 0wFQ== X-Gm-Message-State: AHYfb5hYCpusdsApsauIag3wtg0iU+6Hn8xckchtdLCYymZtnO945LT+ if67bQWF0UBMEYdwSeS51g== X-Received: by 10.55.186.193 with SMTP id k184mr112187qkf.48.1503426075275; Tue, 22 Aug 2017 11:21:15 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Paul Eggert Subject: [PATCH 3/3] posix: Consolidate glob implementation Date: Tue, 22 Aug 2017 15:21:04 -0300 Message-Id: <1503426064-2827-4-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1503426064-2827-1-git-send-email-adhemerval.zanella@linaro.org> References: <1503426064-2827-1-git-send-email-adhemerval.zanella@linaro.org> This patch consolidates the glob implementation. The main changes are: * Remove specific defines required for multiple compilation in same unit (GLOB_ONLY_P, NO_GLOB_PATTERN_P and GLOB_COMPAT_BUILD). To allow using the same code to build compat version on Linux, extra units are used instead (oldglob.c). * Both globfree and GNU extension glob_pattern_p are now on their own files. This simplifies the creation of compat symbol when required. * Also similar to glob/glob64, a new globfree64 is file is added with an empty implementation as default. * On Linux all implementation now uses a default one with the exception of alpha (which requires specific versioning) and s390-32 (which different than other 32 bits with support for v2.1 symbol does not add a compat one). * Move i386 olddirent.h header to Linux default directory, since it is the only header with this name and it is shared among different architectures (and used on compat glob symbol as well). Checked on x86_64-linux-gnu and i686-linux-gnu. * posix/Makefile (routines): Add globfree, globfree64, and glob_pattern_p. * posix/glob.c: Remove GLOB_ONLY_P, GLOB_COMPAT_BUILD, and NO_GLOB_PATTERN_P define usage. (globfree): Move to its own file. (__glob_pattern_type): Likewise. (__glob_pattern_p): Likewise. * posix/glob_internal.h: New file. * posix/glob_pattern_p.c: Likewise. * posix/globfree.c: Likewise. * posix/globfree64.c: Likewise. * sysdeps/gnu/glob64.c: Remove file. * sysdeps/unix/sysv/linux/Makefile (sysdep_routines): Add oldglob. * sysdeps/unix/sysv/linux/alpha/Makefile [$(subdir) = posix] (sysdep_routines): Remove rule. * sysdeps/unix/sysv/linux/alpha/glob.c: Remove file. * sysdeps/unix/sysv/linux/arm/glob64.c: Likewise. * sysdeps/wordsize-64/glob.c: Likewise. * sysdeps/unix/sysv/linux/m68k/glob64.c: Likewise. * sysdeps/unix/sysv/linux/mips/mips64/n64/glob64.c: Likewise. * sysdeps/unix/sysv/linux/powerpc/powerpc32/glob64.c: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/glob64.c: Likewise. * sysdeps/unix/sysv/linux/wordsize-64/glob64.c: Likewise. * sysdeps/unix/sysv/linux/x86_64/x32/glob.c: Likewise. * sysdeps/wordsize-64/glob64.c: Likewise. * sysdeps/unix/sysv/linux/alpha/glob64.c: New file. * sysdeps/unix/sysv/linux/alpha/globfree.c: Likewise. * sysdeps/unix/sysv/linux/glob.c: Likewise. * sysdeps/unix/sysv/linux/glob64.c: Likewise. * sysdeps/unix/sysv/linux/globfree.c: Likewise. * sysdeps/unix/sysv/linux/globfree64.c: Likewise. * sysdeps/unix/sysv/linux/i386/alphasort64.c: include olddirent.h using relative path instead of absolute one. * sysdeps/unix/sysv/linux/i386/getdents64.c: Likewise. * sysdeps/unix/sysv/linux/i386/readdir64.c: Likewise. * sysdeps/unix/sysv/linux/i386/readdir64_r.c: Likewise. * sysdeps/unix/sysv/linux/i386/versionsort64.c: Likewise. * sysdeps/unix/sysv/linux/i386/olddirent.h: Move to ... * sysdeps/unix/sysv/linux/olddirent.h: ... here. * sysdeps/unix/sysv/linux/i386/glob64.c: Move to ... * sysdeps/unix/sysv/linux/oldglob.c: ... here. * sysdeps/unix/sysv/linux/i386/glob64.c: Remove file. * sysdeps/unix/sysv/linux/oldglob.c: New file. * sysdeps/unix/sysv/linux/s390/s390-32/glob64.c: New file. * sysdeps/unix/sysv/linux/s390/s390-32/oldglob.c: Likewise. --- posix/Makefile | 2 +- posix/glob.c | 187 ++++++--------------- posix/glob_internal.h | 57 +++++++ posix/glob_pattern_p.c | 29 ++++ posix/globfree.c | 37 ++++ posix/globfree64.c | 27 +++ sysdeps/gnu/glob64.c | 25 --- sysdeps/unix/sysv/linux/Makefile | 2 +- sysdeps/unix/sysv/linux/alpha/Makefile | 4 - sysdeps/unix/sysv/linux/alpha/{glob.c => glob64.c} | 11 -- sysdeps/unix/sysv/linux/alpha/globfree.c | 36 ++++ sysdeps/unix/sysv/linux/arm/glob64.c | 1 - sysdeps/unix/sysv/linux/glob.c | 23 +++ sysdeps/unix/sysv/linux/glob64.c | 55 ++++++ sysdeps/unix/sysv/linux/globfree.c | 23 +++ sysdeps/unix/sysv/linux/globfree64.c | 0 sysdeps/unix/sysv/linux/i386/alphasort64.c | 2 +- sysdeps/unix/sysv/linux/i386/getdents64.c | 2 +- sysdeps/unix/sysv/linux/i386/readdir64.c | 2 +- sysdeps/unix/sysv/linux/i386/readdir64_r.c | 2 +- sysdeps/unix/sysv/linux/i386/versionsort64.c | 2 +- sysdeps/unix/sysv/linux/m68k/glob64.c | 1 - sysdeps/unix/sysv/linux/mips/mips64/n64/glob64.c | 1 - sysdeps/unix/sysv/linux/{i386 => }/olddirent.h | 0 .../unix/sysv/linux/{i386/glob64.c => oldglob.c} | 53 ++---- sysdeps/unix/sysv/linux/powerpc/powerpc32/glob64.c | 1 - sysdeps/unix/sysv/linux/s390/s390-32/glob64.c | 20 +++ sysdeps/unix/sysv/linux/s390/s390-32/oldglob.c | 2 + sysdeps/unix/sysv/linux/sparc/sparc32/glob64.c | 1 - sysdeps/unix/sysv/linux/wordsize-64/glob64.c | 2 - sysdeps/unix/sysv/linux/x86_64/x32/glob.c | 1 - sysdeps/wordsize-64/glob.c | 8 - sysdeps/wordsize-64/glob64.c | 1 - 33 files changed, 384 insertions(+), 236 deletions(-) create mode 100644 posix/glob_internal.h create mode 100644 posix/glob_pattern_p.c create mode 100644 posix/globfree.c create mode 100644 posix/globfree64.c delete mode 100644 sysdeps/gnu/glob64.c rename sysdeps/unix/sysv/linux/alpha/{glob.c => glob64.c} (78%) create mode 100644 sysdeps/unix/sysv/linux/alpha/globfree.c delete mode 100644 sysdeps/unix/sysv/linux/arm/glob64.c create mode 100644 sysdeps/unix/sysv/linux/glob.c create mode 100644 sysdeps/unix/sysv/linux/glob64.c create mode 100644 sysdeps/unix/sysv/linux/globfree.c create mode 100644 sysdeps/unix/sysv/linux/globfree64.c delete mode 100644 sysdeps/unix/sysv/linux/m68k/glob64.c delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n64/glob64.c rename sysdeps/unix/sysv/linux/{i386 => }/olddirent.h (100%) rename sysdeps/unix/sysv/linux/{i386/glob64.c => oldglob.c} (62%) delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/glob64.c create mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/glob64.c create mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/oldglob.c delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc32/glob64.c delete mode 100644 sysdeps/unix/sysv/linux/wordsize-64/glob64.c delete mode 100644 sysdeps/unix/sysv/linux/x86_64/x32/glob.c delete mode 100644 sysdeps/wordsize-64/glob.c delete mode 100644 sysdeps/wordsize-64/glob64.c -- 2.7.4 diff --git a/posix/Makefile b/posix/Makefile index 9b534f0..0ff8f5c 100644 --- a/posix/Makefile +++ b/posix/Makefile @@ -45,7 +45,7 @@ routines := \ getpgid setpgid getpgrp bsd-getpgrp setpgrp getsid setsid \ getresuid getresgid setresuid setresgid \ pathconf sysconf fpathconf \ - glob glob64 fnmatch regex \ + glob glob64 globfree globfree64 glob_pattern_p fnmatch regex \ confstr \ getopt getopt1 \ sched_setp sched_getp sched_sets sched_gets sched_yield sched_primax \ diff --git a/posix/glob.c b/posix/glob.c index d33f9ab..6abfb69 100644 --- a/posix/glob.c +++ b/posix/glob.c @@ -24,62 +24,63 @@ #include #include -#ifndef GLOB_ONLY_P -# include -# if !defined POSIX && defined _POSIX_VERSION -# define POSIX -# endif +#include +#if !defined POSIX && defined _POSIX_VERSION +# define POSIX +#endif -# include +#include -# include -# ifndef __set_errno -# define __set_errno(val) errno = (val) -# endif +#include +#ifndef __set_errno +# define __set_errno(val) errno = (val) +#endif -# include -# include -# include -# include - -# ifdef _LIBC -# undef strdup -# define strdup(str) __strdup (str) -# define sysconf(id) __sysconf (id) -# define closedir(dir) __closedir (dir) -# define opendir(name) __opendir (name) -# define readdir(str) __readdir64 (str) -# define getpwnam_r(name, bufp, buf, len, res) \ +#include +#include +#include +#include + +#ifdef _LIBC +# undef strdup +# define strdup(str) __strdup (str) +# define sysconf(id) __sysconf (id) +# define closedir(dir) __closedir (dir) +# define opendir(name) __opendir (name) +# define readdir(str) __readdir64 (str) +# define getpwnam_r(name, bufp, buf, len, res) \ __getpwnam_r (name, bufp, buf, len, res) -# ifndef __stat64 -# define __stat64(fname, buf) __xstat64 (_STAT_VER, fname, buf) -# endif -# define struct_stat64 struct stat64 -# else /* !_LIBC */ -# define __getlogin_r(buf, len) getlogin_r (buf, len) -# define __stat64(fname, buf) stat (fname, buf) -# define __fxstatat64(_, d, f, st, flag) fstatat (d, f, st, flag) -# define struct_stat64 struct stat -# ifndef __MVS__ -# define __alloca alloca -# endif -# define __readdir readdir -# define __glob_pattern_p glob_pattern_p -# define COMPILE_GLOB64 -# endif /* _LIBC */ - -# include - -# ifdef _SC_GETPW_R_SIZE_MAX -# define GETPW_R_SIZE_MAX() sysconf (_SC_GETPW_R_SIZE_MAX) -# else -# define GETPW_R_SIZE_MAX() (-1) +# ifndef __stat64 +# define __stat64(fname, buf) __xstat64 (_STAT_VER, fname, buf) # endif -# ifdef _SC_LOGIN_NAME_MAX -# define GET_LOGIN_NAME_MAX() sysconf (_SC_LOGIN_NAME_MAX) -# else -# define GET_LOGIN_NAME_MAX() (-1) +# define struct_stat64 struct stat64 +#else /* !_LIBC */ +# define __getlogin_r(buf, len) getlogin_r (buf, len) +# define __stat64(fname, buf) stat (fname, buf) +# define __fxstatat64(_, d, f, st, flag) fstatat (d, f, st, flag) +# define struct_stat64 struct stat +# ifndef __MVS__ +# define __alloca alloca # endif +# define __readdir readdir +# define __glob_pattern_p glob_pattern_p +# define COMPILE_GLOB64 +#endif /* _LIBC */ + +#include + +#include + +#ifdef _SC_GETPW_R_SIZE_MAX +# define GETPW_R_SIZE_MAX() sysconf (_SC_GETPW_R_SIZE_MAX) +#else +# define GETPW_R_SIZE_MAX() (-1) +#endif +#ifdef _SC_LOGIN_NAME_MAX +# define GET_LOGIN_NAME_MAX() sysconf (_SC_LOGIN_NAME_MAX) +#else +# define GET_LOGIN_NAME_MAX() (-1) +#endif static const char *next_brace_sub (const char *begin, int flags) __THROWNL; @@ -148,8 +149,6 @@ readdir_result_might_be_dir (struct readdir_result d) D_INO_TO_RESULT (source) \ } -# endif /* !defined GLOB_ONLY_P */ - /* Call gl_readdir on STREAM. This macro can be overridden to reduce type safety if an old interface version needs to be supported. */ # ifndef GL_READDIR @@ -215,7 +214,6 @@ static bool size_add_wrapv (size_t a, size_t b, size_t *r); static bool glob_use_alloca (size_t alloca_used, size_t len); /* We must not compile this function twice. */ -# ifndef GLOB_COMPAT_BUILD static bool size_add_wrapv (size_t a, size_t b, size_t *r) { @@ -234,7 +232,6 @@ glob_use_alloca (size_t alloca_used, size_t len) return (!size_add_wrapv (alloca_used, len, &size) && __libc_use_alloca (size)); } -#endif /* GLOB_ONLY_P */ static int glob_in_dir (const char *pattern, const char *directory, int flags, int (*errfunc) (const char *, int), @@ -242,7 +239,6 @@ static int glob_in_dir (const char *pattern, const char *directory, extern int __glob_pattern_type (const char *pattern, int quote) attribute_hidden; -#ifndef GLOB_ONLY_P static int prefix_array (const char *prefix, char **array, size_t n) __THROWNL; static int collated_compare (const void *, const void *) __THROWNL; @@ -271,7 +267,6 @@ next_brace_sub (const char *cp, int flags) return *cp != '\0' ? cp : NULL; } -#endif /* !defined GLOB_ONLY_P */ /* Do glob searching for PATTERN, placing results in PGLOB. The bits defined above may be set in FLAGS. @@ -1255,26 +1250,6 @@ libc_hidden_def (glob) #endif -#ifndef GLOB_ONLY_P - -/* Free storage allocated in PGLOB by a previous `glob' call. */ -void -globfree (glob_t *pglob) -{ - if (pglob->gl_pathv != NULL) - { - size_t i; - for (i = 0; i < pglob->gl_pathc; ++i) - free (pglob->gl_pathv[pglob->gl_offs + i]); - free (pglob->gl_pathv); - pglob->gl_pathv = NULL; - } -} -# if defined _LIBC && !defined globfree -libc_hidden_def (globfree) -# endif - - /* Do a collated comparison of A and B. */ static int collated_compare (const void *a, const void *b) @@ -1331,71 +1306,23 @@ prefix_array (const char *dirname, char **array, size_t n) return 0; } - -/* We must not compile this function twice. */ -# ifndef NO_GLOB_PATTERN_P -int -__glob_pattern_type (const char *pattern, int quote) -{ - const char *p; - int ret = 0; - - for (p = pattern; *p != '\0'; ++p) - switch (*p) - { - case '?': - case '*': - return 1; - - case '\\': - if (quote) - { - if (p[1] != '\0') - ++p; - ret |= 2; - } - break; - - case '[': - ret |= 4; - break; - - case ']': - if (ret & 4) - return 1; - break; - } - - return ret; -} - -/* Return nonzero if PATTERN contains any metacharacters. - Metacharacters can be quoted with backslashes if QUOTE is nonzero. */ -int -__glob_pattern_p (const char *pattern, int quote) -{ - return __glob_pattern_type (pattern, quote) == 1; -} -# ifdef _LIBC -weak_alias (__glob_pattern_p, glob_pattern_p) -# endif -# endif - - /* We put this in a separate function mainly to allow the memory allocated with alloca to be recycled. */ static int __attribute_noinline__ link_stat (const char *dir, size_t dirlen, const char *fname, glob_t *pglob -# if !defined _LIBC && !HAVE_FSTATAT +# ifndef _LIBC , int flags # endif ) { size_t fnamelen = strlen (fname); - char *fullname = __alloca (dirlen + 1 + fnamelen + 1); + char *fullname = (char *) __alloca (dirlen + 1 + fnamelen + 1); struct stat st; +# ifndef _LIBC + struct_stat64 st64; +# endif mempcpy (mempcpy (mempcpy (fullname, dir, dirlen), "/", 1), fname, fnamelen + 1); @@ -1431,8 +1358,6 @@ link_exists_p (int dfd, const char *dir, size_t dirlen, const char *fname, # endif return status == 0 || errno == EOVERFLOW; } -#endif /* !defined GLOB_ONLY_P */ - /* Like `glob', but PATTERN is a final pathname component, and matches are searched for in DIRECTORY. diff --git a/posix/glob_internal.h b/posix/glob_internal.h new file mode 100644 index 0000000..d989a98 --- /dev/null +++ b/posix/glob_internal.h @@ -0,0 +1,57 @@ +/* Shared definition for glob and glob_pattern_p. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef GLOB_INTERNAL_H +# define GLOB_INTERNAL_H + +static inline int +__glob_pattern_type (const char *pattern, int quote) +{ + const char *p; + int ret = 0; + + for (p = pattern; *p != '\0'; ++p) + switch (*p) + { + case '?': + case '*': + return 1; + + case '\\': + if (quote) + { + if (p[1] != '\0') + ++p; + ret |= 2; + } + break; + + case '[': + ret |= 4; + break; + + case ']': + if (ret & 4) + return 1; + break; + } + + return ret; +} + +#endif /* GLOB_INTERNAL_H */ diff --git a/posix/glob_pattern_p.c b/posix/glob_pattern_p.c new file mode 100644 index 0000000..6e451f2 --- /dev/null +++ b/posix/glob_pattern_p.c @@ -0,0 +1,29 @@ +/* Return nonzero if PATTERN contains any metacharacters. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include "glob_internal.h" + +/* Return nonzero if PATTERN contains any metacharacters. + Metacharacters can be quoted with backslashes if QUOTE is nonzero. */ +int +__glob_pattern_p (const char *pattern, int quote) +{ + return __glob_pattern_type (pattern, quote) == 1; +} +weak_alias (__glob_pattern_p, glob_pattern_p) diff --git a/posix/globfree.c b/posix/globfree.c new file mode 100644 index 0000000..4ebd142 --- /dev/null +++ b/posix/globfree.c @@ -0,0 +1,37 @@ +/* Frees the dynamically allocated storage from an earlier call to glob. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +/* Free storage allocated in PGLOB by a previous `glob' call. */ +void +globfree (glob_t *pglob) +{ + if (pglob->gl_pathv != NULL) + { + size_t i; + for (i = 0; i < pglob->gl_pathc; ++i) + free (pglob->gl_pathv[pglob->gl_offs + i]); + free (pglob->gl_pathv); + pglob->gl_pathv = NULL; + } +} +#ifndef globfree +libc_hidden_def (globfree) +#endif diff --git a/posix/globfree64.c b/posix/globfree64.c new file mode 100644 index 0000000..cce288e --- /dev/null +++ b/posix/globfree64.c @@ -0,0 +1,27 @@ +/* Frees the dynamically allocated storage from an earlier call to glob. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +/* Free storage allocated in PGLOB by a previous `glob' call. */ +void +globfree64 (glob64_t *pglob) +{ +} +libc_hidden_def (globfree64) diff --git a/sysdeps/gnu/glob64.c b/sysdeps/gnu/glob64.c deleted file mode 100644 index d1e4e6f..0000000 --- a/sysdeps/gnu/glob64.c +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include -#include - -#define dirent dirent64 -#define __readdir(dirp) __readdir64 (dirp) - -#define glob_t glob64_t -#define glob(pattern, flags, errfunc, pglob) \ - glob64 (pattern, flags, errfunc, pglob) -#define globfree(pglob) globfree64 (pglob) - -#undef stat -#define stat stat64 -#undef __stat -#define __stat(file, buf) __xstat64 (_STAT_VER, file, buf) - -#define NO_GLOB_PATTERN_P 1 - -#define COMPILE_GLOB64 1 - -#include - -libc_hidden_def (glob64) -libc_hidden_def (globfree64) diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index 9d6a2de..8847751 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -162,7 +162,7 @@ endif ifeq ($(subdir),posix) sysdep_headers += bits/initspin.h -sysdep_routines += sched_getcpu +sysdep_routines += sched_getcpu oldglob tests += tst-affinity tst-affinity-pid diff --git a/sysdeps/unix/sysv/linux/alpha/Makefile b/sysdeps/unix/sysv/linux/alpha/Makefile index 47bd189..50f4fb1 100644 --- a/sysdeps/unix/sysv/linux/alpha/Makefile +++ b/sysdeps/unix/sysv/linux/alpha/Makefile @@ -1,7 +1,3 @@ -ifeq ($(subdir),posix) -sysdep_routines += oldglob -endif - ifeq ($(subdir),stdlib) gen-as-const-headers += ucontext-offsets.sym endif diff --git a/sysdeps/unix/sysv/linux/alpha/glob.c b/sysdeps/unix/sysv/linux/alpha/glob64.c similarity index 78% rename from sysdeps/unix/sysv/linux/alpha/glob.c rename to sysdeps/unix/sysv/linux/alpha/glob64.c index 2d7d287..dd86d15 100644 --- a/sysdeps/unix/sysv/linux/alpha/glob.c +++ b/sysdeps/unix/sysv/linux/alpha/glob64.c @@ -16,36 +16,25 @@ . */ #define glob64 __no_glob64_decl -#define globfree64 __no_globfree64_decl -#include #include #include /* For Linux/Alpha we have to make the glob symbols versioned. */ #define glob(pattern, flags, errfunc, pglob) \ __new_glob (pattern, flags, errfunc, pglob) -#define globfree(pglob) \ - __new_globfree (pglob) /* We need prototypes for these new names. */ extern int __new_glob (const char *__pattern, int __flags, int (*__errfunc) (const char *, int), glob_t *__pglob); -extern void __new_globfree (glob_t *__pglob); #include #undef glob -#undef globfree #undef glob64 -#undef globfree64 versioned_symbol (libc, __new_glob, glob, GLIBC_2_1); -versioned_symbol (libc, __new_globfree, globfree, GLIBC_2_1); libc_hidden_ver (__new_glob, glob) -libc_hidden_ver (__new_globfree, globfree) weak_alias (__new_glob, glob64) -weak_alias (__new_globfree, globfree64) -libc_hidden_ver (__new_globfree, globfree64) diff --git a/sysdeps/unix/sysv/linux/alpha/globfree.c b/sysdeps/unix/sysv/linux/alpha/globfree.c new file mode 100644 index 0000000..9d159f1 --- /dev/null +++ b/sysdeps/unix/sysv/linux/alpha/globfree.c @@ -0,0 +1,36 @@ +/* Frees the dynamically allocated storage from an earlier call to glob. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#define globfree64 __no_globfree64_decl + +#include +#include + +#define globfree(pglob) __new_globfree (pglob) +extern void __new_globfree (glob_t *__pglob); + +#include + +#undef globfree +#undef globfree64 + +versioned_symbol (libc, __new_globfree, globfree, GLIBC_2_1); +libc_hidden_ver (__new_globfree, globfree) + +weak_alias (__new_globfree, globfree64) +libc_hidden_ver (__new_globfree, globfree64) diff --git a/sysdeps/unix/sysv/linux/arm/glob64.c b/sysdeps/unix/sysv/linux/arm/glob64.c deleted file mode 100644 index 82a9a29..0000000 --- a/sysdeps/unix/sysv/linux/arm/glob64.c +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/sysdeps/unix/sysv/linux/glob.c b/sysdeps/unix/sysv/linux/glob.c new file mode 100644 index 0000000..153ba8c --- /dev/null +++ b/sysdeps/unix/sysv/linux/glob.c @@ -0,0 +1,23 @@ +/* Find pathnames matching a pattern. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#ifndef __OFF_T_MATCHES_OFF64_T +# include +#endif diff --git a/sysdeps/unix/sysv/linux/glob64.c b/sysdeps/unix/sysv/linux/glob64.c new file mode 100644 index 0000000..6ff6611 --- /dev/null +++ b/sysdeps/unix/sysv/linux/glob64.c @@ -0,0 +1,55 @@ +/* Find pathnames matching a pattern. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#ifdef __OFF_T_MATCHES_OFF64_T +# define glob64 __no_glob64_decl +# include +# undef glob64 +weak_alias (glob, glob64) +#else +# include +# include +# include + +# define dirent dirent64 +# define __readdir(dirp) __readdir64 (dirp) + +# define glob_t glob64_t +# define glob(pattern, flags, errfunc, pglob) \ + __glob64 (pattern, flags, errfunc, pglob) +# define globfree(pglob) globfree64 (pglob) + +# undef stat +# define stat stat64 + +# define COMPILE_GLOB64 1 + +# include + +# include "shlib-compat.h" + +# ifdef GLOB_NO_OLD_VERSION +strong_alias (__glob64, glob64) +libc_hidden_def (glob64) +# else +versioned_symbol (libc, __glob64, glob64, GLIBC_2_2); +libc_hidden_ver (__glob64, glob64) +# endif +#endif diff --git a/sysdeps/unix/sysv/linux/globfree.c b/sysdeps/unix/sysv/linux/globfree.c new file mode 100644 index 0000000..d615510 --- /dev/null +++ b/sysdeps/unix/sysv/linux/globfree.c @@ -0,0 +1,23 @@ +/* Frees the dynamically allocated storage from an earlier call to glob. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#define globfree64 __no_globfree64_decl +#include +#undef globfree64 +weak_alias (globfree, globfree64) +libc_hidden_ver (globfree, globfree64) diff --git a/sysdeps/unix/sysv/linux/globfree64.c b/sysdeps/unix/sysv/linux/globfree64.c new file mode 100644 index 0000000..e69de29 diff --git a/sysdeps/unix/sysv/linux/i386/alphasort64.c b/sysdeps/unix/sysv/linux/i386/alphasort64.c index d5fd47a..04b29b6 100644 --- a/sysdeps/unix/sysv/linux/i386/alphasort64.c +++ b/sysdeps/unix/sysv/linux/i386/alphasort64.c @@ -30,7 +30,7 @@ versioned_symbol (libc, __alphasort64, alphasort64, GLIBC_2_2); #if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2) -#include +#include int __old_alphasort64 (const struct __old_dirent64 **a, diff --git a/sysdeps/unix/sysv/linux/i386/getdents64.c b/sysdeps/unix/sysv/linux/i386/getdents64.c index e8b257f..2010bbf 100644 --- a/sysdeps/unix/sysv/linux/i386/getdents64.c +++ b/sysdeps/unix/sysv/linux/i386/getdents64.c @@ -28,7 +28,7 @@ #if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2) -#include +#include #define __GETDENTS __old_getdents64 #define DIRENT_TYPE struct __old_dirent64 diff --git a/sysdeps/unix/sysv/linux/i386/readdir64.c b/sysdeps/unix/sysv/linux/i386/readdir64.c index de8669f..da3defd 100644 --- a/sysdeps/unix/sysv/linux/i386/readdir64.c +++ b/sysdeps/unix/sysv/linux/i386/readdir64.c @@ -31,7 +31,7 @@ versioned_symbol (libc, __readdir64, readdir64, GLIBC_2_2); #if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2) -#include +#include #define __READDIR attribute_compat_text_section __old_readdir64 #define __GETDENTS __old_getdents64 diff --git a/sysdeps/unix/sysv/linux/i386/readdir64_r.c b/sysdeps/unix/sysv/linux/i386/readdir64_r.c index 344fd53..8c0262d 100644 --- a/sysdeps/unix/sysv/linux/i386/readdir64_r.c +++ b/sysdeps/unix/sysv/linux/i386/readdir64_r.c @@ -31,7 +31,7 @@ versioned_symbol (libc, __readdir64_r, readdir64_r, GLIBC_2_2); #if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2) -#include +#include #define __READDIR_R attribute_compat_text_section __old_readdir64_r #define __GETDENTS __old_getdents64 diff --git a/sysdeps/unix/sysv/linux/i386/versionsort64.c b/sysdeps/unix/sysv/linux/i386/versionsort64.c index 3e1c6ea..87f2f95 100644 --- a/sysdeps/unix/sysv/linux/i386/versionsort64.c +++ b/sysdeps/unix/sysv/linux/i386/versionsort64.c @@ -30,7 +30,7 @@ versioned_symbol (libc, __versionsort64, versionsort64, GLIBC_2_2); #if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2) -#include +#include int __old_versionsort64 (const struct __old_dirent64 **a, diff --git a/sysdeps/unix/sysv/linux/m68k/glob64.c b/sysdeps/unix/sysv/linux/m68k/glob64.c deleted file mode 100644 index 82a9a29..0000000 --- a/sysdeps/unix/sysv/linux/m68k/glob64.c +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/glob64.c b/sysdeps/unix/sysv/linux/mips/mips64/n64/glob64.c deleted file mode 100644 index 33918ea..0000000 --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/glob64.c +++ /dev/null @@ -1 +0,0 @@ -/* glob64 is in glob.c */ diff --git a/sysdeps/unix/sysv/linux/i386/olddirent.h b/sysdeps/unix/sysv/linux/olddirent.h similarity index 100% rename from sysdeps/unix/sysv/linux/i386/olddirent.h rename to sysdeps/unix/sysv/linux/olddirent.h diff --git a/sysdeps/unix/sysv/linux/i386/glob64.c b/sysdeps/unix/sysv/linux/oldglob.c similarity index 62% rename from sysdeps/unix/sysv/linux/i386/glob64.c rename to sysdeps/unix/sysv/linux/oldglob.c index e825b7c..8b04c3c 100644 --- a/sysdeps/unix/sysv/linux/i386/glob64.c +++ b/sysdeps/unix/sysv/linux/oldglob.c @@ -1,5 +1,5 @@ -/* Two glob variants with 64-bit support, for dirent64 and __olddirent64. - Copyright (C) 1998-2017 Free Software Foundation, Inc. +/* Find pathnames matching a pattern. Compatibility version. + Copyright (C) 2017 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -16,62 +16,33 @@ License along with the GNU C Library; if not, see . */ -#include #include -#include - -#define dirent dirent64 -#define __readdir(dirp) __readdir64 (dirp) - -#define glob_t glob64_t -#define glob(pattern, flags, errfunc, pglob) \ - __glob64 (pattern, flags, errfunc, pglob) -#define globfree(pglob) globfree64 (pglob) - -#undef stat -#define stat stat64 -#undef __stat -#define __stat(file, buf) __xstat64 (_STAT_VER, file, buf) - -#define NO_GLOB_PATTERN_P 1 - -#define COMPILE_GLOB64 1 - -#include - #include "shlib-compat.h" -libc_hidden_def (globfree64) - -versioned_symbol (libc, __glob64, glob64, GLIBC_2_2); -libc_hidden_ver (__glob64, glob64) - -#if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2) +#if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2) \ + && !defined(GLOB_NO_OLD_VERSION) -#include +#include int __old_glob64 (const char *__pattern, int __flags, int (*__errfunc) (const char *, int), glob64_t *__pglob); libc_hidden_proto (__old_glob64); -#undef dirent +#define glob_t glob64_t +#define globfree(pglob) globfree64 (pglob) +#undef stat +#define stat stat64 + #define dirent __old_dirent64 -#undef GL_READDIR -# define GL_READDIR(pglob, stream) \ +#define GL_READDIR(pglob, stream) \ ((struct __old_dirent64 *) (pglob)->gl_readdir (stream)) -#undef __readdir #define __readdir(dirp) __old_readdir64 (dirp) -#undef glob #define glob(pattern, flags, errfunc, pglob) \ __old_glob64 (pattern, flags, errfunc, pglob) #define convert_dirent __old_convert_dirent -#define glob_in_dir __old_glob_in_dir -#define GLOB_ATTRIBUTE attribute_compat_text_section -#define GLOB_ONLY_P 1 - -#define GLOB_COMPAT_BUILD 1 +#define GLOB_ATTRIBUTE attribute_compat_text_section #include diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/glob64.c b/sysdeps/unix/sysv/linux/powerpc/powerpc32/glob64.c deleted file mode 100644 index 82a9a29..0000000 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/glob64.c +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/glob64.c b/sysdeps/unix/sysv/linux/s390/s390-32/glob64.c new file mode 100644 index 0000000..b00dc54 --- /dev/null +++ b/sysdeps/unix/sysv/linux/s390/s390-32/glob64.c @@ -0,0 +1,20 @@ +/* Find pathnames matching a pattern. S390-32 Linux version. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#define GLOB_NO_OLD_VERSION +#include diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/oldglob.c b/sysdeps/unix/sysv/linux/s390/s390-32/oldglob.c new file mode 100644 index 0000000..56d7d12 --- /dev/null +++ b/sysdeps/unix/sysv/linux/s390/s390-32/oldglob.c @@ -0,0 +1,2 @@ +#define GLOB_NO_OLD_VERSION +#include diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/glob64.c b/sysdeps/unix/sysv/linux/sparc/sparc32/glob64.c deleted file mode 100644 index 82a9a29..0000000 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/glob64.c +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/sysdeps/unix/sysv/linux/wordsize-64/glob64.c b/sysdeps/unix/sysv/linux/wordsize-64/glob64.c deleted file mode 100644 index eab7703..0000000 --- a/sysdeps/unix/sysv/linux/wordsize-64/glob64.c +++ /dev/null @@ -1,2 +0,0 @@ -/* This file is here so sysdeps/gnu/glob64.c doesn't take precedence. */ -#include diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/glob.c b/sysdeps/unix/sysv/linux/x86_64/x32/glob.c deleted file mode 100644 index e542747..0000000 --- a/sysdeps/unix/sysv/linux/x86_64/x32/glob.c +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/sysdeps/wordsize-64/glob.c b/sysdeps/wordsize-64/glob.c deleted file mode 100644 index 082faf1..0000000 --- a/sysdeps/wordsize-64/glob.c +++ /dev/null @@ -1,8 +0,0 @@ -#define glob64 __no_glob64_decl -#define globfree64 __no_globfree64_decl -#include -#undef glob64 -#undef globfree64 -weak_alias (glob, glob64) -weak_alias (globfree, globfree64) -libc_hidden_ver (globfree, globfree64) diff --git a/sysdeps/wordsize-64/glob64.c b/sysdeps/wordsize-64/glob64.c deleted file mode 100644 index 33918ea..0000000 --- a/sysdeps/wordsize-64/glob64.c +++ /dev/null @@ -1 +0,0 @@ -/* glob64 is in glob.c */