From: Paul Eggert Date: Tue, 30 Mar 2004 18:51:56 +0000 (+0000) Subject: (getloadavg): Don't assume setlocale returns nonnull. X-Git-Tag: cvs-readonly~4205 X-Git-Url: http://erislabs.net/gitweb/?a=commitdiff_plain;h=6f2d98f7b497c21390d667021b9ba6d516edcd4d;p=gnulib.git (getloadavg): Don't assume setlocale returns nonnull. --- diff --git a/lib/ChangeLog b/lib/ChangeLog index 76d685ee4..75c4123fb 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,13 +1,18 @@ +2004-03-30 Bruno Haible + + * getloadavg.c (getloadavg): Don't assume setlocale returns + nonnull. + 2004-03-29 Paul Eggert Merge changes to getloadavg.c from coreutils and Emacs. - * lib/getloadavg.c [!defined HAVE_SETLOCALE] (setlocale): + * getloadavg.c [!defined HAVE_SETLOCALE] (setlocale): Define to an expression, not to the empty string. Include cloexec.h and xalloc.h. (getloadavg): Restore LC_NUMERIC locale after setting it temporarily. Use set_cloexec_flag rather than rolling our own. - * lib/cloexec.c, lib/cloexec.h: New files. + * cloexec.c, cloexec.h: New files. 2004-03-18 Paul Eggert @@ -24,7 +29,7 @@ * argp-parse.c, getopt.c, getopt.h, getopt1.c: Sync with libc CVS. - * lib/getopt_int.h: New file, also synced from libc. + * getopt_int.h: New file, also synced from libc. 2004-03-07 Paul Eggert @@ -592,17 +597,17 @@ 2003-10-12 Paul Eggert - * lib/xalloc.h (xnmalloc, xzalloc, xnrealloc, xclone): New decls. + * xalloc.h (xnmalloc, xzalloc, xnrealloc, xclone): New decls. (XMALLOC, XCALLOC, XREALLOC, XFREE, CCLONE, CLONE): Deprecate, and define in terms of the other primitives. - * lib/xmalloc.c: Include stdbool.h; do not include exit.h. + * xmalloc.c: Include stdbool.h; do not include exit.h. (SIZE_MAX): Define if not already defined. (array_size_overflow): New function. (xalloc_die): Abort instead of exiting if 'error' returns. (xnmalloc, xnrealloc, xzalloc, xclone): New functions. (xmalloc, xrealloc): Use them. (xcalloc): Check for address arithmetic overflow. - * lib/xstrdup.c (xstrdup): Use xclone, since memcpy should be + * xstrdup.c (xstrdup): Use xclone, since memcpy should be a bit faster than strcpy. 2003-10-08 Paul Eggert @@ -1394,11 +1399,11 @@ Merge some files from coreutils. These changes were originally made by Jim Meyering. - * lib/acl.c: Include before ; + * acl.c: Include before ; many older Unixes require this. - * lib/alloca.c (alloca): Remove cast to argument of free; + * alloca.c (alloca): Remove cast to argument of free; no longer needed in C89. - * lib/alloca_.h, lib/regex.h: Fix white space to match + * alloca_.h, regex.h: Fix white space to match what GNU indent does. 2003-08-05 Paul Eggert diff --git a/lib/getloadavg.c b/lib/getloadavg.c index dce4117f0..ed079b2ec 100644 --- a/lib/getloadavg.c +++ b/lib/getloadavg.c @@ -606,7 +606,9 @@ getloadavg (double loadavg[], int nelem) return -1; /* The following sscanf must use the C locale. */ - old_locale = xstrdup (setlocale (LC_NUMERIC, NULL)); + old_locale = setlocale (LC_NUMERIC, NULL); + if (old_locale) + old_locale = xstrdup (old_locale); setlocale (LC_NUMERIC, "C"); count = sscanf (ldavgbuf, "%lf %lf %lf", &load_ave[0], &load_ave[1], &load_ave[2]);