mirror of
https://salsa.debian.org/srivasta/make-dfsg.git
synced 2025-01-30 16:41:44 +00:00
Updated from libc
This commit is contained in:
parent
4314e2f987
commit
6e19c6febb
1 changed files with 14 additions and 5 deletions
19
glob/glob.c
19
glob/glob.c
|
@ -410,14 +410,23 @@ 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. */
|
||||
/* Append slashes to directory names. */
|
||||
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], "/");
|
||||
{
|
||||
size_t len = strlen (pglob->gl_pathv[i]) + 2;
|
||||
char *new = realloc (pglob->gl_pathv[i], len);
|
||||
if (new == NULL)
|
||||
{
|
||||
globfree (pglob);
|
||||
return GLOB_NOSPACE;
|
||||
}
|
||||
strcpy (&new[len - 2], "/");
|
||||
pglob->gl_pathv[i] = new;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(flags & GLOB_NOSORT))
|
||||
|
@ -617,7 +626,7 @@ glob_in_dir (pattern, directory, flags, errfunc, pglob)
|
|||
if (len == 0)
|
||||
len = strlen (name);
|
||||
new->name
|
||||
= (char *) malloc (len + ((flags & GLOB_MARK) ? 1 : 0) + 1);
|
||||
= (char *) malloc (len + 1);
|
||||
if (new->name == NULL)
|
||||
goto memory_error;
|
||||
memcpy ((__ptr_t) new->name, name, len);
|
||||
|
@ -635,7 +644,7 @@ 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);
|
||||
|
|
Loading…
Reference in a new issue