Mercurial > hg > octave-lojdl > gnulib-hg
changeset 12611:42a30e18244c
getlogin_r: Small fixes.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sat, 09 Jan 2010 15:14:41 +0100 |
parents | 80d708efef7d |
children | 62e2caeb3995 |
files | ChangeLog lib/getlogin_r.c m4/getlogin_r.m4 |
diffstat | 3 files changed, 22 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2010-01-09 Bruno Haible <bruno@clisp.org> + + getlogin_r: Small fixes. + * lib/getlogin_r.c (getlogin_r): Don't set errno if the function + succeeds. + * m4/getlogin_r.m4 (gl_GETLOGIN_R): Require gl_USE_SYSTEM_EXTENSIONS + before testing whether getlogin_r is declared. No need to set + HAVE_DECL_GETLOGIN_R to 1. + (gl_PREREQ_GETLOGIN_R): Don't check for the getlogin_r declaration. + 2010-01-09 Bruno Haible <bruno@clisp.org> * lib/unistd.in.h (getlogin_r): Add comment.
--- a/lib/getlogin_r.c +++ b/lib/getlogin_r.c @@ -1,6 +1,6 @@ /* Provide a working getlogin_r for systems which lack it. - Copyright (C) 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2005-2007, 2009-2010 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 @@ -39,15 +39,10 @@ errno = 0; n = getlogin (); + if (!n) + /* ENOENT is a reasonable errno value if getlogin returns NULL. */ + return (errno != 0 ? errno : ENOENT); - /* A system function like getlogin_r is never supposed to set errno - to zero, so make sure errno is nonzero here. ENOENT is a - reasonable errno value if getlogin returns NULL. */ - if (!errno) - errno = ENOENT; - - if (!n) - return errno; nlen = strlen (n); if (size <= nlen) return ERANGE;
--- a/m4/getlogin_r.m4 +++ b/m4/getlogin_r.m4 @@ -1,6 +1,6 @@ -#serial 4 +#serial 5 -# Copyright (C) 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. +# Copyright (C) 2005-2007, 2009-2010 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -14,13 +14,16 @@ AC_DEFUN([gl_GETLOGIN_R], [ AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) + + dnl Persuade glibc <unistd.h> to declare getlogin_r(). + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_CHECK_FUNCS_ONCE([getlogin_r]) if test $ac_cv_func_getlogin_r = no; then AC_LIBOBJ([getlogin_r]) gl_PREREQ_GETLOGIN_R - if test $ac_cv_have_decl_getlogin_r = yes; then - HAVE_DECL_GETLOGIN_R=1 - else + AC_CHECK_DECLS_ONCE([getlogin_r]) + if test $ac_cv_have_decl_getlogin_r = no; then HAVE_DECL_GETLOGIN_R=0 fi fi @@ -29,5 +32,4 @@ AC_DEFUN([gl_PREREQ_GETLOGIN_R], [ AC_CHECK_DECLS_ONCE([getlogin]) - AC_CHECK_DECLS_ONCE([getlogin_r]) ])