changeset 1694:4e91c96ef423

Include locale.h. [!HAVE_SETLOCALE]: Define-away setlocale. (getloadavg): Ensure the sscanf of /proc/getloadavg data uses the `C' numeric locale. Restore afterwards.
author Jim Meyering <jim@meyering.net>
date Sun, 31 Jan 1999 16:54:00 +0000
parents f0186dc826f7
children 8a8968a55207
files lib/getloadavg.c
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lib/getloadavg.c
+++ b/lib/getloadavg.c
@@ -98,9 +98,15 @@
 extern int errno;
 #endif
 
+#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
    returns the load average multiplied by 100.  What we actually want
@@ -638,8 +644,11 @@
   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;