-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to Paul Eggert on 6/28/2006 10:32 AM: > > I'd rather not do that. Surely there's a less-intrusive way to fix > this problem on nonstandard platforms like that. You can use your own > <sys/stat.h> replacement, for example. >
Here's my proposal for a <sys/stat.h> replacement, tested on native cygwin and cross-compiling to mingw; with it, the mkstemp module compiles on mingw. Any feedback before I install this? ChangeLog: 2006-06-29 Eric Blake <[EMAIL PROTECTED]> * MODULES.html.sh: Add sys_stat. * modules/sys_stat: New module. * modules/mkstemp (Depends-on): Add sys_stat. doc/ChangeLog: 2006-06-28 Eric Blake <[EMAIL PROTECTED]> * functions.texi (Function Portability): Document missing lstat on mingw. lib/ChangeLog: 2006-06-29 Eric Blake <[EMAIL PROTECTED]> * stat_.h: New file. m4/ChangeLog: 2006-06-29 Eric Blake <[EMAIL PROTECTED]> * sys_stat_h.m4 (gl_HEADER_SYS_STAT_H): New file. - -- Life is short - so eat dessert first! Eric Blake [EMAIL PROTECTED] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.1 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFEo8nP84KuGfSFAYARAso7AJ9nTtFK77tMvwpuCCuygMGGBbuyewCgyMvu 3BRL4eoHE8bkKGAfmrVzWP8= =+KBv -----END PGP SIGNATURE-----
Index: MODULES.html.sh =================================================================== RCS file: /sources/gnulib/gnulib/MODULES.html.sh,v retrieving revision 1.119 diff -u -p -r1.119 MODULES.html.sh --- MODULES.html.sh 29 Jun 2006 10:59:42 -0000 1.119 +++ MODULES.html.sh 29 Jun 2006 12:13:12 -0000 @@ -1808,6 +1808,7 @@ func_all_modules () func_module rmdir func_module ssize_t func_module strtok_r + func_module sys_stat func_module unistd func_module utime func_module wcwidth Index: doc/functions.texi =================================================================== RCS file: /sources/gnulib/gnulib/doc/functions.texi,v retrieving revision 1.3 diff -u -p -r1.3 functions.texi --- doc/functions.texi 22 May 2006 18:52:10 -0000 1.3 +++ doc/functions.texi 29 Jun 2006 12:13:12 -0000 @@ -366,6 +366,9 @@ On platforms where @code{off_t} is a 32- correctly report the size of files or block devices larger than 2 GB. The fix is to use the @code{AC_SYS_LARGEFILE} macro. +On Windows systems (excluding Cygwin), symlinks are not supported, so [EMAIL PROTECTED] does not exist. Just define lstat to use stat. + @item mbrtowc @itemx mbsrtowcs @itemx mbstowcs Index: lib/stat_.h =================================================================== RCS file: lib/stat_.h diff -N lib/stat_.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lib/stat_.h 29 Jun 2006 12:13:17 -0000 @@ -0,0 +1,43 @@ +/* Provide a complete sys/stat header file. + Copyright (C) 2006 Free Software Foundation, Inc. + Written by Eric Blake. + + 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. */ + +#ifndef _gl_SYS_STAT_H +#define _gl_SYS_STAT_H + +/* This file is supposed to be used on platforms where <sys/stat.h> is + incomplete. It is intended to provide definitions and prototypes + needed by an application. Start with what the system provides. */ +#include @FULL_PATH_SYS_STAT_H@ + +/* mingw does not support symlinks, therefore it does not have lstat. But + without links, stat does just fine. */ +#if ! HAVE_FUNC_LSTAT +# define lstat stat +#endif + +/* mingw's _mkdir() function has 1 argument, but we pass 2 arguments. + Therefore we have to disable the argument count checking. Additionally, + it only declares _mkdir in the nonstandard io.h. */ +#if ! HAVE_DECL_MKDIR +# if HAVE_IO_H +# include <io.h> +# endif +# define mkdir ((int (*)()) _mkdir) +#endif + +#endif /* _gl_SYS_STAT_H */ Index: m4/sys_stat_h.m4 =================================================================== RCS file: m4/sys_stat_h.m4 diff -N m4/sys_stat_h.m4 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ m4/sys_stat_h.m4 29 Jun 2006 12:13:17 -0000 @@ -0,0 +1,30 @@ +# sys_stat_h.m4 serial 1 -*- Autoconf -*- +dnl Copyright (C) 2006 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Eric Blake. +dnl Test whether <sys/stat.h> contains lstat and mkdir or must be substituted. + +AC_DEFUN([gl_HEADER_SYS_STAT_H], +[ + dnl Check for lstat. Systems that lack it (mingw) also lack symlinks, so + dnl stat is a good replacement. + AC_CHECK_FUNCS_ONCE([lstat]) + + dnl Check for mkdir. Mingw has _mkdir(name) in the nonstandard <io.h> + dnl instead. + AC_CHECK_DECLS([mkdir], [], [], [#include <sys/stat.h> +]) + + SYS_STAT_H= + if test $ac_cv_func_lstat:$ac_cv_have_decl_mkdir != yes:yes ; then + gl_FULL_HEADER_PATH([sys/stat.h]) + FULL_PATH_SYS_STAT_H='<'$gl_cv_full_path_sys_stat_h'>' + AC_CHECK_HEADERS([io.h]) + AC_SUBST([FULL_PATH_SYS_STAT_H]) + SYS_STAT_H='sys/stat.h' + fi + AC_SUBST([SYS_STAT_H]) +]) Index: modules/mkstemp =================================================================== RCS file: /sources/gnulib/gnulib/modules/mkstemp,v retrieving revision 1.6 diff -u -p -r1.6 mkstemp --- modules/mkstemp 2 May 2005 07:00:50 -0000 1.6 +++ modules/mkstemp 29 Jun 2006 12:13:17 -0000 @@ -12,6 +12,7 @@ m4/mkstemp.m4 Depends-on: stat-macros +sys_stat configure.ac: gl_FUNC_MKSTEMP Index: modules/sys_stat =================================================================== RCS file: modules/sys_stat diff -N modules/sys_stat --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ modules/sys_stat 29 Jun 2006 12:13:17 -0000 @@ -0,0 +1,35 @@ +Description: +A <sys/stat.h> for systems with missing declarations. + +Files: +lib/stat_.h +m4/full-header-path.m4 +m4/sys_stat_h.m4 + +Depends-on: + +configure.ac: +gl_HEADER_SYS_STAT_H + +Makefile.am: +BUILT_SOURCES += $(SYS_STAT_H) +EXTRA_DIST += stat_.h + +# We need the following in order to create <sys/stat.h> when the system +# has one that is incomplete. +sys/stat.h: stat_.h + test -d sys || mkdir sys + sed -e 's|@''FULL_PATH_SYS_STAT_H''@|$(FULL_PATH_SYS_STAT_H)|g' \ + < $(srcdir)/stat_.h > [EMAIL PROTECTED] + mv [EMAIL PROTECTED] $@ +MOSTLYCLEANFILES += sys/stat.h sys/stat.h-t +MOSTLYCLEANDIRS += sys + +Include: +#include <sys/stat.h> + +License: +LGPL + +Maintainer: +Eric Blake