]> granicus.if.org Git - procps-ng/commitdiff
watch,free: interpet intervals in non-locale way
authorCraig Small <csmall@enc.com.au>
Sun, 3 Jul 2016 06:14:36 +0000 (16:14 +1000)
committerCraig Small <csmall@enc.com.au>
Sun, 3 Jul 2016 06:14:36 +0000 (16:14 +1000)
Both watch and free used the locale to determine the required delay
interval for subsequent updates. It's preferable to not care about
locale and accept both 12.34 and 12,34 as meaning 12 seconds and
340 microseconds.

References:
 https://bugs.debian.org/692113

Signed-off-by: Craig Small <csmall@enc.com.au>
NEWS
free.1
free.c
watch.c

diff --git a/NEWS b/NEWS
index c160a4a7d9a2bf76dc0cf44b73b23cf3a693ef98..f97ef37a5b5429558b9741588d7f7d99a89d74af 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ procps-ng-NEXT
   * kill: report error if cannot kill process Debian #733172
   * watch: Add hostname to header
   * library: Find tty quicker Debian #770215
+  * watch,free: use locale-independent float Debian #692113
 
 procps-ng-3.3.11
 ----------------
diff --git a/free.1 b/free.1
index 0cbab5d1467789ae2dd505705c762278b6ebb9cf..ca669231c60b969c3ece2863cedb9d30e6b43984 100644 (file)
--- a/free.1
+++ b/free.1
@@ -2,7 +2,7 @@
 .\"  This page Copyright (C) 1993 Matt Welsh, mdw@sunsite.unc.edu.
 .\"  Long options where added at April 15th, 2011.
 .\"  Freely distributable under the terms of the GPL
-.TH FREE 1 "Jul 2016" "procps-ng" "User Commands"
+.TH FREE 1 "2016-06-03" "procps-ng" "User Commands"
 .SH NAME
 free \- Display amount of free and used memory in the system
 .SH SYNOPSIS
@@ -110,11 +110,10 @@ option.
 \fB\-l\fR, \fB\-\-lohi\fR
 Show detailed low and high memory statistics.
 .TP
-\fB\-s\fR, \fB\-\-seconds\fR \fIseconds\fR
-Continuously display the result delay
-.I seconds
+\fB\-s\fR, \fB\-\-seconds\fR \fIdelay\fR
+Continuously display the result \fIdelay\fR  seconds
 apart.  You may actually specify any floating point number for
-.IR delay ,
+\fIdelay\fR using either . or , for decimal point.
 .BR usleep (3)
 is used for microsecond resolution delay times.
 .TP
diff --git a/free.c b/free.c
index f86ab95153becbe5ee478d7f60de3f1d365d9243..3db0b59eb14a63da87addf7d8866d7ff78f94b03 100644 (file)
--- a/free.c
+++ b/free.c
@@ -324,9 +324,7 @@ int main(int argc, char **argv)
                case 's':
                        flags |= FREE_REPEAT;
                        errno = 0;
-                       args.repeat_interval = (1000000 * strtof(optarg, &endptr));
-                       if (errno || optarg == endptr || (endptr && *endptr))
-                               xerrx(EXIT_FAILURE, _("seconds argument `%s' failed"), optarg);
+            args.repeat_interval = (1000000 * strtod_nol_or_err(optarg, "seconds argument failed"));
                        if (args.repeat_interval < 1)
                                xerrx(EXIT_FAILURE,
                                     _("seconds argument `%s' is not positive number"), optarg);
diff --git a/watch.c b/watch.c
index c87eeb520d12183af21273debb64c2f07b674bb1..c510bed602910da3852cfb3dbbfe993fa89f968e 100644 (file)
--- a/watch.c
+++ b/watch.c
@@ -724,7 +724,7 @@ int main(int argc, char *argv[])
                        flags |= WATCH_EXEC;
                        break;
                case 'n':
-                       interval = strtod_or_err(optarg, _("failed to parse argument"));
+                       interval = strtod_nol_or_err(optarg, _("failed to parse argument"));
                        if (interval < 0.1)
                                interval = 0.1;
                        if (interval > UINT_MAX)