summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2003-02-07 09:28:50 +0000
committerJim Meyering <jim@meyering.net>2003-02-07 09:28:50 +0000
commit0876c5bbd326ead4b8918066c4cd26d176b8e3f2 (patch)
tree38d05b67295cc2437cd90266fec76e07042e366e
parent4f1c8d7e88cdb5d17394d43d883a9946804ba752 (diff)
downloadcoreutils-0876c5bbd326ead4b8918066c4cd26d176b8e3f2.tar.xz
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.
-rw-r--r--lib/ftw.c19
1 files 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 <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. */