summaryrefslogtreecommitdiff
path: root/src/uptime.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1999-01-31 16:53:28 +0000
committerJim Meyering <jim@meyering.net>1999-01-31 16:53:28 +0000
commit62b3fd4e81e400e4885a5ca0d0ead8ba7f0115ea (patch)
tree75991f5dd3ae4d27df45b30b7786e6d6b3e2ebbf /src/uptime.c
parentc4ece6d8cb80bbfc7a2ad2ab252be9f89138acd7 (diff)
downloadcoreutils-62b3fd4e81e400e4885a5ca0d0ead8ba7f0115ea.tar.xz
(print_uptime): Use the C numeric locale for sscanf
of /proc/uptime data, then restore.
Diffstat (limited to 'src/uptime.c')
-rw-r--r--src/uptime.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/uptime.c b/src/uptime.c
index c52496272..352f0ab4b 100644
--- a/src/uptime.c
+++ b/src/uptime.c
@@ -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 */