From: Bruno Haible Date: Sat, 17 Dec 2016 10:00:30 +0000 (+0100) Subject: getlogin: Port to newer mingw. X-Git-Tag: v1.0~6486 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=8fe9cd1cfc148a37b352bd5320b5d3b35a3880fc;p=gnulib.git getlogin: Port to newer mingw. * m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize HAVE_DECL_GETLOGIN. * m4/getlogin.m4 (gl_FUNC_GETLOGIN): Set HAVE_DECL_GETLOGIN. * modules/unistd (Makefile.am): Substibute HAVE_DECL_GETLOGIN, not HAVE_GETLOGIN. * lib/unistd.in.h (getlogin): Test HAVE_DECL_GETLOGIN, not HAVE_GETLOGIN. * doc/posix-functions/getlogin.texi: Mention the issue. * tests/test-getlogin.c: Don't include on native Windows. --- diff --git a/ChangeLog b/ChangeLog index fc8bef9bdc..bd5ef81cc7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2016-12-17 Bruno Haible + + getlogin: Port to newer mingw. + * m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize HAVE_DECL_GETLOGIN. + * m4/getlogin.m4 (gl_FUNC_GETLOGIN): Set HAVE_DECL_GETLOGIN. + * modules/unistd (Makefile.am): Substibute HAVE_DECL_GETLOGIN, not + HAVE_GETLOGIN. + * lib/unistd.in.h (getlogin): Test HAVE_DECL_GETLOGIN, not + HAVE_GETLOGIN. + * doc/posix-functions/getlogin.texi: Mention the issue. + * tests/test-getlogin.c: Don't include on native Windows. Fixes + regression introduced on 2014-05-14. + 2016-12-16 Paul Eggert builtin-expect: improve port to IBM XL C diff --git a/doc/posix-functions/getlogin.texi b/doc/posix-functions/getlogin.texi index 2569eb1437..73e961cfc1 100644 --- a/doc/posix-functions/getlogin.texi +++ b/doc/posix-functions/getlogin.texi @@ -10,7 +10,10 @@ Portability problems fixed by Gnulib: @itemize @item This function is missing on some platforms: -mingw, MSVC 9. +older mingw, MSVC 9. +@item +This function is not declared unless @code{_POSIX} is defined on some platforms: +mingw. @end itemize Portability problems not fixed by Gnulib: diff --git a/lib/unistd.in.h b/lib/unistd.in.h index 61250c973d..686eb818c2 100644 --- a/lib/unistd.in.h +++ b/lib/unistd.in.h @@ -776,7 +776,7 @@ _GL_WARN_ON_USE (gethostname, "gethostname is unportable - " ${LOGNAME-$USER} on Unix platforms, $USERNAME on native Windows platforms. */ -# if !@HAVE_GETLOGIN@ +# if !@HAVE_DECL_GETLOGIN@ _GL_FUNCDECL_SYS (getlogin, char *, (void)); # endif _GL_CXXALIAS_SYS (getlogin, char *, (void)); diff --git a/m4/getlogin.m4 b/m4/getlogin.m4 index b3b2655dbb..a03193b06a 100644 --- a/m4/getlogin.m4 +++ b/m4/getlogin.m4 @@ -1,4 +1,4 @@ -# getlogin.m4 serial 3 +# getlogin.m4 serial 4 dnl Copyright (C) 2010-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -7,6 +7,10 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_GETLOGIN], [ AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + AC_CHECK_DECLS_ONCE([getlogin]) + if test $ac_cv_have_decl_getlogin = no; then + HAVE_DECL_GETLOGIN=0 + fi AC_CHECK_FUNCS_ONCE([getlogin]) if test $ac_cv_func_getlogin = no; then HAVE_GETLOGIN=0 diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4 index 544dadb412..46ff109944 100644 --- a/m4/unistd_h.m4 +++ b/m4/unistd_h.m4 @@ -1,4 +1,4 @@ -# unistd_h.m4 serial 68 +# unistd_h.m4 serial 69 dnl Copyright (C) 2006-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -145,6 +145,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS], HAVE_DECL_FCHDIR=1; AC_SUBST([HAVE_DECL_FCHDIR]) HAVE_DECL_FDATASYNC=1; AC_SUBST([HAVE_DECL_FDATASYNC]) HAVE_DECL_GETDOMAINNAME=1; AC_SUBST([HAVE_DECL_GETDOMAINNAME]) + HAVE_DECL_GETLOGIN=1; AC_SUBST([HAVE_DECL_GETLOGIN]) HAVE_DECL_GETLOGIN_R=1; AC_SUBST([HAVE_DECL_GETLOGIN_R]) HAVE_DECL_GETPAGESIZE=1; AC_SUBST([HAVE_DECL_GETPAGESIZE]) HAVE_DECL_GETUSERSHELL=1; AC_SUBST([HAVE_DECL_GETUSERSHELL]) diff --git a/modules/unistd b/modules/unistd index 1619509694..8af837ca59 100644 --- a/modules/unistd +++ b/modules/unistd @@ -99,7 +99,6 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H -e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \ -e 's|@''HAVE_GETGROUPS''@|$(HAVE_GETGROUPS)|g' \ -e 's|@''HAVE_GETHOSTNAME''@|$(HAVE_GETHOSTNAME)|g' \ - -e 's|@''HAVE_GETLOGIN''@|$(HAVE_GETLOGIN)|g' \ -e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \ -e 's|@''HAVE_GROUP_MEMBER''@|$(HAVE_GROUP_MEMBER)|g' \ -e 's|@''HAVE_LCHOWN''@|$(HAVE_LCHOWN)|g' \ @@ -121,6 +120,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H -e 's|@''HAVE_DECL_FCHDIR''@|$(HAVE_DECL_FCHDIR)|g' \ -e 's|@''HAVE_DECL_FDATASYNC''@|$(HAVE_DECL_FDATASYNC)|g' \ -e 's|@''HAVE_DECL_GETDOMAINNAME''@|$(HAVE_DECL_GETDOMAINNAME)|g' \ + -e 's|@''HAVE_DECL_GETLOGIN''@|$(HAVE_DECL_GETLOGIN)|g' \ -e 's|@''HAVE_DECL_GETLOGIN_R''@|$(HAVE_DECL_GETLOGIN_R)|g' \ -e 's|@''HAVE_DECL_GETPAGESIZE''@|$(HAVE_DECL_GETPAGESIZE)|g' \ -e 's|@''HAVE_DECL_GETUSERSHELL''@|$(HAVE_DECL_GETUSERSHELL)|g' \ diff --git a/tests/test-getlogin.c b/tests/test-getlogin.c index 6e1b64c7a9..ed04c8c27b 100644 --- a/tests/test-getlogin.c +++ b/tests/test-getlogin.c @@ -28,7 +28,9 @@ SIGNATURE_CHECK (getlogin, char *, (void)); #include #include #include -#include +#if !((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__) +# include +#endif #include #include