top: correct functioning of the '-p' command line args

With the introduction of a new '1' command line toggle
I have gone and broken a provision of the '-p' command
line switch (pids monitoring). Multiple pids could not
be specified through the use of comma delimited lists.

Thus, this commit simply corrects that newly added bug
which was born in the 'adjustment' commit shown below.

Reference(s):
. adjustment to '-1' implementation
commit 909b37d755

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2017-05-22 12:00:00 -05:00 committed by Craig Small
parent 3fd84670b2
commit 4b44aebd80

View File

@ -3605,7 +3605,6 @@ static void parse_args (char **args) {
. bunched args are actually handled properly and none are ignored . bunched args are actually handled properly and none are ignored
. we tolerate NO whitespace and NO switches -- maybe too tolerant? */ . we tolerate NO whitespace and NO switches -- maybe too tolerant? */
static const char numbs_str[] = "+,-.0123456789"; static const char numbs_str[] = "+,-.0123456789";
static const char wrong_str[] = "+,-.";
float tmp_delay = FLT_MAX; float tmp_delay = FLT_MAX;
int i; int i;
@ -3622,7 +3621,7 @@ static void parse_args (char **args) {
case '-': case '-':
if (cp[1]) ++cp; if (cp[1]) ++cp;
else if (*args) cp = *args++; else if (*args) cp = *args++;
if (strspn(cp, wrong_str)) if (strspn(cp, "+,-."))
error_exit(fmtmk(N_fmt(WRONG_switch_fmt) error_exit(fmtmk(N_fmt(WRONG_switch_fmt)
, cp, Myname, N_txt(USAGE_abbrev_txt))); , cp, Myname, N_txt(USAGE_abbrev_txt)));
continue; continue;
@ -3704,7 +3703,7 @@ static void parse_args (char **args) {
if (Monpidsidx >= MONPIDMAX) if (Monpidsidx >= MONPIDMAX)
error_exit(fmtmk(N_fmt(LIMIT_exceed_fmt), MONPIDMAX)); error_exit(fmtmk(N_fmt(LIMIT_exceed_fmt), MONPIDMAX));
if (1 != sscanf(cp, "%d", &pid) if (1 != sscanf(cp, "%d", &pid)
|| strpbrk(cp, wrong_str)) || strpbrk(cp, "+-."))
error_exit(fmtmk(N_fmt(BAD_mon_pids_fmt), cp)); error_exit(fmtmk(N_fmt(BAD_mon_pids_fmt), cp));
if (!pid) pid = getpid(); if (!pid) pid = getpid();
for (i = 0; i < Monpidsidx; i++) for (i = 0; i < Monpidsidx; i++)