Mercurial > hg > octave-lyh > gnulib-hg
changeset 9954:0f61f5040489
Fix compilation errors related to rpl_mkdir on mingw.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Mon, 21 Apr 2008 23:57:39 +0200 |
parents | 5605642e7756 |
children | 288822bd74b0 |
files | ChangeLog lib/mkdir.c lib/sys_stat.in.h m4/mkdir-slash.m4 m4/sys_stat_h.m4 modules/sys_stat |
diffstat | 6 files changed, 68 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2008-04-20 Bruno Haible <bruno@clisp.org> + + * lib/mkdir.c (mkdir): Undefine after the includes, not right after + config.h. Provide _mkdir based fallback for mingw. + * lib/sys_stat.in.h (mkdir): Define through an 'extern' declaration + if REPLACE_MKDIR is 1. Otherwise, test for mingw directly. + * m4/mkdir-slash.m4 (gl_FUNC_MKDIR_TRAILING_SLASH): Require + gl_SYS_STAT_H_DEFAULTS. When doing the replacement, set REPLACE_MKDIR + rather than defining mkdir in config.h. + * m4/sys_stat_h.m4 (gl_SYS_STAT_MODULE_INDICATOR): New macro. + (gl_SYS_STAT_H_DEFAULTS): New macro. + (gl_HEADER_SYS_STAT_H): Require it. Don't set HAVE_DECL_MKDIR and + HAVE_IO_H any more. + * modules/sys_stat (Makefile.am): Substitute REPLACE_MKDIR instead of + HAVE_DECL_MKDIR and HAVE_IO_H. + 2008-04-20 Bruno Haible <bruno@clisp.org> * lib/isapipe.c: Port to native Windows platforms.
--- a/lib/mkdir.c +++ b/lib/mkdir.c @@ -1,7 +1,7 @@ /* On some systems, mkdir ("foo/", 0700) fails because of the trailing slash. On those systems, this wrapper removes the trailing slash. - Copyright (C) 2001, 2003, 2006 Free Software Foundation, Inc. + Copyright (C) 2001, 2003, 2006, 2008 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 @@ -20,13 +20,10 @@ #include <config.h> -/* Disable the definition of mkdir to rpl_mkdir (from config.h) in this - file. Otherwise, we'd get conflicting prototypes for rpl_mkdir on - most systems. */ -#undef mkdir - +/* Specification. */ #include <sys/types.h> #include <sys/stat.h> + #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -34,6 +31,17 @@ #include "dirname.h" #include "xalloc.h" +/* Disable the definition of mkdir to rpl_mkdir (from the <sys/stat.h> + substitute) in this file. Otherwise, we'd get an endless recursion. */ +#undef mkdir + +/* mingw's _mkdir() function has 1 argument, but we pass 2 arguments. + Additionally, it declares _mkdir (and depending on compile flags, an + alias mkdir), only in the nonstandard io.h. */ +#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +# define mkdir(name,mode) _mkdir (name) +#endif + /* This function is required at least for NetBSD 1.5.2. */ int
--- a/lib/sys_stat.in.h +++ b/lib/sys_stat.in.h @@ -1,5 +1,5 @@ /* Provide a more complete sys/stat header file. - Copyright (C) 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2006-2008 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 @@ -29,6 +29,12 @@ #ifndef _GL_SYS_STAT_H #define _GL_SYS_STAT_H +/* Before doing "#define mkdir rpl_mkdir" below, we need to include all + headers that may declare mkdir(). */ +#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +# include <io.h> +#endif + #ifndef S_IFMT # define S_IFMT 0170000 #endif @@ -261,11 +267,15 @@ # define lstat stat #endif +#if @REPLACE_MKDIR@ +# undef mkdir +# define mkdir rpl_mkdir +extern int mkdir (char const *name, mode_t mode); +#else /* mingw's _mkdir() function has 1 argument, but we pass 2 arguments. Additionally, it declares _mkdir (and depending on compile flags, an - alias mkdir), only in the nonstandard io.h. */ -#if ! @HAVE_DECL_MKDIR@ && @HAVE_IO_H@ -# include <io.h> + alias mkdir), only in the nonstandard <io.h>, which is included above. */ +# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ static inline int rpl_mkdir (char const *name, mode_t mode) @@ -273,7 +283,8 @@ return _mkdir (name); } -# define mkdir rpl_mkdir +# define mkdir rpl_mkdir +# endif #endif #endif /* _GL_SYS_STAT_H */
--- a/m4/mkdir-slash.m4 +++ b/m4/mkdir-slash.m4 @@ -1,6 +1,6 @@ -#serial 5 +#serial 6 -# Copyright (C) 2001, 2003, 2004, 2006 Free Software Foundation, Inc. +# Copyright (C) 2001, 2003, 2004, 2006, 2008 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. @@ -10,6 +10,7 @@ # trailing slashes. AC_DEFUN([gl_FUNC_MKDIR_TRAILING_SLASH], [dnl + AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) AC_CHECK_HEADERS_ONCE(unistd.h) AC_CACHE_CHECK([whether mkdir fails due to a trailing slash], gl_cv_func_mkdir_trailing_slash_bug, @@ -37,9 +38,8 @@ ) if test $gl_cv_func_mkdir_trailing_slash_bug = yes; then + REPLACE_MKDIR=1 AC_LIBOBJ(mkdir) - AC_DEFINE(mkdir, rpl_mkdir, - [Define to rpl_mkdir if the replacement function should be used.]) gl_PREREQ_MKDIR fi ])
--- a/m4/sys_stat_h.m4 +++ b/m4/sys_stat_h.m4 @@ -1,4 +1,4 @@ -# sys_stat_h.m4 serial 7 -*- Autoconf -*- +# sys_stat_h.m4 serial 8 -*- Autoconf -*- dnl Copyright (C) 2006-2008 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -9,6 +9,8 @@ AC_DEFUN([gl_HEADER_SYS_STAT_H], [ + AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) + dnl Check for lstat. Systems that lack it (mingw) also lack symlinks, so dnl stat is a good replacement. AC_CHECK_FUNCS_ONCE([lstat]) @@ -19,24 +21,7 @@ fi AC_SUBST([HAVE_LSTAT]) - dnl Check for mkdir. Mingw has _mkdir(name) in the nonstandard <io.h> - dnl instead. - AC_CHECK_DECLS([mkdir], - [], - [AC_CHECK_HEADERS([io.h])], - [#include <sys/stat.h>]) - if test $ac_cv_have_decl_mkdir = yes; then - HAVE_DECL_MKDIR=1 - else - HAVE_DECL_MKDIR=0 - fi - AC_SUBST([HAVE_DECL_MKDIR]) - if test "$ac_cv_header_io_h" = yes; then - HAVE_IO_H=1 - else - HAVE_IO_H=0 - fi - AC_SUBST([HAVE_IO_H]) + dnl For the mkdir substitute. AC_REQUIRE([AC_C_INLINE]) dnl Check for broken stat macros. @@ -55,3 +40,16 @@ #include <sys/stat.h>]) ]) # gl_HEADER_SYS_STAT_H + +AC_DEFUN([gl_SYS_STAT_MODULE_INDICATOR], +[ + dnl Use AC_REQUIRE here, so that the default settings are expanded once only. + AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) + GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1 +]) + +AC_DEFUN([gl_SYS_STAT_H_DEFAULTS], +[ + dnl Assume proper GNU behavior unless another module says otherwise. + REPLACE_MKDIR=0; AC_SUBST([REPLACE_MKDIR]) +])
--- a/modules/sys_stat +++ b/modules/sys_stat @@ -23,9 +23,8 @@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \ -e 's|@''NEXT_SYS_STAT_H''@|$(NEXT_SYS_STAT_H)|g' \ - -e 's|@''HAVE_IO_H''@|$(HAVE_IO_H)|g' \ -e 's|@''HAVE_LSTAT''@|$(HAVE_LSTAT)|g' \ - -e 's|@''HAVE_DECL_MKDIR''@|$(HAVE_DECL_MKDIR)|g' \ + -e 's|@''REPLACE_MKDIR''@|$(REPLACE_MKDIR)|g' \ < $(srcdir)/sys_stat.in.h; \ } > $@-t mv $@-t $@