mirror of
git://git.sv.gnu.org/coreutils.git
synced 2026-04-18 17:56:54 +02:00
Merge inconsequential changes from libc.
Include limits.h earlier. Move PATH_MAX definition `down' a little; add comment. Rename local, saved_errno to save_err.
This commit is contained in:
19
lib/ftw.c
19
lib/ftw.c
@@ -60,6 +60,7 @@ char *alloca ();
|
||||
|
||||
#include <errno.h>
|
||||
#include <ftw.h>
|
||||
#include <limits.h>
|
||||
#include <search.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -73,11 +74,6 @@ char *alloca ();
|
||||
# include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
#ifndef PATH_MAX
|
||||
# define PATH_MAX 1024
|
||||
#endif
|
||||
|
||||
#if ! _LIBC && !HAVE_DECL_STPCPY && !defined stpcpy
|
||||
char *stpcpy ();
|
||||
#endif
|
||||
@@ -155,6 +151,14 @@ int rpl_lstat (const char *, struct stat *);
|
||||
# define NFTW_FUNC_T __nftw_func_t
|
||||
#endif
|
||||
|
||||
/* We define PATH_MAX if the system does not provide a definition.
|
||||
This does not artificially limit any operation. PATH_MAX is simply
|
||||
used as a guesstimate for the expected maximal path length.
|
||||
Buffers will be enlarged if necessary. */
|
||||
#ifndef PATH_MAX
|
||||
# define PATH_MAX 1024
|
||||
#endif
|
||||
|
||||
struct dir_data
|
||||
{
|
||||
DIR *stream;
|
||||
@@ -656,6 +660,7 @@ ftw_startup (const char *dir, int is_nftw, void *func, int descriptors,
|
||||
* sizeof (struct dir_data *));
|
||||
memset (data.dirstreams, '\0', data.maxdir * sizeof (struct dir_data *));
|
||||
|
||||
/* PATH_MAX is always defined when we get here. */
|
||||
dir_len = strlen (dir);
|
||||
data.dirbufsize = MAX (2 * dir_len, PATH_MAX);
|
||||
data.dirbuf = (char *) malloc (data.dirbufsize);
|
||||
@@ -768,10 +773,10 @@ ftw_startup (const char *dir, int is_nftw, void *func, int descriptors,
|
||||
/* Return to the start directory (if necessary). */
|
||||
if (cwd != NULL)
|
||||
{
|
||||
int saved_errno = errno;
|
||||
int save_err = errno;
|
||||
__chdir (cwd);
|
||||
free (cwd);
|
||||
__set_errno (saved_errno);
|
||||
__set_errno (save_err);
|
||||
}
|
||||
|
||||
/* Free all memory. */
|
||||
|
||||
Reference in New Issue
Block a user