diff options
author | Jim Meyering <jim@meyering.net> | 2001-08-12 20:11:39 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2001-08-12 20:11:39 +0000 |
commit | 79dbd85e74360835c284b3c064ba5b356dbf3a28 (patch) | |
tree | b1a0acfc8d2057704d6e693dded4f003bcc3674f /lib | |
parent | 8982646a6389eed994f20e502db2d98c1c9c985c (diff) | |
download | coreutils-79dbd85e74360835c284b3c064ba5b356dbf3a28.tar.xz |
(xgetcwd) [defined __GLIBC__ && __GLIBC__ >= 2]:
Simply `return getcwd (NULL, 0);'.
[! (defined __GLIBC__ && __GLIBC__ >= 2)]:
Use 1300 as initial value for length, not PATH_MAX.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/xgetcwd.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/xgetcwd.c b/lib/xgetcwd.c index 896be5d6a..95d0ab96c 100644 --- a/lib/xgetcwd.c +++ b/lib/xgetcwd.c @@ -1,5 +1,5 @@ /* xgetcwd.c -- return current directory with unlimited length - Copyright (C) 1992, 1996, 2000 Free Software Foundation, Inc. + Copyright (C) 1992, 1996, 2000, 2001 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -47,6 +47,9 @@ extern void free (); char * xgetcwd () { +#if defined __GLIBC__ && __GLIBC__ >= 2 + return getcwd (NULL, 0); +#else char *ret; unsigned path_max; char buf[1024]; @@ -58,7 +61,7 @@ xgetcwd () if (errno != ERANGE) return NULL; - path_max = (unsigned) PATH_MAX; + path_max = 1300; path_max += 2; /* The getcwd docs say to do this. */ for (;;) @@ -82,4 +85,5 @@ xgetcwd () path_max += path_max / 16; path_max += 32; } +#endif } |