mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 21:44:16 +00:00
parent
75e9c863f6
commit
cbae738882
4 changed files with 25 additions and 17 deletions
|
@ -468,7 +468,7 @@ static int builtin_bind(parser_t &parser, io_streams_t &streams, wchar_t **argv)
|
||||||
|
|
||||||
int opt;
|
int opt;
|
||||||
wgetopter_t w;
|
wgetopter_t w;
|
||||||
while ((opt = w.wgetopt_long_only(argc, argv, short_options, long_options, NULL)) != -1) {
|
while ((opt = w.wgetopt_long(argc, argv, short_options, long_options, NULL)) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case L'a': {
|
case L'a': {
|
||||||
all = true;
|
all = true;
|
||||||
|
@ -520,7 +520,7 @@ static int builtin_bind(parser_t &parser, io_streams_t &streams, wchar_t **argv)
|
||||||
return STATUS_INVALID_ARGS;
|
return STATUS_INVALID_ARGS;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
DIE("unexpected retval from wgetopt_long_only");
|
DIE("unexpected retval from wgetopt_long");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,7 @@ static int string_escape(parser_t &parser, io_streams_t &streams, int argc, wcha
|
||||||
|
|
||||||
int opt;
|
int opt;
|
||||||
wgetopter_t w;
|
wgetopter_t w;
|
||||||
while ((opt = w.wgetopt_long_only(argc, argv, short_options, long_options, NULL)) != -1) {
|
while ((opt = w.wgetopt_long(argc, argv, short_options, long_options, NULL)) != -1) {
|
||||||
switch (opt) { //!OCLINT(too few branches)
|
switch (opt) { //!OCLINT(too few branches)
|
||||||
case 'n': {
|
case 'n': {
|
||||||
flags |= ESCAPE_NO_QUOTED;
|
flags |= ESCAPE_NO_QUOTED;
|
||||||
|
@ -113,7 +113,7 @@ static int string_escape(parser_t &parser, io_streams_t &streams, int argc, wcha
|
||||||
return STATUS_INVALID_ARGS;
|
return STATUS_INVALID_ARGS;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
DIE("unexpected retval from wgetopt_long_only");
|
DIE("unexpected retval from wgetopt_long");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ static int string_join(parser_t &parser, io_streams_t &streams, int argc, wchar_
|
||||||
|
|
||||||
int opt;
|
int opt;
|
||||||
wgetopter_t w;
|
wgetopter_t w;
|
||||||
while ((opt = w.wgetopt_long_only(argc, argv, short_options, long_options, NULL)) != -1) {
|
while ((opt = w.wgetopt_long(argc, argv, short_options, long_options, NULL)) != -1) {
|
||||||
switch (opt) { //!OCLINT(too few branches)
|
switch (opt) { //!OCLINT(too few branches)
|
||||||
case L'q': {
|
case L'q': {
|
||||||
quiet = true;
|
quiet = true;
|
||||||
|
@ -157,7 +157,7 @@ static int string_join(parser_t &parser, io_streams_t &streams, int argc, wchar_
|
||||||
return STATUS_INVALID_ARGS;
|
return STATUS_INVALID_ARGS;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
DIE("unexpected retval from wgetopt_long_only");
|
DIE("unexpected retval from wgetopt_long");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -203,7 +203,7 @@ static int string_length(parser_t &parser, io_streams_t &streams, int argc, wcha
|
||||||
|
|
||||||
int opt;
|
int opt;
|
||||||
wgetopter_t w;
|
wgetopter_t w;
|
||||||
while ((opt = w.wgetopt_long_only(argc, argv, short_options, long_options, NULL)) != -1) {
|
while ((opt = w.wgetopt_long(argc, argv, short_options, long_options, NULL)) != -1) {
|
||||||
switch (opt) { //!OCLINT(too few branches)
|
switch (opt) { //!OCLINT(too few branches)
|
||||||
case L'q': {
|
case L'q': {
|
||||||
quiet = true;
|
quiet = true;
|
||||||
|
@ -214,7 +214,7 @@ static int string_length(parser_t &parser, io_streams_t &streams, int argc, wcha
|
||||||
return STATUS_INVALID_ARGS;
|
return STATUS_INVALID_ARGS;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
DIE("unexpected retval from wgetopt_long_only");
|
DIE("unexpected retval from wgetopt_long");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -861,7 +861,7 @@ static int string_split(parser_t &parser, io_streams_t &streams, int argc, wchar
|
||||||
|
|
||||||
int opt;
|
int opt;
|
||||||
wgetopter_t w;
|
wgetopter_t w;
|
||||||
while ((opt = w.wgetopt_long_only(argc, argv, short_options, long_options, NULL)) != -1) {
|
while ((opt = w.wgetopt_long(argc, argv, short_options, long_options, NULL)) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'm': {
|
case 'm': {
|
||||||
max = fish_wcstol(w.woptarg);
|
max = fish_wcstol(w.woptarg);
|
||||||
|
@ -888,7 +888,7 @@ static int string_split(parser_t &parser, io_streams_t &streams, int argc, wchar
|
||||||
return STATUS_INVALID_ARGS;
|
return STATUS_INVALID_ARGS;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
DIE("unexpected retval from wgetopt_long_only");
|
DIE("unexpected retval from wgetopt_long");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1023,7 +1023,7 @@ static int string_repeat(parser_t &parser, io_streams_t &streams, int argc, wcha
|
||||||
return STATUS_INVALID_ARGS;
|
return STATUS_INVALID_ARGS;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
DIE("unexpected retval from wgetopt_long_only");
|
DIE("unexpected retval from wgetopt_long");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1068,7 +1068,7 @@ static int string_sub(parser_t &parser, io_streams_t &streams, int argc, wchar_t
|
||||||
|
|
||||||
int opt;
|
int opt;
|
||||||
wgetopter_t w;
|
wgetopter_t w;
|
||||||
while ((opt = w.wgetopt_long_only(argc, argv, short_options, long_options, NULL)) != -1) {
|
while ((opt = w.wgetopt_long(argc, argv, short_options, long_options, NULL)) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'l': {
|
case 'l': {
|
||||||
length = fish_wcstol(w.woptarg);
|
length = fish_wcstol(w.woptarg);
|
||||||
|
@ -1107,7 +1107,7 @@ static int string_sub(parser_t &parser, io_streams_t &streams, int argc, wchar_t
|
||||||
return STATUS_INVALID_ARGS;
|
return STATUS_INVALID_ARGS;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
DIE("unexpected retval from wgetopt_long_only");
|
DIE("unexpected retval from wgetopt_long");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1167,7 +1167,7 @@ static int string_trim(parser_t &parser, io_streams_t &streams, int argc, wchar_
|
||||||
|
|
||||||
int opt;
|
int opt;
|
||||||
wgetopter_t w;
|
wgetopter_t w;
|
||||||
while ((opt = w.wgetopt_long_only(argc, argv, short_options, long_options, NULL)) != -1) {
|
while ((opt = w.wgetopt_long(argc, argv, short_options, long_options, NULL)) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'c': {
|
case 'c': {
|
||||||
chars_to_trim = w.woptarg;
|
chars_to_trim = w.woptarg;
|
||||||
|
@ -1194,7 +1194,7 @@ static int string_trim(parser_t &parser, io_streams_t &streams, int argc, wchar_
|
||||||
return STATUS_INVALID_ARGS;
|
return STATUS_INVALID_ARGS;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
DIE("unexpected retval from wgetopt_long_only");
|
DIE("unexpected retval from wgetopt_long");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -444,7 +444,11 @@ int wgetopter_t::wgetopt_long(int argc, wchar_t **argv, const wchar_t *options,
|
||||||
return _wgetopt_internal(argc, argv, options, long_options, opt_index, 0);
|
return _wgetopt_internal(argc, argv, options, long_options, opt_index, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#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 wgetopter_t::wgetopt_long_only(int argc, wchar_t **argv, const wchar_t *options,
|
int wgetopter_t::wgetopt_long_only(int argc, wchar_t **argv, const wchar_t *options,
|
||||||
const struct woption *long_options, int *opt_index) {
|
const struct woption *long_options, int *opt_index) {
|
||||||
return _wgetopt_internal(argc, argv, options, long_options, opt_index, 1);
|
return _wgetopt_internal(argc, argv, options, long_options, opt_index, 1);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
|
@ -123,13 +123,17 @@ class wgetopter_t {
|
||||||
ordering(),
|
ordering(),
|
||||||
first_nonopt(0),
|
first_nonopt(0),
|
||||||
last_nonopt(0) {}
|
last_nonopt(0) {}
|
||||||
|
|
||||||
int wgetopt_long(int argc, wchar_t **argv, const wchar_t *options,
|
int wgetopt_long(int argc, wchar_t **argv, const wchar_t *options,
|
||||||
const struct woption *long_options, int *opt_index);
|
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,
|
int wgetopt_long_only(int argc, wchar_t **argv, const wchar_t *options,
|
||||||
const struct woption *long_options, int *opt_index);
|
const struct woption *long_options, int *opt_index);
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// Describe the long-named options requested by the application. The LONG_OPTIONS argument to
|
/// Describe the long-named options requested by the application. The LONG_OPTIONS argument to
|
||||||
/// getopt_long or getopt_long_only is a vector of `struct option' terminated by an element
|
/// getopt_long or getopt_long_only is a vector of `struct option' terminated by an element
|
||||||
/// containing a name which is zero.
|
/// containing a name which is zero.
|
||||||
|
|
Loading…
Reference in a new issue