Mercurial > hg > octave-lojdl > gnulib-hg
changeset 5887:cfb8f3b61b7f
Fix a few glitches in getlogin_r.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Wed, 25 May 2005 19:14:06 +0000 |
parents | 775f86a9883a |
children | 266767a72575 |
files | ChangeLog lib/ChangeLog lib/getlogin_r.c lib/getlogin_r.h m4/ChangeLog |
diffstat | 5 files changed, 25 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,7 @@ 2005-05-25 Derek Price <derek@ximbiot.com> Paul Eggert <eggert@cs.ucla.edu> - * lib/getlogin_r.c, lib/getlogin_r.h, m4/getlogin_r.m4, - modules/getlogin_r: New files. + * modules/getlogin_r: New files. 2005-05-18 Derek Price <derek@ximbiot.com>
--- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,8 @@ +2005-05-25 Derek Price <derek@ximbiot.com> + Paul Eggert <eggert@cs.ucla.edu> + + * getlogin_r.c, getlogin_r.h: New files. + 2005-05-22 Bruno Haible <bruno@clisp.org> * minmax.h: Include <limits.h> only when it defines MIN, MAX.
--- a/lib/getlogin_r.c +++ b/lib/getlogin_r.c @@ -18,7 +18,9 @@ /* written by Paul Eggert and Derek Price */ -#include <config.h> +#if HAVE_CONFIG_H +# include <config.h> +#endif #include "getlogin_r.h" @@ -38,22 +40,15 @@ getlogin_r (char *name, size_t size) { char *n; - int save_errno = errno; + size_t nlen; errno = 0; n = getlogin (); - if (n) - { - size_t nlen = strlen (n); - if (nlen < size) - { - memcpy (name, n, nlen + 1); - return 0; - } - errno = ERANGE; - } - - if (errno) return errno; - errno = save_errno; - return -1; + if (!n) + return errno ? errno : ENOENT; + nlen = strlen (n); + if (size <= nlen) + return ERANGE; + memcpy (name, n, nlen + 1); + return 0; }
--- a/lib/getlogin_r.h +++ b/lib/getlogin_r.h @@ -33,5 +33,6 @@ See <http://www.opengroup.org/onlinepubs/009695399/functions/getlogin.html>. */ +# include <stddef.h> int getlogin_r (char *name, size_t size); #endif
--- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -1,3 +1,8 @@ +2005-05-25 Derek Price <derek@ximbiot.com> + Paul Eggert <eggert@cs.ucla.edu> + + * getlogin_r.m4: New files. + 2005-05-22 Bruno Haible <bruno@clisp.org> * minmax.m4: New file. @@ -4226,7 +4231,7 @@ * uintmax_t.m4: New file. * Makefile.am (EXTRA_DIST): Add inttypes_h.m4 and uintmax_t.m4. -Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 +Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, -are permitted provided the copyright notice and this notice are preserved. \ No newline at end of file +are permitted provided the copyright notice and this notice are preserved.