diff options
author | Jim Meyering <jim@meyering.net> | 2004-03-30 13:50:44 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2004-03-30 13:50:44 +0000 |
commit | 922e4e22cc70fbfd62071660676c093f02839517 (patch) | |
tree | f06b9c58b473c9a81377236f1abc56a2de43345a | |
parent | 739d31dc6672734c90829a4391145464bf850c5e (diff) | |
download | coreutils-922e4e22cc70fbfd62071660676c093f02839517.tar.xz |
Merge changes from emacs (via gnulib).
-rw-r--r-- | lib/getloadavg.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/getloadavg.c b/lib/getloadavg.c index c6b6fee10..dce4117f0 100644 --- a/lib/getloadavg.c +++ b/lib/getloadavg.c @@ -111,10 +111,11 @@ extern int errno; # include <locale.h> #endif #ifndef HAVE_SETLOCALE -# define setlocale(Category, Locale) /* empty */ +# define setlocale(Category, Locale) ((char *) NULL) #endif #include "cloexec.h" +#include "xalloc.h" #ifndef HAVE_GETLOADAVG @@ -594,6 +595,7 @@ getloadavg (double loadavg[], int nelem) char ldavgbuf[40]; double load_ave[3]; int fd, count; + char *old_locale; fd = open (LINUX_LDAV_FILE, O_RDONLY); if (fd == -1) @@ -604,10 +606,12 @@ getloadavg (double loadavg[], int nelem) return -1; /* The following sscanf must use the C locale. */ + old_locale = xstrdup (setlocale (LC_NUMERIC, NULL)); setlocale (LC_NUMERIC, "C"); count = sscanf (ldavgbuf, "%lf %lf %lf", &load_ave[0], &load_ave[1], &load_ave[2]); - setlocale (LC_NUMERIC, ""); + setlocale (LC_NUMERIC, old_locale); + free (old_locale); if (count < 1) return -1; |