diff options
author | Jim Meyering <jim@meyering.net> | 1999-01-31 16:54:00 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1999-01-31 16:54:00 +0000 |
commit | a12101a2246aca9d93a03d610eafecf76eb4c86a (patch) | |
tree | 52aa1f3605bbb77bbdfbbaacfad97b60ff693b3e /lib/getloadavg.c | |
parent | 62b3fd4e81e400e4885a5ca0d0ead8ba7f0115ea (diff) | |
download | coreutils-a12101a2246aca9d93a03d610eafecf76eb4c86a.tar.xz |
Include locale.h.
[!HAVE_SETLOCALE]: Define-away setlocale.
(getloadavg): Ensure the sscanf of /proc/getloadavg data uses the
`C' numeric locale. Restore afterwards.
Diffstat (limited to 'lib/getloadavg.c')
-rw-r--r-- | lib/getloadavg.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/getloadavg.c b/lib/getloadavg.c index 3d81bdd96..8acb58692 100644 --- a/lib/getloadavg.c +++ b/lib/getloadavg.c @@ -98,8 +98,14 @@ extern int errno; #endif -#ifndef HAVE_GETLOADAVG +#if HAVE_LOCALE_H +# include <locale.h> +#endif +#if !HAVE_SETLOCALE +# define setlocale(Category, Locale) /* empty */ +#endif +#ifndef HAVE_GETLOADAVG /* The existing Emacs configuration files define a macro called LOAD_AVE_CVT, which accepts a value of type LOAD_AVE_TYPE, and @@ -638,8 +644,11 @@ getloadavg (loadavg, nelem) if (count <= 0) return -1; + /* The following sscanf must use the C locale. */ + setlocale (LC_NUMERIC, "C"); count = sscanf (ldavgbuf, "%lf %lf %lf", &load_ave[0], &load_ave[1], &load_ave[2]); + setlocale (LC_NUMERIC, ""); if (count < 1) return -1; |