top: tweak argument parsing for some locale situations

Boy I hate locale stuff. For code I thought was pretty
robust, Jaromir sure proved that it wasn't. Anyway, me
thinks this commit closes some gaps and will cause top
to behave appropriately under various locale settings.

It does *not* permit top to respond to the ',' and '.'
floating point separator without regard to the locale.
It does, however, enforce proper LC_NUMERIC responses.

Let's look on this commit as an interim solution until
Jaromir can create that proposed 'fp_decode' function.
Who knows, he might even borrow some of our mkfloat().

[ An aside: the coreutils sleep and timeout programs ]
[ claim to permit floating point arguments. However, ]
[ neither one will accept the comma separator should ]
[ the locale be a country that in fact uses a comma. ]

[ In other words, with this commit we are way ahead! ]

Reference(s):
http://www.freelists.org/post/procps/topwatch-floating-point-input
http://www.freelists.org/post/procps/topwatch-floating-point-input,1

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner
2014-06-25 00:00:00 -05:00
committed by Jaromir Capik
parent cec1976511
commit f7b84f45c7
3 changed files with 36 additions and 17 deletions

View File

@@ -312,7 +312,7 @@ static void build_norm_nlstab (void) {
Norm_nlstab[LIMIT_exceed_fmt] = _("pid limit (%d) exceeded");
Norm_nlstab[BAD_mon_pids_fmt] = _("bad pid '%s'");
Norm_nlstab[MISSING_args_fmt] = _("-%c requires argument");
Norm_nlstab[BAD_widtharg_fmt] = _("bad width arg '%s', must > %d");
Norm_nlstab[BAD_widtharg_fmt] = _("bad width arg '%s'");
Norm_nlstab[UNKNOWN_opts_fmt] = _(""
"unknown option '%c'\n"
"Usage:\n %s%s");