]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(print_uptime): Use the C numeric locale for sscanf
authorJim Meyering <jim@meyering.net>
Sun, 31 Jan 1999 16:53:28 +0000 (16:53 +0000)
committerJim Meyering <jim@meyering.net>
Sun, 31 Jan 1999 16:53:28 +0000 (16:53 +0000)
of /proc/uptime data, then restore.

src/uptime.c

index c52496272cace44e4da5836df3ed6597a77624d4..352f0ab4bb3c471761155b1f887278ccadbc632f 100644 (file)
@@ -1,5 +1,5 @@
 /* GNU's uptime.
-   Copyright (C) 92, 93, 94, 95, 96, 1997, 1998 Free Software Foundation, Inc.
+   Copyright (C) 92, 93, 94, 95, 96, 1997, 1998, 1999 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -63,9 +63,14 @@ print_uptime (int n, const STRUCT_UTMP *this)
       char buf[BUFSIZ];
       int res;
       fgets (buf, BUFSIZ, fp);
+
+      /* The following sscanf must use the C locale.  */
+      setlocale (LC_NUMERIC, "C");
       res = sscanf (buf, "%lf", &upsecs);
+      setlocale (LC_NUMERIC, "");
       if (res == 1)
        uptime = (time_t) upsecs;
+
       fclose (fp);
     }
 #endif /* HAVE_PROC_UPTIME */