From: Derek R. Price Date: Fri, 24 Jun 2005 14:53:03 +0000 (+0000) Subject: Remove stat module & update lstat. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0d1d61835135da48448b5f09ada9f67c35ca4b97;p=pspp Remove stat module & update lstat. * MODULES.html.sh (stat): Remove. * MODULES.html: Regenerated. * config/srclist.txt (GLIBC sources): Remove stat. * lib/stat.c: Remove this file... (slash_aware_lstat): ...moving this content and its support... * lib/lstat.c (rpl_lstat): ...into here. * lib/lstat.h: New file. * m4/lstat.m4 (gl_FUNC_LSTAT): Drop AC_FUNC_LSTAT in favor of AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK. * m4/stat.m4: Remove this file. * modules/lstat (Description): Correct function name. (Files): Add "lstat.h". (Depends-on): Remove stat, add xalloc, stat-macros. * modules/stat: Remove this file. (Include): Add "lstat.h", remove . --- diff --git a/ChangeLog b/ChangeLog index 2abdac1cb1..7485517d3f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2005-06-24 Derek Price + and Bruno Haible + + Remove stat module & update lstat. + * MODULES.html.sh (stat): Remove. + * MODULES.html: Regenerated. + * modules/lstat (Description): Correct function name. + (Files): Add "lstat.h". + (Depends-on): Remove stat, add xalloc, stat-macros. + * modules/stat: Remove this file. + (Include): Add "lstat.h", remove . + 2005-06-08 Bruno Haible * modules/csharpcomp: New file. diff --git a/MODULES.html b/MODULES.html index e974afe3d2..ac141ab34d 100644 --- a/MODULES.html +++ b/MODULES.html @@ -2,7 +2,7 @@ Gnulib Module List - +

Gnulib Module List

