]> Savannah Git Hosting - gnulib.git/commitdiff
getlogin: Port to newer mingw.
authorBruno Haible <bruno@clisp.org>
Sat, 17 Dec 2016 10:00:30 +0000 (11:00 +0100)
committerBruno Haible <bruno@clisp.org>
Sat, 17 Dec 2016 11:05:38 +0000 (12:05 +0100)
* 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.

ChangeLog
doc/posix-functions/getlogin.texi
lib/unistd.in.h
m4/getlogin.m4
m4/unistd_h.m4
modules/unistd
tests/test-getlogin.c

index fc8bef9bdc2ca000489ae2b6b2f9e8d79980f8c3..bd5ef81cc7a5edf270ac914050be66130152d04a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+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
index 2569eb14378629644fa64980a594fa6bbcf507e0..73e961cfc1c14224c3a547fcf0e4bdb46c2722b9 100644 (file)
@@ -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:
index 61250c973d4df7831afcab35237df1663cb4e7c1..686eb818c20d21ec2ef3c0585e183590358d880a 100644 (file)
@@ -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));
index b3b2655dbb4a1aa44b9fbf573eb1b8aa0d4e034e..a03193b06a94dcddec75ed419bd64d3a1276a991 100644 (file)
@@ -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
index 544dadb4122ff3c21f005b786b85b51f1f51ca4e..46ff109944313d0aa792616ae419e8f588096fb1 100644 (file)
@@ -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])
index 1619509694db3e327ab64e089f609e3f12a9c467..8af837ca59eb51a5dba3a2fff5955e2dc3825858 100644 (file)
@@ -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' \
index 6e1b64c7a9cc074f221a95a4ef0b586320ae71cf..ed04c8c27b063ff12ecfffaca356056d045e2277 100644 (file)
@@ -28,7 +28,9 @@ SIGNATURE_CHECK (getlogin, char *, (void));
 #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>