top: some minor tweaks supporting long cmdline options

This darn patch began as 1 correction to an extraneous
comma in the man document. Then, it grew to include an
adjustment for a couple of additional man page things.

After that, I figured I might as well tighten up logic
dealing with those awful gaps in the getopt_long code.

[ the error_exit mentioned in the associated comment ]
[ will only be taken when '=' ends the argv vectors! ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner
2021-09-08 00:00:00 -05:00
committed by Craig Small
parent 2d75b2eb96
commit 8c23dfdcd4
2 changed files with 9 additions and 6 deletions

View File

@@ -3829,8 +3829,10 @@ static void parse_args (int argc, char **argv) {
cp = argv[optind++];
if (cp) {
if (*cp == '=') ++cp;
if (*cp == '\0' && optind < argc) cp = argv[optind++];
if (!cp || *cp == '\0') error_exit(fmtmk(N_fmt(MISSING_args_fmt), ch));
/* here, if we're actually accessing argv[argc], we'll rely on
the required NULL delimiter which yields an error_exit next */
if (*cp == '\0') cp = argv[optind++];
if (!cp) error_exit(fmtmk(N_fmt(MISSING_args_fmt), ch));
}
#endif
switch (ch) {