Skip to content

Commit 8bedd71

Browse files
committed
Simplify musl's getopt, including removing optind, optopt, opterr, idx, and longonly
1 parent efb5a88 commit 8bedd71

File tree

3 files changed

+131
-174
lines changed

3 files changed

+131
-174
lines changed

include/extern/getopt.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ static constexpr int optional_argument = 2;
1212
// clang-format on
1313

1414
extern char *musl_optarg;
15-
extern int musl_optind, musl_opterr, musl_optopt, musl_optreset;
15+
extern int musl_optind, musl_optopt;
1616

1717
struct option {
1818
char const *name;
@@ -21,8 +21,6 @@ struct option {
2121
int val;
2222
};
2323

24-
int musl_getopt_long_only(
25-
int argc, char **argv, char const *optstring, option const *longopts, int *idx
26-
);
24+
int musl_getopt_long_only(int argc, char **argv, char const *optstring, option const *longopts);
2725

2826
#endif // RGBDS_EXTERN_GETOPT_HPP

src/cli.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ void cli_ParseArgs(
9494
for (;;) {
9595
char *atFileName = nullptr;
9696
for (int ch;
97-
(ch = musl_getopt_long_only(curArgc, curArgv, optString.c_str(), longOpts, nullptr))
98-
!= -1;) {
97+
(ch = musl_getopt_long_only(curArgc, curArgv, optString.c_str(), longOpts)) != -1;) {
9998
if (ch == 1 && musl_optarg[0] == '@') {
10099
atFileName = &musl_optarg[1];
101100
break;

0 commit comments

Comments
 (0)