diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-09-28 15:17:09 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-09-28 15:17:09 -0400 |
| commit | 23af8b64a3f924f3eed3307735e1041b72f32c1f (patch) | |
| tree | c9bdd4ad4f9152e134afc4c0f1713425d4361d85 /stdlib | |
| parent | 566356d82ed97c274b7985cafdce6704520c8ff0 (diff) | |
Overhaul of argument parsing code
Diffstat (limited to 'stdlib')
| -rw-r--r-- | stdlib/stdlib.c | 2 | ||||
| -rw-r--r-- | stdlib/stdlib.h | 4 |
2 files changed, 4 insertions, 2 deletions
diff --git a/stdlib/stdlib.c b/stdlib/stdlib.c index 801283a7..7111a9fc 100644 --- a/stdlib/stdlib.c +++ b/stdlib/stdlib.c @@ -130,7 +130,7 @@ static Array_t parse_array(const TypeInfo *item_info, int n, char *args[]) } #pragma GCC diagnostic ignored "-Wstack-protector" -public void tomo_parse_args(Text_t usage, Text_t help, int spec_len, cli_arg_t spec[spec_len], int argc, char *argv[]) +public void _tomo_parse_args(int argc, char *argv[], Text_t usage, Text_t help, int spec_len, cli_arg_t spec[spec_len]) { bool populated_args[spec_len] = {}; bool used_args[argc] = {}; diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h index b8e78e9b..ea4f5d27 100644 --- a/stdlib/stdlib.h +++ b/stdlib/stdlib.h @@ -20,7 +20,9 @@ typedef struct { } cli_arg_t; void tomo_init(void); -void tomo_parse_args(Text_t usage, Text_t help, int spec_len, cli_arg_t spec[spec_len], int argc, char *argv[]); +void _tomo_parse_args(int argc, char *argv[], Text_t usage, Text_t help, int spec_len, cli_arg_t spec[spec_len]); +#define tomo_parse_args(argc, argv, usage, help, ...) \ + _tomo_parse_args(argc, argv, usage, help, sizeof((cli_arg_t[]){__VA_ARGS__})/sizeof(cli_arg_t), (cli_arg_t[]){__VA_ARGS__}) __attribute__((format(printf, 1, 2))) _Noreturn void fail(const char *fmt, ...); __attribute__((format(printf, 4, 5))) |
