mvsw61xx: track and set per-VLAN port state in STU
[openwrt/openwrt.git] / toolchain / musl / patches / 120-getopt_non-option-arguments_fix.patch
1 --- a/src/misc/getopt.c
2 +++ b/src/misc/getopt.c
3 @@ -24,8 +24,23 @@ int getopt(int argc, char * const argv[]
4 optind = 1;
5 }
6
7 - if (optind >= argc || !argv[optind] || argv[optind][0] != '-' || !argv[optind][1])
8 + if (optind >= argc || !argv[optind])
9 return -1;
10 +
11 + if (argv[optind][0] != '-') {
12 + /* GNU extension */
13 + if (optstring[0] == '-') {
14 + optarg = argv[optind];
15 + optind++;
16 + return 1;
17 + }
18 +
19 + return -1;
20 + }
21 +
22 + if (!argv[optind][1])
23 + return -1;
24 +
25 if (argv[optind][1] == '-' && !argv[optind][2])
26 return optind++, -1;
27
28 --- a/src/misc/getopt_long.c
29 +++ b/src/misc/getopt_long.c
30 @@ -12,7 +12,12 @@ static int __getopt_long(int argc, char
31 __optpos = 0;
32 optind = 1;
33 }
34 - if (optind >= argc || !argv[optind] || argv[optind][0] != '-') return -1;
35 + if (optind >= argc || !argv[optind])
36 + return -1;
37 +
38 + if (argv[optind][0] != '-')
39 + return getopt(argc, argv, optstring);
40 +
41 if ((longonly && argv[optind][1]) ||
42 (argv[optind][1] == '-' && argv[optind][2]))
43 {