X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fcanonicalize-lgpl.c;h=e8d2b65ebc82b2a1f8aa9eac982a901822985c6b;hb=4565266f776db0d78b2c207a5fe79f929f9806ca;hp=7da120680d581534d89300862c74ea368c81b512;hpb=d5f7e64df8267621f5e17b2def101343f767b86e;p=gnulib.git
diff --git a/lib/canonicalize-lgpl.c b/lib/canonicalize-lgpl.c
index 7da120680..e8d2b65eb 100644
--- a/lib/canonicalize-lgpl.c
+++ b/lib/canonicalize-lgpl.c
@@ -1,11 +1,11 @@
/* Return the canonical absolute name of a given file.
- Copyright (C) 1996-2003, 2005-2006 Free Software Foundation, Inc.
+ Copyright (C) 1996-2003, 2005-2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
- This program is free software; you can redistribute it and/or modify
+ 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
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
+ the Free Software Foundation; either version 3 of the License, 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
@@ -13,8 +13,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+ along with this program. If not, see . */
#include
@@ -66,7 +65,7 @@
# define __canonicalize_file_name canonicalize_file_name
# define __realpath rpl_realpath
# include "pathmax.h"
-# include "allocsa.h"
+# include "malloca.h"
# if HAVE_GETCWD
# ifdef VMS
/* We want the directory in Unix syntax, not in VMS syntax. */
@@ -101,7 +100,7 @@ __realpath (const char *name, char *resolved)
char *rpath, *dest, *extra_buf = NULL;
const char *start, *end, *rpath_limit;
long int path_max;
-#ifdef S_ISLNK
+#if HAVE_READLINK
int num_links = 0;
#endif
@@ -135,7 +134,12 @@ __realpath (const char *name, char *resolved)
{
rpath = malloc (path_max);
if (rpath == NULL)
- return NULL;
+ {
+ /* It's easier to set errno to ENOMEM than to rely on the
+ 'malloc-posix' gnulib module. */
+ errno = ENOMEM;
+ return NULL;
+ }
}
else
rpath = resolved;
@@ -209,7 +213,12 @@ __realpath (const char *name, char *resolved)
new_size += path_max;
new_rpath = (char *) realloc (rpath, new_size);
if (new_rpath == NULL)
- goto error;
+ {
+ /* It's easier to set errno to ENOMEM than to rely on the
+ 'realloc-posix' gnulib module. */
+ errno = ENOMEM;
+ goto error;
+ }
rpath = new_rpath;
rpath_limit = rpath + new_size;
@@ -231,7 +240,7 @@ __realpath (const char *name, char *resolved)
#endif
goto error;
-#ifdef S_ISLNK
+#if HAVE_READLINK
if (S_ISLNK (st.st_mode))
{
char *buf;
@@ -244,7 +253,7 @@ __realpath (const char *name, char *resolved)
goto error;
}
- buf = allocsa (path_max);
+ buf = malloca (path_max);
if (!buf)
{
errno = ENOMEM;
@@ -255,7 +264,7 @@ __realpath (const char *name, char *resolved)
if (n < 0)
{
int saved_errno = errno;
- freesa (buf);
+ freea (buf);
errno = saved_errno;
goto error;
}
@@ -263,10 +272,10 @@ __realpath (const char *name, char *resolved)
if (!extra_buf)
{
- extra_buf = allocsa (path_max);
+ extra_buf = malloca (path_max);
if (!extra_buf)
{
- freesa (buf);
+ freea (buf);
errno = ENOMEM;
goto error;
}
@@ -275,7 +284,7 @@ __realpath (const char *name, char *resolved)
len = strlen (end);
if ((long int) (n + len) >= path_max)
{
- freesa (buf);
+ freea (buf);
__set_errno (ENAMETOOLONG);
goto error;
}
@@ -299,7 +308,7 @@ __realpath (const char *name, char *resolved)
*dest = '\0';
if (extra_buf)
- freesa (extra_buf);
+ freea (extra_buf);
return resolved ? memcpy (resolved, rpath, dest - rpath + 1) : rpath;
@@ -307,7 +316,7 @@ error:
{
int saved_errno = errno;
if (extra_buf)
- freesa (extra_buf);
+ freea (extra_buf);
if (resolved)
strcpy (resolved, rpath);
else