mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
Clean up bits of wgetopter_t interface
This commit is contained in:
parent
2cccc9b589
commit
9f436c3750
1 changed files with 12 additions and 28 deletions
|
@ -45,7 +45,7 @@ Cambridge, MA 02139, USA. */
|
|||
|
||||
class wgetopter_t {
|
||||
private:
|
||||
bool initialized;
|
||||
bool initialized = false;
|
||||
bool missing_arg_return_colon = false;
|
||||
|
||||
void exchange(wchar_t **argv);
|
||||
|
@ -65,9 +65,9 @@ class wgetopter_t {
|
|||
// For communication from `getopt' to the caller. When `getopt' finds an option that takes an
|
||||
// argument, the argument value is returned here. Also, when `ordering' is RETURN_IN_ORDER, each
|
||||
// non-option ARGV-element is returned here.
|
||||
wchar_t *woptarg;
|
||||
wchar_t *woptarg = nullptr;
|
||||
|
||||
const wchar_t *shortopts;
|
||||
const wchar_t *shortopts = nullptr;
|
||||
|
||||
// Index in ARGV of the next element to be scanned. This is used for communication to and from
|
||||
// the caller and for communication between successive calls to `getopt'.
|
||||
|
@ -81,21 +81,21 @@ class wgetopter_t {
|
|||
// so far.
|
||||
|
||||
// XXX 1003.2 says this must be 1 before any call.
|
||||
int woptind;
|
||||
int woptind = 0;
|
||||
|
||||
// The next char to be scanned in the option-element in which the last option character we
|
||||
// returned was found. This allows us to pick up the scan where we left off.
|
||||
//
|
||||
// If this is zero, or a null string, it means resume the scan by advancing to the next
|
||||
// ARGV-element.
|
||||
wchar_t *nextchar;
|
||||
wchar_t *nextchar = nullptr;
|
||||
|
||||
// Callers store zero here to inhibit the error message for unrecognized options.
|
||||
int wopterr;
|
||||
int wopterr = 0;
|
||||
|
||||
// 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.
|
||||
int woptopt;
|
||||
int woptopt = '?';
|
||||
|
||||
// Describe how to deal with options that follow non-option ARGV-elements.
|
||||
//
|
||||
|
@ -118,35 +118,19 @@ class wgetopter_t {
|
|||
// The special argument `--' forces an end of option-scanning regardless of the value of
|
||||
// `ordering'. In the case of RETURN_IN_ORDER, only `--' can cause `getopt' to return EOF with
|
||||
// `woptind' != ARGC.
|
||||
enum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } ordering;
|
||||
enum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } ordering = PERMUTE;
|
||||
|
||||
// Handle permutation of arguments.
|
||||
|
||||
// Describe the part of ARGV that contains non-options that have been skipped. `first_nonopt'
|
||||
// is the index in ARGV of the first of them; `last_nonopt' is the index after the last of them.
|
||||
int first_nonopt;
|
||||
int last_nonopt;
|
||||
int first_nonopt = 0;
|
||||
int last_nonopt = 0;
|
||||
|
||||
wgetopter_t() {}
|
||||
|
||||
wgetopter_t()
|
||||
: initialized(false),
|
||||
missing_arg_return_colon(false),
|
||||
woptarg(NULL),
|
||||
shortopts(NULL),
|
||||
woptind(0),
|
||||
nextchar(NULL),
|
||||
wopterr(0),
|
||||
woptopt('?'),
|
||||
ordering(),
|
||||
first_nonopt(0),
|
||||
last_nonopt(0) {}
|
||||
int wgetopt_long(int argc, wchar_t **argv, const wchar_t *options,
|
||||
const struct woption *long_options, int *opt_index);
|
||||
#if 0
|
||||
// This function should never be used by fish. We keep the signature just in case we find a
|
||||
// need to use it in the future.
|
||||
int wgetopt_long_only(int argc, wchar_t **argv, const wchar_t *options,
|
||||
const struct woption *long_options, int *opt_index);
|
||||
#endif
|
||||
};
|
||||
|
||||
/// Describe the long-named options requested by the application. The LONG_OPTIONS argument to
|
||||
|
|
Loading…
Reference in a new issue