Make return code in noarg case GNU-compatible

This commit is contained in:
Andrey A. Chernov 2004-03-03 08:29:00 +00:00
parent d92dc3946d
commit 8848539902
2 changed files with 24 additions and 20 deletions

View File

@ -311,26 +311,26 @@ This practice is wrong, and should not be used in any current development.
.\" to
.\" mean the preceding option takes an optional argument.
.\" .El
.It
Return value in case of missing argument if first character
(after
.Ql +
or
.Ql - )
in option string is not
.Ql \&: :
.Bl -tag -width ".Bx"
.It Tn GNU
returns
.Ql \&?
.It Bx
returns
.Ql \&:
(since
.Bx Ns 's
.Fn getopt
does).
.El
.\" .It
.\" Return value in case of missing argument if first character
.\" (after
.\" .Ql +
.\" or
.\" .Ql - )
.\" in option string is not
.\" .Ql \&: :
.\" .Bl -tag -width ".Bx"
.\" .It Tn GNU
.\" returns
.\" .Ql \&?
.\" .It Bx
.\" returns
.\" .Ql \&:
.\" (since
.\" .Bx Ns 's
.\" .Fn getopt
.\" does).
.\" .El
.\" .It
.\" Handling of
.\" .Ql --a

View File

@ -284,7 +284,11 @@ parse_long_options(char * const *nargv, const char *options,
optopt = long_options[match].val;
else
optopt = 0;
#ifdef GNU_COMPATIBLE
return (BADCH);
#else
return (BADARG);
#endif
}
if (long_options[match].has_arg == required_argument ||
long_options[match].has_arg == optional_argument) {