mirror of
https://git.savannah.gnu.org/git/make.git
synced 2024-12-27 06:27:51 +00:00
Updated from libc
This commit is contained in:
parent
11af972f87
commit
675981bc4f
2 changed files with 34 additions and 6 deletions
|
@ -1,3 +1,11 @@
|
|||
Tue Apr 25 17:17:19 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
|
||||
|
||||
* posix/glob.c (glob): If GLOB_MARK set, stat names to find
|
||||
directories and append slashes to them in final pass before
|
||||
sorting.
|
||||
(glob_in_dir): If GLOB_MARK set, just allocate the extra char for the
|
||||
slash; never append it here.
|
||||
|
||||
Wed Mar 8 13:38:13 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
|
||||
|
||||
* posix/glob/configure.bat: Fixes from DJ.
|
||||
|
|
32
glob/glob.c
32
glob/glob.c
|
@ -26,6 +26,7 @@ Cambridge, MA 02139, USA. */
|
|||
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
|
||||
/* Comment out all this code if we are using the GNU C Library, and are not
|
||||
|
@ -173,6 +174,17 @@ extern char *alloca ();
|
|||
|
||||
#endif
|
||||
|
||||
#ifndef __GNU_LIBRARY__
|
||||
#define __lstat lstat
|
||||
#ifndef HAVE_LSTAT
|
||||
#define lstat stat
|
||||
#endif
|
||||
#ifdef STAT_MACROS_BROKEN
|
||||
#undef S_ISDIR
|
||||
#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef STDC_HEADERS
|
||||
#undef size_t
|
||||
#define size_t unsigned int
|
||||
|
@ -394,9 +406,21 @@ glob (pattern, flags, errfunc, pglob)
|
|||
}
|
||||
}
|
||||
|
||||
if (flags & GLOB_MARK)
|
||||
{
|
||||
/* Append slashes to directory names. glob_in_dir has already
|
||||
allocated the extra character for us. */
|
||||
int i;
|
||||
struct stat st;
|
||||
for (i = oldcount; i < pglob->gl_pathc; ++i)
|
||||
if (__lstat (pglob->gl_pathv[i], &st) == 0 &&
|
||||
S_ISDIR (st.st_mode))
|
||||
strcat (pglob->gl_pathv[i], "/");
|
||||
}
|
||||
|
||||
if (!(flags & GLOB_NOSORT))
|
||||
/* Sort the vector. */
|
||||
qsort ((__ptr_t) & pglob->gl_pathv[oldcount],
|
||||
qsort ((__ptr_t) &pglob->gl_pathv[oldcount],
|
||||
pglob->gl_pathc - oldcount,
|
||||
sizeof (char *), collated_compare);
|
||||
|
||||
|
@ -595,8 +619,6 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
|
|||
if (new->name == NULL)
|
||||
goto memory_error;
|
||||
memcpy ((__ptr_t) new->name, name, len);
|
||||
if (flags & GLOB_MARK)
|
||||
new->name[len++] = '/';
|
||||
new->name[len] = '\0';
|
||||
new->next = names;
|
||||
names = new;
|
||||
|
@ -611,12 +633,10 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
|
|||
nfound = 1;
|
||||
names = (struct globlink *) __alloca (sizeof (struct globlink));
|
||||
names->next = NULL;
|
||||
names->name = (char *) malloc (len + ((flags & GLOB_MARK) ? 1 : 0) + 1);
|
||||
names->name = (char *) malloc (len + 1);
|
||||
if (names->name == NULL)
|
||||
goto memory_error;
|
||||
memcpy (names->name, pattern, len);
|
||||
if (flags & GLOB_MARK)
|
||||
names->name[len++] = '/';
|
||||
names->name[len] = '\0';
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue