From 0876c5bbd326ead4b8918066c4cd26d176b8e3f2 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 7 Feb 2003 09:28:50 +0000 Subject: 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. --- lib/ftw.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/ftw.c b/lib/ftw.c index fc1c5109c..982b047c3 100644 --- a/lib/ftw.c +++ b/lib/ftw.c @@ -60,6 +60,7 @@ char *alloca (); #include #include +#include #include #include #include @@ -73,11 +74,6 @@ char *alloca (); # include #endif -#include -#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. */ -- cgit v1.2.3-70-g09d2