summaryrefslogtreecommitdiffstats
path: root/libc/stdlib/realpath.c
diff options
context:
space:
mode:
author"Steven J. Hill" <sjhill@realitydiluted.com>2006-02-25 04:03:33 +0000
committer"Steven J. Hill" <sjhill@realitydiluted.com>2006-02-25 04:03:33 +0000
commitcb6a88484ce0b5ffba2fe98a40e2d51f4af92eb8 (patch)
tree520f8e8d113184cfa7954ebd274564b8c255fa9a /libc/stdlib/realpath.c
parente4461be66e2655058aef358b00050bc70ac72861 (diff)
downloaduClibc-alpine-cb6a88484ce0b5ffba2fe98a40e2d51f4af92eb8.tar.bz2
uClibc-alpine-cb6a88484ce0b5ffba2fe98a40e2d51f4af92eb8.tar.xz
Merge from trunk. Going pretty good so far. Kind of. Okay, not really.
Diffstat (limited to 'libc/stdlib/realpath.c')
-rw-r--r--libc/stdlib/realpath.c37
1 files changed, 17 insertions, 20 deletions
diff --git a/libc/stdlib/realpath.c b/libc/stdlib/realpath.c
index 88677f7a7..c3cc517de 100644
--- a/libc/stdlib/realpath.c
+++ b/libc/stdlib/realpath.c
@@ -1,21 +1,11 @@
/*
* realpath.c -- canonicalize pathname by removing symlinks
* Copyright (C) 1993 Rick Sladkey <jrs@world.std.com>
+ * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Library Public License for more details.
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#define readlink __readlink
-#define getcwd __getcwd
-
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -28,9 +18,16 @@
#include <limits.h> /* for PATH_MAX */
#include <sys/param.h> /* for MAXPATHLEN */
#include <errno.h>
+#include <stdlib.h>
#include <sys/stat.h> /* for S_IFLNK */
+libc_hidden_proto(strcat)
+libc_hidden_proto(strcpy)
+libc_hidden_proto(strlen)
+libc_hidden_proto(readlink)
+libc_hidden_proto(getcwd)
+
#ifndef PATH_MAX
#ifdef _POSIX_VERSION
#define PATH_MAX _POSIX_PATH_MAX
@@ -62,11 +59,11 @@ char resolved_path[];
int n;
/* Make a copy of the source path since we may need to modify it. */
- if (__strlen(path) >= PATH_MAX - 2) {
+ if (strlen(path) >= PATH_MAX - 2) {
__set_errno(ENAMETOOLONG);
return NULL;
}
- __strcpy(copy_path, path);
+ strcpy(copy_path, path);
path = copy_path;
max_path = copy_path + PATH_MAX - 2;
/* If it's a relative pathname use getwd for starters. */
@@ -78,7 +75,7 @@ char resolved_path[];
#else
getwd(new_path);
#endif
- new_path += __strlen(new_path);
+ new_path += strlen(new_path);
if (new_path[-1] != '/')
*new_path++ = '/';
} else {
@@ -132,7 +129,7 @@ char resolved_path[];
if (errno != EINVAL) {
/* Make sure it's null terminated. */
*new_path = '\0';
- __strcpy(resolved_path, got_path);
+ strcpy(resolved_path, got_path);
return NULL;
}
} else {
@@ -145,13 +142,13 @@ char resolved_path[];
/* Otherwise back up over this component. */
while (*(--new_path) != '/');
/* Safe sex check. */
- if (__strlen(path) + n >= PATH_MAX - 2) {
+ if (strlen(path) + n >= PATH_MAX - 2) {
__set_errno(ENAMETOOLONG);
return NULL;
}
/* Insert symlink contents into path. */
- __strcat(link_path, path);
- __strcpy(copy_path, link_path);
+ strcat(link_path, path);
+ strcpy(copy_path, link_path);
path = copy_path;
}
#endif /* S_IFLNK */
@@ -162,6 +159,6 @@ char resolved_path[];
new_path--;
/* Make sure it's null terminated. */
*new_path = '\0';
- __strcpy(resolved_path, got_path);
+ strcpy(resolved_path, got_path);
return resolved_path;
}