#include <stddef.h>
#include <stdlib.h>
#include <string.h>
-
-#if HAVE_UNISTD_H || defined _LIBC
-# include <unistd.h>
-#endif
+#include <unistd.h>
#include <limits.h>
# include <sys/param.h>
#endif
#ifndef MAXSYMLINKS
-# define MAXSYMLINKS 20
+# ifdef SYMLOOP_MAX
+# define MAXSYMLINKS SYMLOOP_MAX
+# else
+# define MAXSYMLINKS 20
+# endif
#endif
#include <sys/stat.h>
# define __getcwd(buf, max) getwd (buf)
# endif
# define __readlink readlink
- /* On systems without symbolic links, call stat() instead of lstat(). */
-# if !defined S_ISLNK && !HAVE_READLINK
-# define lstat stat
-# endif
#endif
/* Return the canonical absolute name of file NAME. A canonical name
char *rpath, *dest, *extra_buf = NULL;
const char *start, *end, *rpath_limit;
long int path_max;
-#if HAVE_READLINK
int num_links = 0;
-#endif
if (name == NULL)
{
#endif
goto error;
-#if HAVE_READLINK
if (S_ISLNK (st.st_mode))
{
char *buf;
if (dest > rpath + 1)
while ((--dest)[-1] != '/');
}
-#endif
}
}
if (dest > rpath + 1 && dest[-1] == '/')