mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
Update.
1998-03-20 11:58 Ulrich Drepper <drepper@cygnus.com> * dirent/Makefile (routines): Add scandir64, alphasort64, and versionsort64. * dirent/alphasort64.c: New file. * dirent/scandir64.c: New file. * dirent/versionsort64.c: New file. * dirent/dirent.h: Add LFS support for scandir, alphasort, and versionsort. * sysdeps/generic/readdir64.c: Rename to __readdir64 and make old name weak alias. * sysdeps/unix/sysv/linux/readdir64.c: Likewise. * dirent/alphasort.c: Use strcoll instead of strcmp. * dirent/scandir.c: Optimize a bit. * dirent/versionsort.c: Pretty print. 1998-03-20 Ulrich Drepper <drepper@cygnus.com> * string/string.h: Add prototype for __strtok_r.
This commit is contained in:
23
ChangeLog
23
ChangeLog
@ -1,3 +1,26 @@
|
|||||||
|
1998-03-20 11:58 Ulrich Drepper <drepper@cygnus.com>
|
||||||
|
|
||||||
|
* dirent/Makefile (routines): Add scandir64, alphasort64, and
|
||||||
|
versionsort64.
|
||||||
|
* dirent/alphasort64.c: New file.
|
||||||
|
* dirent/scandir64.c: New file.
|
||||||
|
* dirent/versionsort64.c: New file.
|
||||||
|
* dirent/dirent.h: Add LFS support for scandir, alphasort, and
|
||||||
|
versionsort.
|
||||||
|
* sysdeps/generic/readdir64.c: Rename to __readdir64 and make
|
||||||
|
old name weak alias.
|
||||||
|
* sysdeps/unix/sysv/linux/readdir64.c: Likewise.
|
||||||
|
|
||||||
|
* dirent/alphasort.c: Use strcoll instead of strcmp.
|
||||||
|
|
||||||
|
* dirent/scandir.c: Optimize a bit.
|
||||||
|
|
||||||
|
* dirent/versionsort.c: Pretty print.
|
||||||
|
|
||||||
|
1998-03-20 Ulrich Drepper <drepper@cygnus.com>
|
||||||
|
|
||||||
|
* string/string.h: Add prototype for __strtok_r.
|
||||||
|
|
||||||
1998-03-20 12:14 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
|
1998-03-20 12:14 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
|
||||||
|
|
||||||
* posix/Makefile: Fix typo in last change.
|
* posix/Makefile: Fix typo in last change.
|
||||||
|
@ -24,7 +24,8 @@ subdir := dirent
|
|||||||
headers := dirent.h bits/dirent.h
|
headers := dirent.h bits/dirent.h
|
||||||
routines := opendir closedir readdir readdir_r rewinddir \
|
routines := opendir closedir readdir readdir_r rewinddir \
|
||||||
seekdir telldir scandir alphasort versionsort \
|
seekdir telldir scandir alphasort versionsort \
|
||||||
getdents dirfd readdir64 readdir64_r
|
getdents dirfd readdir64 readdir64_r scandir64 \
|
||||||
|
alphasort64 versionsort64
|
||||||
distribute := dirstream.h
|
distribute := dirstream.h
|
||||||
|
|
||||||
tests := list tst-seekdir opendir-tst1
|
tests := list tst-seekdir opendir-tst1
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 1992, 1997 Free Software Foundation, Inc.
|
/* Copyright (C) 1992, 1997, 1998 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -22,6 +22,6 @@
|
|||||||
int
|
int
|
||||||
alphasort (const void *a, const void *b)
|
alphasort (const void *a, const void *b)
|
||||||
{
|
{
|
||||||
return strcmp ((*(const struct dirent **) a)->d_name,
|
return strcoll ((*(const struct dirent **) a)->d_name,
|
||||||
(*(const struct dirent **) b)->d_name);
|
(*(const struct dirent **) b)->d_name);
|
||||||
}
|
}
|
||||||
|
27
dirent/alphasort64.c
Normal file
27
dirent/alphasort64.c
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/* Copyright (C) 1992, 1997, 1998 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 Library General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 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
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||||
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
alphasort64 (const void *a, const void *b)
|
||||||
|
{
|
||||||
|
return strcoll ((*(const struct dirent64 **) a)->d_name,
|
||||||
|
(*(const struct dirent64 **) b)->d_name);
|
||||||
|
}
|
@ -135,6 +135,7 @@ extern struct dirent *readdir __P ((DIR *__dirp)) __asm__ ("readdir64");
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __USE_LARGEFILE64
|
#ifdef __USE_LARGEFILE64
|
||||||
|
extern struct dirent64 *__readdir64 __P ((DIR *__dirp));
|
||||||
extern struct dirent64 *readdir64 __P ((DIR *__dirp));
|
extern struct dirent64 *readdir64 __P ((DIR *__dirp));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -199,18 +200,49 @@ extern int dirfd __P ((DIR *__dirp));
|
|||||||
Entries for which SELECT returns nonzero are individually malloc'd,
|
Entries for which SELECT returns nonzero are individually malloc'd,
|
||||||
sorted using qsort with CMP, and collected in a malloc'd array in
|
sorted using qsort with CMP, and collected in a malloc'd array in
|
||||||
*NAMELIST. Returns the number of entries selected, or -1 on error. */
|
*NAMELIST. Returns the number of entries selected, or -1 on error. */
|
||||||
extern int scandir __P ((__const char *__dir,
|
# ifndef __USE_FILE_OFFSET64
|
||||||
struct dirent ***__namelist,
|
extern int scandir __P ((__const char *__dir, struct dirent ***__namelist,
|
||||||
int (*__selector) __P ((__const struct dirent *)),
|
int (*__selector) (__const struct dirent *),
|
||||||
int (*__cmp) __P ((__const __ptr_t,
|
int (*__cmp) (__const __ptr_t, __const __ptr_t)));
|
||||||
__const __ptr_t))));
|
# else
|
||||||
|
extern int scandir __P ((__const char *__dir, struct dirent ***__namelist,
|
||||||
|
int (*__selector) (__const struct dirent *),
|
||||||
|
int (*__cmp) (__const __ptr_t, __const __ptr_t)))
|
||||||
|
__asm__ ("scandir64");
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# if defined __USE_GNU && defined __USE_LARGEFILE64
|
||||||
|
/* This function is like `scandir' but it uses the 64bit dirent structure.
|
||||||
|
Please note that the CMP function must now work with struct dirent64 **. */
|
||||||
|
extern int scandir64 __P ((__const char *__dir, struct dirent64 ***__namelist,
|
||||||
|
int (*__selector) (__const struct dirent64 *),
|
||||||
|
int (*__cmp) (__const __ptr_t, __const __ptr_t)));
|
||||||
|
# endif
|
||||||
|
|
||||||
/* Function to compare two `struct dirent's alphabetically. */
|
/* Function to compare two `struct dirent's alphabetically. */
|
||||||
extern int alphasort __P ((__const __ptr_t, __const __ptr_t));
|
# ifndef __USE_FILE_OFFSET64
|
||||||
|
extern int alphasort __P ((__const __ptr_t __e1, __const __ptr_t __e2));
|
||||||
|
# else
|
||||||
|
extern int alphasort __P ((__const __ptr_t __e1, __const __ptr_t __e2))
|
||||||
|
__asm__ ("alphasort64");
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# if defined __USE_GNU && defined __USE_LARGEFILE64
|
||||||
|
extern int alphasort64 __P ((__const __ptr_t __e1, __const __ptr_t __e2));
|
||||||
|
# endif
|
||||||
|
|
||||||
# ifdef __USE_GNU
|
# ifdef __USE_GNU
|
||||||
/* Function to compare two `struct dirent's by name & version. */
|
/* Function to compare two `struct dirent's by name & version. */
|
||||||
extern int versionsort __P ((__const __ptr_t, __const __ptr_t));
|
# ifndef __USE_FILE_OFFSET64
|
||||||
|
extern int versionsort __P ((__const __ptr_t __e1, __const __ptr_t __e2));
|
||||||
|
# else
|
||||||
|
extern int versionsort __P ((__const __ptr_t __e1, __const __ptr_t __e2))
|
||||||
|
__asm__ ("versionsort64");
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# ifdef __USE_LARGEFILE64
|
||||||
|
extern int versionsort64 __P ((__const __ptr_t __e1, __const __ptr_t __e2));
|
||||||
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
/* Read directory entries from FD into BUF, reading at most NBYTES.
|
/* Read directory entries from FD into BUF, reading at most NBYTES.
|
||||||
|
@ -44,6 +44,7 @@ scandir (dir, namelist, select, cmp)
|
|||||||
while ((d = __readdir (dp)) != NULL)
|
while ((d = __readdir (dp)) != NULL)
|
||||||
if (select == NULL || (*select) (d))
|
if (select == NULL || (*select) (d))
|
||||||
{
|
{
|
||||||
|
struct dirent *vnew;
|
||||||
size_t dsize;
|
size_t dsize;
|
||||||
|
|
||||||
/* Ignore errors from select or readdir */
|
/* Ignore errors from select or readdir */
|
||||||
@ -58,20 +59,16 @@ scandir (dir, namelist, select, cmp)
|
|||||||
vsize *= 2;
|
vsize *= 2;
|
||||||
new = (struct dirent **) realloc (v, vsize * sizeof (*v));
|
new = (struct dirent **) realloc (v, vsize * sizeof (*v));
|
||||||
if (new == NULL)
|
if (new == NULL)
|
||||||
{
|
|
||||||
lose:
|
|
||||||
__set_errno (ENOMEM);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
v = new;
|
v = new;
|
||||||
}
|
}
|
||||||
|
|
||||||
dsize = &d->d_name[_D_ALLOC_NAMLEN (d)] - (char *) d;
|
dsize = &d->d_name[_D_ALLOC_NAMLEN (d)] - (char *) d;
|
||||||
v[i] = (struct dirent *) malloc (dsize);
|
vnew = (struct dirent *) malloc (dsize);
|
||||||
if (v[i] == NULL)
|
if (vnew == NULL)
|
||||||
goto lose;
|
break;
|
||||||
|
|
||||||
memcpy (v[i++], d, dsize);
|
v[i++] = (struct dirent *) memcpy (vnew, d, dsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (errno != 0)
|
if (errno != 0)
|
||||||
|
93
dirent/scandir64.c
Normal file
93
dirent/scandir64.c
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
/* Copyright (C) 1992, 93, 94, 95, 96, 97, 98 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 Library General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 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
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||||
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
scandir64 (dir, namelist, select, cmp)
|
||||||
|
const char *dir;
|
||||||
|
struct dirent64 ***namelist;
|
||||||
|
int (*select) __P ((const struct dirent64 *));
|
||||||
|
int (*cmp) __P ((const void *, const void *));
|
||||||
|
{
|
||||||
|
DIR *dp = opendir (dir);
|
||||||
|
struct dirent64 **v = NULL;
|
||||||
|
size_t vsize = 0, i;
|
||||||
|
struct dirent64 *d;
|
||||||
|
int save;
|
||||||
|
|
||||||
|
if (dp == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
save = errno;
|
||||||
|
__set_errno (0);
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while ((d = __readdir64 (dp)) != NULL)
|
||||||
|
if (select == NULL || (*select) (d))
|
||||||
|
{
|
||||||
|
struct dirent64 *vnew;
|
||||||
|
size_t dsize;
|
||||||
|
|
||||||
|
/* Ignore errors from select or readdir */
|
||||||
|
__set_errno (0);
|
||||||
|
|
||||||
|
if (i == vsize)
|
||||||
|
{
|
||||||
|
struct dirent64 **new;
|
||||||
|
if (vsize == 0)
|
||||||
|
vsize = 10;
|
||||||
|
else
|
||||||
|
vsize *= 2;
|
||||||
|
new = (struct dirent64 **) realloc (v, vsize * sizeof (*v));
|
||||||
|
if (new == NULL)
|
||||||
|
break;
|
||||||
|
v = new;
|
||||||
|
}
|
||||||
|
|
||||||
|
dsize = &d->d_name[_D_ALLOC_NAMLEN (d)] - (char *) d;
|
||||||
|
vnew = (struct dirent64 *) malloc (dsize);
|
||||||
|
if (vnew == NULL)
|
||||||
|
break;
|
||||||
|
|
||||||
|
v[i++] = (struct dirent64 *) memcpy (vnew, d, dsize);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errno != 0)
|
||||||
|
{
|
||||||
|
save = errno;
|
||||||
|
(void) closedir (dp);
|
||||||
|
while (i > 0)
|
||||||
|
free (v[--i]);
|
||||||
|
free (v);
|
||||||
|
__set_errno (save);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
(void) closedir (dp);
|
||||||
|
__set_errno (save);
|
||||||
|
|
||||||
|
/* Sort the list if we have a comparison function to sort with. */
|
||||||
|
if (cmp != NULL)
|
||||||
|
qsort (v, i, sizeof (*v), cmp);
|
||||||
|
*namelist = v;
|
||||||
|
return i;
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 1992, 1997 Free Software Foundation, Inc.
|
/* Copyright (C) 1992, 1997, 1998 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
27
dirent/versionsort64.c
Normal file
27
dirent/versionsort64.c
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/* Copyright (C) 1992, 1997, 1998 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 Library General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 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
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
||||||
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
versionsort64 (const void *a, const void *b)
|
||||||
|
{
|
||||||
|
return strverscmp ((*(const struct dirent64 **) a)->d_name,
|
||||||
|
(*(const struct dirent64 **) b)->d_name);
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 1991, 92, 93, 95, 96, 97 Free Software Foundation, Inc.
|
/* Copyright (C) 1991, 92, 93, 95, 96, 97, 98 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -167,9 +167,11 @@ extern char *strcasestr __P ((__const char *__haystack,
|
|||||||
extern char *strtok __P ((char *__restrict __s,
|
extern char *strtok __P ((char *__restrict __s,
|
||||||
__const char *__restrict __delim));
|
__const char *__restrict __delim));
|
||||||
|
|
||||||
#if defined __USE_POSIX || defined __USE_MISC
|
|
||||||
/* Divide S into tokens separated by characters in DELIM. Information
|
/* Divide S into tokens separated by characters in DELIM. Information
|
||||||
passed between calls are stored in SAVE_PTR. */
|
passed between calls are stored in SAVE_PTR. */
|
||||||
|
extern char *__strtok_r __P ((char *__s, __const char *__delim,
|
||||||
|
char **__save_ptr));
|
||||||
|
#if defined __USE_POSIX || defined __USE_MISC
|
||||||
extern char *strtok_r __P ((char *__s, __const char *__delim,
|
extern char *strtok_r __P ((char *__s, __const char *__delim,
|
||||||
char **__save_ptr));
|
char **__save_ptr));
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 1991, 1995, 1996, 1997 Free Software Foundation, Inc.
|
/* Copyright (C) 1991, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -22,10 +22,11 @@
|
|||||||
|
|
||||||
/* Read a directory entry from DIRP. */
|
/* Read a directory entry from DIRP. */
|
||||||
struct dirent64 *
|
struct dirent64 *
|
||||||
readdir64 (DIR *dirp)
|
__readdir64 (DIR *dirp)
|
||||||
{
|
{
|
||||||
__set_errno (ENOSYS);
|
__set_errno (ENOSYS);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
weak_alias (__readdir64, readdir64)
|
||||||
stub_warning (readdir64)
|
stub_warning (readdir64)
|
||||||
#include <stub-tag.h>
|
#include <stub-tag.h>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 1997 Free Software Foundation, Inc.
|
/* Copyright (C) 1997, 1998 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -32,7 +32,7 @@ extern ssize_t __getdirentries64 (int, char *, size_t, off_t *);
|
|||||||
|
|
||||||
/* Read a directory entry from DIRP. */
|
/* Read a directory entry from DIRP. */
|
||||||
struct dirent64 *
|
struct dirent64 *
|
||||||
readdir64 (DIR *dirp)
|
__readdir64 (DIR *dirp)
|
||||||
{
|
{
|
||||||
struct dirent64 *dp;
|
struct dirent64 *dp;
|
||||||
|
|
||||||
@ -101,3 +101,4 @@ readdir64 (DIR *dirp)
|
|||||||
|
|
||||||
return dp;
|
return dp;
|
||||||
}
|
}
|
||||||
|
weak_alias (__readdir64, readdir64)
|
||||||
|
Reference in New Issue
Block a user