From 922e4e22cc70fbfd62071660676c093f02839517 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Tue, 30 Mar 2004 13:50:44 +0000 Subject: [PATCH] Merge changes from emacs (via gnulib). --- lib/getloadavg.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/getloadavg.c b/lib/getloadavg.c index c6b6fee109..dce4117f08 100644 --- a/lib/getloadavg.c +++ b/lib/getloadavg.c @@ -111,10 +111,11 @@ extern int errno; # include #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; -- 2.47.2