summaryrefslogtreecommitdiff
path: root/posix
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1996-12-02 04:00:15 +0000
committerUlrich Drepper <drepper@redhat.com>1996-12-02 04:00:15 +0000
commite4cf5070694529a8779d5e1581567bcfb9307da0 (patch)
treea0ea63fe9d81e75431c6c37340810c850e53c736 /posix
parenta401eea9eb827caa393c3206fa6f3939ea067e94 (diff)
downloadglibc-e4cf5070694529a8779d5e1581567bcfb9307da0.tar.gz
update from main archive 961201cvs/libc-961202
Mon Dec 2 03:59:38 1996 Ulrich Drepper <drepper@cygnus.com> * grp/initgroups.c: Update and reformat copyright. Use __getgrent_r instead of getgrent. * inet/rcmd.c: Update and reformat copyright. Use __gethostbyname_r instead of gethostbyname. * inet/rexec.c: Likewise. * intl/finddomain.c: Correct comment about CEN sponsor and revision. * locale/findlocale.c: Likewise. * intl/l10nflist.c: Correct handling of CEN sponsor and revision. * locale/Makefile (CPPFLAGS): Add definition of LOCALEDIR. * locale/setlocale.c (setlocale): Correctly split value of LOCALE_PATH. * locale/programs/localedef.c: Use LOCALEDIR not LOCALE_PATH to find output directory. * nss/getXXbyYY.c [NEED_H_ERRNO]: Before enlarging buffer test h_errno_tmp variable. Save error value from being changed during `free' call. * nss/getXXent.c: Likewise. * nss/nss_files/files-XXX.c: Set h_errno variable to NETDB_INTERNAL before returning ERANGE error. * posix/glob.c: Use getlogin_r and getpwnam_r function when available or in GNU libc. * pwd/getpw.c: Use getpwuid_r instead of getpwuid. * sunrpc/clnt_gen.c: Use gethostbyname_r and getprotobyname_r. * sunrpc/clnt_simp.c: Likewise. * sunrpc/getrpcport.c: Likewise. * sysdeps/unix/sysv/linux/gethostid.c: Likewise. * posix/getconf.c: Treat _SC_UNIT_MAX and _SC_ULONG_MAX separately since the value might be outsode the range of the `long int'. Print string `undefined' when a value is undefined. * stdlib/l64a.c: Return correct pointer. Patch by NIIBE Yutaka <gniibe@mri.co.jp>. * string/Makefile (routines): Add argz-addsep. * string/argz-addsep.c: New file. * string/argz.h: Add prototypes for argz_add_sep. * string/argz-ctsep.c: Prevent memory leak. * string/strcoll.c: Correct typo in comment. Sat Nov 30 02:53:59 1996 Ulrich Drepper <drepper@cygnus.com> * sysdeps/unix/sysv/linux/sys/serial.h: Removed again. The file is not general enough to be part of the libc. * sysdeps/unix/sysv/linux/Dist: Remove sys/serial.h. * sysdeps/unix/sysv/linux/Makefile: Don't install sys/serial.h. Thu Nov 28 20:04:41 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * login/Makefile: Fix typo. * nss/Makefile (generated): Filter out db-alias.c. Thu Nov 28 14:44:01 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * time/Makefile (echo-zonenames): Don't depend on non-existing target `zonenames'. Thu Nov 28 12:34:05 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * link.h: New file. * nss/nsswitch.c: Use it. * printf.h: Fix file name. * stdlib/strfmon.c: Use it.
Diffstat (limited to 'posix')
-rw-r--r--posix/getconf.c9
-rw-r--r--posix/glob.c45
2 files changed, 49 insertions, 5 deletions
diff --git a/posix/getconf.c b/posix/getconf.c
index f4f47650b7..5b67a281df 100644
--- a/posix/getconf.c
+++ b/posix/getconf.c
@@ -231,7 +231,14 @@ main (int argc, char *argv[])
if (argc > 2)
usage ();
value = sysconf (c->call_name);
- printf ("%ld\n", value);
+ if (value == -1l)
+ if (c->call_name == _SC_UINT_MAX
+ || c->call_name == _SC_ULONG_MAX)
+ printf ("%lu\n", value);
+ else
+ puts (_("undefined"));
+ else
+ printf ("%ld\n", value);
exit (0);
case CONFSTR:
diff --git a/posix/glob.c b/posix/glob.c
index b8820cee94..0fa15611bd 100644
--- a/posix/glob.c
+++ b/posix/glob.c
@@ -56,7 +56,7 @@ Cambridge, MA 02139, USA. */
#include <stddef.h>
#endif
-#ifdef HAVE_UNISTD_H
+#if defined HAVE_UNISTD_H || defined _LIBC
#include <unistd.h>
#ifndef POSIX
#ifdef _POSIX_VERSION
@@ -467,11 +467,40 @@ glob (pattern, flags, errfunc, pglob)
if (dirname == NULL || dirname[0] == '\0')
{
extern char *getlogin __P ((void));
- char *name = getlogin ();
- if (name != NULL)
+ extern int getlogin_r __P ((char *, size_t));
+ int success;
+
+#if defined HAVE_GETLOGIN_R || defined _LIBC
+ size_t buflen = sysconf (_SC_LOGIN_NAME_MAX) + 1;
+ char *name;
+
+ if (buflen == 0)
+ /* `sysconf' does not support _SC_LOGIN_NAME_MAX. Try
+ a moderate value. */
+ buflen = 16;
+ name = __alloca (buflen);
+
+ success = getlogin_r (name, buflen) >= 0;
+#else
+ char *name;
+ success = (name = getlogin ()) != NULL;
+#endif
+ if (success)
{
+#if defined HAVE_GETPWNAM_R || defined _LIBC
+ size_t pwbuflen = sysconf (_SC_GETPW_R_SIZE_MAX);
+ char *pwtmpbuf;
+ struct passwd pwbuf, *p;
+
+ pwtmpbuf = __alloca (pwbuflen);
+
+ success = (__getpwnam_r (name, &pwbuf, pwtmpbuf,
+ pwbuflen, &p) >= 0);
+#else
struct passwd *p = getpwnam (name);
- if (p != NULL)
+ success = p != NULL;
+#endif
+ if (success)
dirname = p->pw_dir;
}
}
@@ -491,9 +520,17 @@ glob (pattern, flags, errfunc, pglob)
dirname = "c:/users/default"; /* poor default */
#else
/* Look up specific user's home directory. */
+#if defined HAVE_GETPWNAM_R || defined _LIBC
+ size_t buflen = sysconf (_SC_GETPW_R_SIZE_MAX);
+ char *pwtmpbuf = __alloca (buflen);
+ struct passwd pwbuf, *p;
+ if (__getpwnam_r (dirname + 1, &pwbuf, pwtmpbuf, buflen, &p) >= 0)
+ dirname = p->pw_dir;
+#else
struct passwd *p = getpwnam (dirname + 1);
if (p != NULL)
dirname = p->pw_dir;
+#endif
#endif /* WIN32 */
#endif
}