* 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 <pwd.h> on native Windows.
+2016-12-17 Bruno Haible <bruno@clisp.org>
+
+ 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 <pwd.h> on native Windows. Fixes
+ regression introduced on 2014-05-14.
+
2016-12-16 Paul Eggert <eggert@cs.ucla.edu>
builtin-expect: improve port to IBM XL C
@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:
${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));
-# 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,
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
-# 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,
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])
-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' \
-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' \
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <pwd.h>
+#if !((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__)
+# include <pwd.h>
+#endif
#include <sys/stat.h>
#include <sys/types.h>