X-Git-Url: https://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fgetloadavg.c;h=e9c4c08890203d4ac568b835ba07c7afc265132d;hb=9a3aebb793224b17196fc77d6cb203a41a5c1905;hp=3d81bdd964ef8650ed46a6c6040a35ef7844c419;hpb=a8b5f7b77bf805e866a739998920f8e6a72e4a11;p=gnulib.git diff --git a/lib/getloadavg.c b/lib/getloadavg.c index 3d81bdd96..e9c4c0889 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 +#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 @@ -302,6 +308,12 @@ extern int errno; # define LDAV_CVT(n) (((double) (n)) / FSCALE) # endif +# ifndef NLIST_STRUCT +# if HAVE_NLIST_H +# define NLIST_STRUCT +# endif +# endif + /* VAX C can't handle multi-line #ifs, or lines longer that 256 characters. */ # ifndef NLIST_STRUCT @@ -638,8 +650,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;