@@ -550,13 +550,9 @@ to a fixed length string readlink readlink() function: read the value of a symbolic link. - - stat - stat() function: return information about a file, following symbolic links. - lstat - stat() function: return information about a file or symbolic link. + lstat() function: return information about a file or symbolic link. time_r @@ -2302,19 +2298,12 @@ variables. readlink.m4
gl_FUNC_READLINK --- - - stat - #include <sys/stat.h> - stat.c - stat.m4
gl_FUNC_STAT - xalloc
stat-macros - lstat - #include <sys/stat.h> + #include "lstat.h" lstat.c lstat.m4
gl_FUNC_LSTAT - stat + xalloc
stat-macros time_r @@ -3411,6 +3400,6 @@ variables.
  • A testsuite
    - Generated from MODULES.html.sh on 9 June 2005. + Generated from MODULES.html.sh on 24 June 2005. diff --git a/MODULES.html.sh b/MODULES.html.sh index 7de240d001..96370c4aed 100755 --- a/MODULES.html.sh +++ b/MODULES.html.sh @@ -1063,7 +1063,6 @@ srand srand48 srandom sscanf -stat statvfs stdin strcasecmp @@ -1756,7 +1755,6 @@ func_all_modules () func_module mkdtemp func_module poll func_module readlink - func_module stat func_module lstat func_module time_r func_module timespec diff --git a/config/ChangeLog b/config/ChangeLog index ebcc25c2e7..65fe7280e7 100644 --- a/config/ChangeLog +++ b/config/ChangeLog @@ -1,3 +1,9 @@ +2005-06-24 Derek Price + and Bruno Haible + + Remove stat module & update lstat. + * srclist.txt (libc sources): Remove stat. + 2005-05-29 Derek Price * srclist.txt (glob_.h, glob.c): Add these files. diff --git a/config/srclist.txt b/config/srclist.txt index d2b3a03fec..531acb0c81 100644 --- a/config/srclist.txt +++ b/config/srclist.txt @@ -1,4 +1,4 @@ -# $Id: srclist.txt,v 1.63 2005-05-29 16:56:02 dprice Exp $ +# $Id: srclist.txt,v 1.64 2005-06-24 14:53:03 dprice Exp $ # Files for which we are not the source. See ./srclistvars.sh for the # variable definitions. @@ -143,7 +143,6 @@ $LIBCSRC/sysdeps/generic/memmem.c lib gpl # # These implementations are quite different. #$LIBCSRC/io/lstat.c lib gpl -#$LIBCSRC/io/stat.c lib gpl #$LIBCSRC/libio/__fpending.c lib gpl #$LIBCSRC/malloc/malloc.c lib gpl #$LIBCSRC/misc/dirname.c lib gpl diff --git a/lib/ChangeLog b/lib/ChangeLog index 32c5859388..3e684232f1 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,12 @@ +2005-06-24 Derek Price + and Bruno Haible + + Remove stat module & update lstat. + * stat.c: Remove this file... + (slash_aware_lstat): ...moving this content and its support... + * lstat.c (rpl_lstat): ...into here. + * lstat.h: New file. + 2005-06-23 Paul Eggert * mktime.c: Include even if !DEBUG. (From glibc.) diff --git a/lib/lstat.c b/lib/lstat.c index ef274b09e5..0d539fe4a6 100644 --- a/lib/lstat.c +++ b/lib/lstat.c @@ -1,8 +1,6 @@ -/* Work around the bug in some systems whereby lstat succeeds when - given the zero-length file name argument. The lstat from SunOS 4.1.4 - has this bug. +/* Work around a bug of lstat on some systems - Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -19,5 +17,59 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#define LSTAT -#include "stat.c" +/* written by Jim Meyering */ + +#include + +/* The specification of these functions is in sys_stat.h. But we cannot + include this include file here, because on some systems, a + "#define lstat lstat64" is being used, and sys_stat.h deletes this + definition. */ + +#include +#include +#include +#include + +#include "stat-macros.h" +#include "xalloc.h" + +/* lstat works differently on Linux and Solaris systems. POSIX (see + `pathname resolution' in the glossary) requires that programs like `ls' + take into consideration the fact that FILE has a trailing slash when + FILE is a symbolic link. On Linux systems, the lstat function already + has the desired semantics (in treating `lstat("symlink/",sbuf)' just like + `lstat("symlink/.",sbuf)', but on Solaris it does not. + + If FILE has a trailing slash and specifies a symbolic link, + then append a `.' to FILE and call lstat a second time. */ + +int +rpl_lstat (const char *file, struct stat *sbuf) +{ + size_t len; + char *new_file; + + int lstat_result = lstat (file, sbuf); + + if (lstat_result != 0 || !S_ISLNK (sbuf->st_mode)) + return lstat_result; + + len = strlen (file); + if (len == 0 || file[len - 1] != '/') + return lstat_result; + + /* FILE refers to a symbolic link and the name ends with a slash. + Append a `.' to FILE and repeat the lstat call. */ + + /* Add one for the `.' we'll append, and one more for the trailing NUL. */ + new_file = xmalloc (len + 1 + 1); + memcpy (new_file, file, len); + new_file[len] = '.'; + new_file[len + 1] = 0; + + lstat_result = lstat (new_file, sbuf); + free (new_file); + + return lstat_result; +} diff --git a/lib/lstat.h b/lib/lstat.h new file mode 100644 index 0000000000..6a83fbf8fe --- /dev/null +++ b/lib/lstat.h @@ -0,0 +1,24 @@ +/* Retrieving information about files. + Copyright (C) 2005 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 + 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 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. */ + +#include + +#if !LSTAT_FOLLOWS_SLASHED_SYMLINK +extern int rpl_lstat (const char *name, struct stat *buf); +# undef lstat +# define lstat rpl_lstat +#endif diff --git a/lib/stat.c b/lib/stat.c deleted file mode 100644 index b06926ff05..0000000000 --- a/lib/stat.c +++ /dev/null @@ -1,111 +0,0 @@ -/* Work around the bug in some systems whereby stat/lstat succeeds when - given the zero-length file name argument. The stat/lstat from SunOS 4.1.4 - has this bug. Also work around a deficiency in Solaris systems (up to at - least Solaris 9) regarding the semantics of `lstat ("symlink/", sbuf).' - - Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 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 - 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 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. */ - -/* written by Jim Meyering */ - -#include - -#include -#include -#include -#if defined LSTAT && ! LSTAT_FOLLOWS_SLASHED_SYMLINK -# include -# include - -# include "stat-macros.h" -# include "xalloc.h" - -/* lstat works differently on Linux and Solaris systems. POSIX (see - `pathname resolution' in the glossary) requires that programs like `ls' - take into consideration the fact that FILE has a trailing slash when - FILE is a symbolic link. On Linux systems, the lstat function already - has the desired semantics (in treating `lstat("symlink/",sbuf)' just like - `lstat("symlink/.",sbuf)', but on Solaris it does not. - - If FILE has a trailing slash and specifies a symbolic link, - then append a `.' to FILE and call lstat a second time. */ - -static int -slash_aware_lstat (const char *file, struct stat *sbuf) -{ - size_t len; - char *new_file; - - int lstat_result = lstat (file, sbuf); - - if (lstat_result != 0 || !S_ISLNK (sbuf->st_mode)) - return lstat_result; - - len = strlen (file); - if (file[len - 1] != '/') - return lstat_result; - - /* FILE refers to a symbolic link and the name ends with a slash. - Append a `.' to FILE and repeat the lstat call. */ - - /* Add one for the `.' we'll append, and one more for the trailing NUL. */ - new_file = xmalloc (len + 1 + 1); - memcpy (new_file, file, len); - new_file[len] = '.'; - new_file[len + 1] = 0; - - lstat_result = lstat (new_file, sbuf); - free (new_file); - - return lstat_result; -} -#endif /* LSTAT && ! LSTAT_FOLLOWS_SLASHED_SYMLINK */ - -/* This is a wrapper for stat/lstat. - If FILE is the empty string, fail with errno == ENOENT. - Otherwise, return the result of calling the real stat/lstat. - - This works around the bug in some systems whereby stat/lstat succeeds when - given the zero-length file name argument. The stat/lstat from SunOS 4.1.4 - has this bug. */ - -/* This function also provides a version of lstat with consistent semantics - when FILE specifies a symbolic link and has a trailing slash. */ - -#ifdef LSTAT -# define rpl_xstat rpl_lstat -# if ! LSTAT_FOLLOWS_SLASHED_SYMLINK -# define xstat_return_val(F, S) slash_aware_lstat (F, S) -# else -# define xstat_return_val(F, S) lstat (F, S) -# endif -#else -# define rpl_xstat rpl_stat -# define xstat_return_val(F, S) stat (F, S) -#endif - -int -rpl_xstat (const char *file, struct stat *sbuf) -{ - if (file && *file == 0) - { - errno = ENOENT; - return -1; - } - - return xstat_return_val (file, sbuf); -} diff --git a/m4/ChangeLog b/m4/ChangeLog index 5563e7f051..b7bffee3c3 100644 --- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -1,3 +1,11 @@ +2005-06-24 Derek Price + and Bruno Haible + + Remove stat module & update lstat. + * lstat.m4 (gl_FUNC_LSTAT): Drop AC_FUNC_LSTAT in favor of + AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK. + * stat.m4: Remove this file. + 2005-06-20 Derek Price * bison.m4: Note that precious decls of YACC & YFLAGS will be diff --git a/m4/lstat.m4 b/m4/lstat.m4 index 3af1fdff07..59d7191f68 100644 --- a/m4/lstat.m4 +++ b/m4/lstat.m4 @@ -18,7 +18,7 @@ dnl AC_DEFUN([gl_FUNC_LSTAT], [ - AC_REQUIRE([AC_FUNC_LSTAT]) - dnl Note: AC_FUNC_LSTAT does AC_LIBOBJ(lstat). + AC_REQUIRE([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK]) + dnl Note: AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK does AC_LIBOBJ(lstat). : ]) diff --git a/m4/stat.m4 b/m4/stat.m4 deleted file mode 100644 index d87064518b..0000000000 --- a/m4/stat.m4 +++ /dev/null @@ -1,32 +0,0 @@ -#serial 11 - -# Copyright (C) 1997, 1998, 1999, 2000, 2001, 2003, 2004 Free Software -# Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -dnl From Jim Meyering. -dnl Determine whether stat has the bug that it succeeds when given the -dnl zero-length file name argument. The stat from SunOS 4.1.4 and the Hurd -dnl (as of 1998-11-01) do this. -dnl -dnl If it does, then define HAVE_STAT_EMPTY_STRING_BUG and arrange to -dnl compile the wrapper function. -dnl - -AC_DEFUN([gl_FUNC_STAT], -[ - AC_FUNC_STAT - dnl Note: AC_FUNC_STAT does AC_LIBOBJ(stat). - if test $ac_cv_func_stat_empty_string_bug = yes; then - gl_PREREQ_STAT - fi -]) - -# Prerequisites of lib/stat.c. -AC_DEFUN([gl_PREREQ_STAT], -[ - : -]) diff --git a/modules/lstat b/modules/lstat index f703aef964..d26e9646c4 100644 --- a/modules/lstat +++ b/modules/lstat @@ -1,12 +1,14 @@ Description: -stat() function: return information about a file or symbolic link. +lstat() function: return information about a file or symbolic link. Files: lib/lstat.c +lib/lstat.h m4/lstat.m4 Depends-on: -stat +xalloc +stat-macros configure.ac: gl_FUNC_LSTAT @@ -14,7 +16,7 @@ gl_FUNC_LSTAT Makefile.am: Include: - +"lstat.h" License: GPL diff --git a/modules/stat b/modules/stat deleted file mode 100644 index f9425d96c0..0000000000 --- a/modules/stat +++ /dev/null @@ -1,24 +0,0 @@ -Description: -stat() function: return information about a file, following symbolic links. - -Files: -lib/stat.c -m4/stat.m4 - -Depends-on: -xalloc -stat-macros - -configure.ac: -gl_FUNC_STAT - -Makefile.am: - -Include: - - -License: -GPL - -Maintainer: -Jim Meyering