mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-06 08:51:14 -03:00
Remove wgeopter_t::wopterr
wopterr was a feature to allow wgetopt to emit error messages; but we do not use this and never will. Remove its support. No functional change expected here.
This commit is contained in:
@@ -205,10 +205,6 @@ int wgetopter_t::_handle_short_opt(int argc, string_array_t argv) {
|
|||||||
if (*nextchar == '\0') ++woptind;
|
if (*nextchar == '\0') ++woptind;
|
||||||
|
|
||||||
if (temp == nullptr || c == ':') {
|
if (temp == nullptr || c == ':') {
|
||||||
if (wopterr) {
|
|
||||||
std::fwprintf(stderr, _(L"%ls: Invalid option -- %lc\n"), argv[0],
|
|
||||||
static_cast<wint_t>(c));
|
|
||||||
}
|
|
||||||
woptopt = c;
|
woptopt = c;
|
||||||
|
|
||||||
if (*nextchar != '\0') woptind++;
|
if (*nextchar != '\0') woptind++;
|
||||||
@@ -236,11 +232,6 @@ int wgetopter_t::_handle_short_opt(int argc, string_array_t argv) {
|
|||||||
// the next element now.
|
// the next element now.
|
||||||
woptind++;
|
woptind++;
|
||||||
} else if (woptind == argc) {
|
} else if (woptind == argc) {
|
||||||
if (wopterr) {
|
|
||||||
// 1003.2 specifies the format of this message.
|
|
||||||
std::fwprintf(stderr, _(L"%ls: Option requires an argument -- %lc\n"), argv[0],
|
|
||||||
static_cast<wint_t>(c));
|
|
||||||
}
|
|
||||||
woptopt = c;
|
woptopt = c;
|
||||||
c = missing_arg_return_colon ? ':' : '?';
|
c = missing_arg_return_colon ? ':' : '?';
|
||||||
} else {
|
} else {
|
||||||
@@ -264,15 +255,6 @@ void wgetopter_t::_update_long_opt(int argc, string_array_t argv, const struct w
|
|||||||
if (pfound->has_arg)
|
if (pfound->has_arg)
|
||||||
woptarg = nameend + 1;
|
woptarg = nameend + 1;
|
||||||
else {
|
else {
|
||||||
if (wopterr) {
|
|
||||||
if (argv[woptind - 1][1] == '-') // --option
|
|
||||||
std::fwprintf(stderr, _(L"%ls: Option '--%ls' doesn't allow an argument\n"),
|
|
||||||
argv[0], pfound->name);
|
|
||||||
else
|
|
||||||
// +option or -option
|
|
||||||
std::fwprintf(stderr, _(L"%ls: Option '%lc%ls' doesn't allow an argument\n"),
|
|
||||||
argv[0], argv[woptind - 1][0], pfound->name);
|
|
||||||
}
|
|
||||||
nextchar += std::wcslen(nextchar);
|
nextchar += std::wcslen(nextchar);
|
||||||
*retval = '?';
|
*retval = '?';
|
||||||
return;
|
return;
|
||||||
@@ -281,9 +263,6 @@ void wgetopter_t::_update_long_opt(int argc, string_array_t argv, const struct w
|
|||||||
if (woptind < argc)
|
if (woptind < argc)
|
||||||
woptarg = argv[woptind++];
|
woptarg = argv[woptind++];
|
||||||
else {
|
else {
|
||||||
if (wopterr)
|
|
||||||
std::fwprintf(stderr, _(L"%ls: Option '%ls' requires an argument\n"), argv[0],
|
|
||||||
argv[woptind - 1]);
|
|
||||||
nextchar += std::wcslen(nextchar);
|
nextchar += std::wcslen(nextchar);
|
||||||
*retval = missing_arg_return_colon ? ':' : '?';
|
*retval = missing_arg_return_colon ? ':' : '?';
|
||||||
return;
|
return;
|
||||||
@@ -340,9 +319,6 @@ bool wgetopter_t::_handle_long_opt(int argc, string_array_t argv, const struct w
|
|||||||
_find_matching_long_opt(longopts, nameend, &exact, &ambig, &indfound);
|
_find_matching_long_opt(longopts, nameend, &exact, &ambig, &indfound);
|
||||||
|
|
||||||
if (ambig && !exact) {
|
if (ambig && !exact) {
|
||||||
if (wopterr) {
|
|
||||||
std::fwprintf(stderr, _(L"%ls: Option '%ls' is ambiguous\n"), argv[0], argv[woptind]);
|
|
||||||
}
|
|
||||||
nextchar += std::wcslen(nextchar);
|
nextchar += std::wcslen(nextchar);
|
||||||
woptind++;
|
woptind++;
|
||||||
*retval = '?';
|
*retval = '?';
|
||||||
@@ -358,14 +334,6 @@ bool wgetopter_t::_handle_long_opt(int argc, string_array_t argv, const struct w
|
|||||||
// with '--' or is not a valid short option, then it's an error. Otherwise interpret it as a
|
// with '--' or is not a valid short option, then it's an error. Otherwise interpret it as a
|
||||||
// short option.
|
// short option.
|
||||||
if (!long_only || argv[woptind][1] == '-' || std::wcschr(shortopts, *nextchar) == nullptr) {
|
if (!long_only || argv[woptind][1] == '-' || std::wcschr(shortopts, *nextchar) == nullptr) {
|
||||||
if (wopterr) {
|
|
||||||
if (argv[woptind][1] == '-') // --option
|
|
||||||
std::fwprintf(stderr, _(L"%ls: Unrecognized option '--%ls'\n"), argv[0], nextchar);
|
|
||||||
else
|
|
||||||
// +option or -option
|
|
||||||
std::fwprintf(stderr, _(L"%ls: Unrecognized option '%lc%ls'\n"), argv[0],
|
|
||||||
argv[woptind][0], nextchar);
|
|
||||||
}
|
|
||||||
nextchar = const_cast<wchar_t *>(L"");
|
nextchar = const_cast<wchar_t *>(L"");
|
||||||
woptind++;
|
woptind++;
|
||||||
*retval = '?';
|
*retval = '?';
|
||||||
@@ -391,8 +359,7 @@ bool wgetopter_t::_handle_long_opt(int argc, string_array_t argv, const struct w
|
|||||||
// that those that are not options now come last.)
|
// that those that are not options now come last.)
|
||||||
//
|
//
|
||||||
// OPTSTRING is a string containing the legitimate option characters. If an option character is seen
|
// OPTSTRING is a string containing the legitimate option characters. If an option character is seen
|
||||||
// that is not listed in OPTSTRING, return '?' after printing an error message. If you set
|
// that is not listed in OPTSTRING, return '?'.
|
||||||
// `wopterr' to zero, the error message is suppressed but we still return '?'.
|
|
||||||
//
|
//
|
||||||
// If a char in OPTSTRING is followed by a colon, that means it wants an arg, so the following text
|
// If a char in OPTSTRING is followed by a colon, that means it wants an arg, so the following text
|
||||||
// in the same ARGV-element, or the text of the following ARGV-element, is returned in `optarg'.
|
// in the same ARGV-element, or the text of the following ARGV-element, is returned in `optarg'.
|
||||||
|
|||||||
@@ -76,9 +76,6 @@ class wgetopter_t {
|
|||||||
// XXX 1003.2 says this must be 1 before any call.
|
// XXX 1003.2 says this must be 1 before any call.
|
||||||
int woptind = 0;
|
int woptind = 0;
|
||||||
|
|
||||||
// Callers store zero here to inhibit the error message for unrecognized options.
|
|
||||||
int wopterr = 0;
|
|
||||||
|
|
||||||
// Set to an option character which was unrecognized. This must be initialized on some systems
|
// Set to an option character which was unrecognized. This must be initialized on some systems
|
||||||
// to avoid linking in the system's own getopt implementation.
|
// to avoid linking in the system's own getopt implementation.
|
||||||
int woptopt = '?';
|
int woptopt = '?';
|
||||||
|
|||||||
Reference in New Issue
Block a user