From cb6a88484ce0b5ffba2fe98a40e2d51f4af92eb8 Mon Sep 17 00:00:00 2001 From: "\"Steven J. Hill\"" Date: Sat, 25 Feb 2006 04:03:33 +0000 Subject: Merge from trunk. Going pretty good so far. Kind of. Okay, not really. --- libc/stdlib/realpath.c | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) (limited to 'libc/stdlib/realpath.c') 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 + * Copyright (C) 2000-2006 Erik Andersen * - * 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 #endif @@ -28,9 +18,16 @@ #include /* for PATH_MAX */ #include /* for MAXPATHLEN */ #include +#include #include /* 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; } -- cgit v1.2.3