From 1c9a6bde7e12e1978e8e47764913a91b7407e9b5 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Thu, 5 Dec 2019 13:57:11 -0500 Subject: [PATCH 1/1] Remove bt_/BT_ prefixes throughout Since this is not longer part of Babeltrace, remove the bt_/BT_ prefixes. This was done mechanically using: sed -i -e 's/BT_ARGPAR/ARGPAR/g' -e 's/bt_argpar/argpar/g' Hopefully there isn't too much collateral damage. Signed-off-by: Simon Marchi --- argpar/argpar.c | 78 +++++++++---------- argpar/argpar.h | 58 +++++++------- tests/test_argpar.c | 180 ++++++++++++++++++++++---------------------- 3 files changed, 158 insertions(+), 158 deletions(-) diff --git a/argpar/argpar.c b/argpar/argpar.c index c31b181..8cc20cd 100644 --- a/argpar/argpar.c +++ b/argpar/argpar.c @@ -114,14 +114,14 @@ end: } static -void destroy_item(struct bt_argpar_item * const item) +void destroy_item(struct argpar_item * const item) { if (!item) { goto end; } - if (item->type == BT_ARGPAR_ITEM_TYPE_OPT) { - struct bt_argpar_item_opt * const opt_item = (void *) item; + if (item->type == ARGPAR_ITEM_TYPE_OPT) { + struct argpar_item_opt * const opt_item = (void *) item; free((void *) opt_item->arg); } @@ -133,8 +133,8 @@ end: } static -bool push_item(struct bt_argpar_item_array * const array, - struct bt_argpar_item * const item) +bool push_item(struct argpar_item_array * const array, + struct argpar_item * const item) { bool success; @@ -143,10 +143,10 @@ bool push_item(struct bt_argpar_item_array * const array, if (array->n_items == array->n_alloc) { unsigned int new_n_alloc = array->n_alloc * 2; - struct bt_argpar_item **new_items; + struct argpar_item **new_items; new_items = argpar_realloc(array->items, - struct bt_argpar_item *, new_n_alloc); + struct argpar_item *, new_n_alloc); if (!new_items) { success = false; goto end; @@ -166,7 +166,7 @@ end: } static -void destroy_item_array(struct bt_argpar_item_array * const array) +void destroy_item_array(struct argpar_item_array * const array) { if (array) { unsigned int i; @@ -181,17 +181,17 @@ void destroy_item_array(struct bt_argpar_item_array * const array) } static -struct bt_argpar_item_array *new_item_array(void) +struct argpar_item_array *new_item_array(void) { - struct bt_argpar_item_array *ret; + struct argpar_item_array *ret; const int initial_size = 10; - ret = argpar_zalloc(struct bt_argpar_item_array); + ret = argpar_zalloc(struct argpar_item_array); if (!ret) { goto end; } - ret->items = argpar_calloc(struct bt_argpar_item *, initial_size); + ret->items = argpar_calloc(struct argpar_item *, initial_size); if (!ret->items) { goto error; } @@ -209,18 +209,18 @@ end: } static -struct bt_argpar_item_opt *create_opt_item( - const struct bt_argpar_opt_descr * const descr, +struct argpar_item_opt *create_opt_item( + const struct argpar_opt_descr * const descr, const char * const arg) { - struct bt_argpar_item_opt *opt_item = - argpar_zalloc(struct bt_argpar_item_opt); + struct argpar_item_opt *opt_item = + argpar_zalloc(struct argpar_item_opt); if (!opt_item) { goto end; } - opt_item->base.type = BT_ARGPAR_ITEM_TYPE_OPT; + opt_item->base.type = ARGPAR_ITEM_TYPE_OPT; opt_item->descr = descr; if (arg) { @@ -241,18 +241,18 @@ end: } static -struct bt_argpar_item_non_opt *create_non_opt_item(const char * const arg, +struct argpar_item_non_opt *create_non_opt_item(const char * const arg, const unsigned int orig_index, const unsigned int non_opt_index) { - struct bt_argpar_item_non_opt * const non_opt_item = - argpar_zalloc(struct bt_argpar_item_non_opt); + struct argpar_item_non_opt * const non_opt_item = + argpar_zalloc(struct argpar_item_non_opt); if (!non_opt_item) { goto end; } - non_opt_item->base.type = BT_ARGPAR_ITEM_TYPE_NON_OPT; + non_opt_item->base.type = ARGPAR_ITEM_TYPE_NON_OPT; non_opt_item->arg = arg; non_opt_item->orig_index = orig_index; non_opt_item->non_opt_index = non_opt_index; @@ -262,11 +262,11 @@ end: } static -const struct bt_argpar_opt_descr *find_descr( - const struct bt_argpar_opt_descr * const descrs, +const struct argpar_opt_descr *find_descr( + const struct argpar_opt_descr * const descrs, const char short_name, const char * const long_name) { - const struct bt_argpar_opt_descr *descr; + const struct argpar_opt_descr *descr; for (descr = descrs; descr->short_name || descr->long_name; descr++) { if (short_name && descr->short_name && @@ -293,8 +293,8 @@ enum parse_orig_arg_opt_ret { static enum parse_orig_arg_opt_ret parse_short_opts(const char * const short_opts, const char * const next_orig_arg, - const struct bt_argpar_opt_descr * const descrs, - struct bt_argpar_parse_ret * const parse_ret, + const struct argpar_opt_descr * const descrs, + struct argpar_parse_ret * const parse_ret, bool * const used_next_orig_arg) { enum parse_orig_arg_opt_ret ret = PARSE_ORIG_ARG_OPT_RET_OK; @@ -307,8 +307,8 @@ enum parse_orig_arg_opt_ret parse_short_opts(const char * const short_opts, while (*short_opt_ch) { const char *opt_arg = NULL; - const struct bt_argpar_opt_descr *descr; - struct bt_argpar_item_opt *opt_item; + const struct argpar_opt_descr *descr; + struct argpar_item_opt *opt_item; /* Find corresponding option descriptor */ descr = find_descr(descrs, *short_opt_ch, NULL); @@ -376,14 +376,14 @@ end: static enum parse_orig_arg_opt_ret parse_long_opt(const char * const long_opt_arg, const char * const next_orig_arg, - const struct bt_argpar_opt_descr * const descrs, - struct bt_argpar_parse_ret * const parse_ret, + const struct argpar_opt_descr * const descrs, + struct argpar_parse_ret * const parse_ret, bool * const used_next_orig_arg) { const size_t max_len = 127; enum parse_orig_arg_opt_ret ret = PARSE_ORIG_ARG_OPT_RET_OK; - const struct bt_argpar_opt_descr *descr; - struct bt_argpar_item_opt *opt_item; + const struct argpar_opt_descr *descr; + struct argpar_item_opt *opt_item; /* Option's argument, if any */ const char *opt_arg = NULL; @@ -472,8 +472,8 @@ end: static enum parse_orig_arg_opt_ret parse_orig_arg_opt(const char * const orig_arg, const char * const next_orig_arg, - const struct bt_argpar_opt_descr * const descrs, - struct bt_argpar_parse_ret * const parse_ret, + const struct argpar_opt_descr * const descrs, + struct argpar_parse_ret * const parse_ret, bool * const used_next_orig_arg) { enum parse_orig_arg_opt_ret ret = PARSE_ORIG_ARG_OPT_RET_OK; @@ -521,12 +521,12 @@ end: } ARGPAR_HIDDEN -struct bt_argpar_parse_ret bt_argpar_parse(unsigned int argc, +struct argpar_parse_ret argpar_parse(unsigned int argc, const char * const *argv, - const struct bt_argpar_opt_descr * const descrs, + const struct argpar_opt_descr * const descrs, bool fail_on_unknown_opt) { - struct bt_argpar_parse_ret parse_ret = { 0 }; + struct argpar_parse_ret parse_ret = { 0 }; unsigned int i; unsigned int non_opt_index = 0; @@ -544,7 +544,7 @@ struct bt_argpar_parse_ret bt_argpar_parse(unsigned int argc, if (orig_arg[0] != '-') { /* Non-option argument */ - struct bt_argpar_item_non_opt *non_opt_item = + struct argpar_item_non_opt *non_opt_item = create_non_opt_item(orig_arg, i, non_opt_index); if (!non_opt_item) { @@ -612,7 +612,7 @@ end: } ARGPAR_HIDDEN -void bt_argpar_parse_ret_fini(struct bt_argpar_parse_ret *ret) +void argpar_parse_ret_fini(struct argpar_parse_ret *ret) { ARGPAR_ASSERT(ret); diff --git a/argpar/argpar.h b/argpar/argpar.h index dffbe6e..7a50f45 100644 --- a/argpar/argpar.h +++ b/argpar/argpar.h @@ -26,7 +26,7 @@ #include /* Sentinel for an option descriptor array */ -#define BT_ARGPAR_OPT_DESCR_SENTINEL { -1, '\0', NULL, false } +#define ARGPAR_OPT_DESCR_SENTINEL { -1, '\0', NULL, false } /* * ARGPAR_HIDDEN: if argpar is used in some shared library, we don't want them @@ -42,7 +42,7 @@ #endif /* Option descriptor */ -struct bt_argpar_opt_descr { +struct argpar_opt_descr { /* Numeric ID for this option */ const int id; @@ -57,33 +57,33 @@ struct bt_argpar_opt_descr { }; /* Item type */ -enum bt_argpar_item_type { +enum argpar_item_type { /* Option */ - BT_ARGPAR_ITEM_TYPE_OPT, + ARGPAR_ITEM_TYPE_OPT, /* Non-option */ - BT_ARGPAR_ITEM_TYPE_NON_OPT, + ARGPAR_ITEM_TYPE_NON_OPT, }; /* Base item */ -struct bt_argpar_item { - enum bt_argpar_item_type type; +struct argpar_item { + enum argpar_item_type type; }; /* Option item */ -struct bt_argpar_item_opt { - struct bt_argpar_item base; +struct argpar_item_opt { + struct argpar_item base; /* Corresponding descriptor */ - const struct bt_argpar_opt_descr *descr; + const struct argpar_opt_descr *descr; /* Argument, or `NULL` if none */ const char *arg; }; /* Non-option item */ -struct bt_argpar_item_non_opt { - struct bt_argpar_item base; +struct argpar_item_non_opt { + struct argpar_item base; /* * Complete argument, pointing to one of the entries of the @@ -98,9 +98,9 @@ struct bt_argpar_item_non_opt { unsigned int non_opt_index; }; -struct bt_argpar_item_array { - /* Array of `struct bt_argpar_item *`, or `NULL` on error */ - struct bt_argpar_item **items; +struct argpar_item_array { + /* Array of `struct argpar_item *`, or `NULL` on error */ + struct argpar_item **items; /* Number of used slots in `items`. */ unsigned int n_items; @@ -109,10 +109,10 @@ struct bt_argpar_item_array { unsigned int n_alloc; }; -/* What is returned by bt_argpar_parse() */ -struct bt_argpar_parse_ret { - /* Array of `struct bt_argpar_item *`, or `NULL` on error */ - struct bt_argpar_item_array *items; +/* What is returned by argpar_parse() */ +struct argpar_parse_ret { + /* Array of `struct argpar_item *`, or `NULL` on error */ + struct argpar_item_array *items; /* Error string, or `NULL` if none */ char *error; @@ -123,7 +123,7 @@ struct bt_argpar_parse_ret { /* * Parses the arguments `argv` of which the count is `argc` using the - * sentinel-terminated (use `BT_ARGPAR_OPT_DESCR_SENTINEL`) option + * sentinel-terminated (use `ARGPAR_OPT_DESCR_SENTINEL`) option * descriptor array `descrs`. * * This function considers ALL the elements of `argv`, including the @@ -163,9 +163,9 @@ struct bt_argpar_parse_ret { * contains one entry for each instance). * * On success, this function returns an array of items - * (`struct bt_argpar_item *`). Each item is to be casted to the - * appropriate type (`struct bt_argpar_item_opt *` or - * `struct bt_argpar_item_non_opt *`) depending on its type. + * (`struct argpar_item *`). Each item is to be casted to the + * appropriate type (`struct argpar_item_opt *` or + * `struct argpar_item_non_opt *`) depending on its type. * * The returned array contains the items in the same order that the * arguments were parsed, including non-option arguments. This means, @@ -213,21 +213,21 @@ struct bt_argpar_parse_ret { * the `error` string member contains details about the error. * * You can finalize the returned structure with - * bt_argpar_parse_ret_fini(). + * argpar_parse_ret_fini(). */ ARGPAR_HIDDEN -struct bt_argpar_parse_ret bt_argpar_parse(unsigned int argc, +struct argpar_parse_ret argpar_parse(unsigned int argc, const char * const *argv, - const struct bt_argpar_opt_descr *descrs, + const struct argpar_opt_descr *descrs, bool fail_on_unknown_opt); /* - * Finalizes what is returned by bt_argpar_parse(). + * Finalizes what is returned by argpar_parse(). * - * It is safe to call bt_argpar_parse() multiple times with the same + * It is safe to call argpar_parse() multiple times with the same * structure. */ ARGPAR_HIDDEN -void bt_argpar_parse_ret_fini(struct bt_argpar_parse_ret *ret); +void argpar_parse_ret_fini(struct argpar_parse_ret *ret); #endif /* BABELTRACE_ARGPAR_H */ diff --git a/tests/test_argpar.c b/tests/test_argpar.c index 4674d89..458c69e 100644 --- a/tests/test_argpar.c +++ b/tests/test_argpar.c @@ -39,24 +39,24 @@ static void test_succeed(const char *cmdline, const char *expected_cmd_line, - const struct bt_argpar_opt_descr *descrs, + const struct argpar_opt_descr *descrs, unsigned int expected_ingested_orig_args) { - struct bt_argpar_parse_ret parse_ret; + struct argpar_parse_ret parse_ret; GString *res_str = g_string_new(NULL); gchar **argv = g_strsplit(cmdline, " ", 0); unsigned int i; assert(argv); assert(res_str); - parse_ret = bt_argpar_parse(g_strv_length(argv), + parse_ret = argpar_parse(g_strv_length(argv), (const char * const *) argv, descrs, false); ok(parse_ret.items, - "bt_argpar_parse() succeeds for command line `%s`", cmdline); + "argpar_parse() succeeds for command line `%s`", cmdline); ok(!parse_ret.error, - "bt_argpar_parse() does not write an error for command line `%s`", cmdline); + "argpar_parse() does not write an error for command line `%s`", cmdline); ok(parse_ret.ingested_orig_args == expected_ingested_orig_args, - "bt_argpar_parse() returns the correct number of ingested " + "argpar_parse() returns the correct number of ingested " "original arguments for command line `%s`", cmdline); if (parse_ret.ingested_orig_args != expected_ingested_orig_args) { diag("Expected: %u Got: %u", expected_ingested_orig_args, @@ -64,18 +64,18 @@ void test_succeed(const char *cmdline, } if (!parse_ret.items) { - fail("bt_argpar_parse() returns the expected parsed arguments " + fail("argpar_parse() returns the expected parsed arguments " "for command line `%s`", cmdline); goto end; } for (i = 0; i < parse_ret.items->n_items; i++) { - const struct bt_argpar_item *arg = parse_ret.items->items[i]; + const struct argpar_item *arg = parse_ret.items->items[i]; switch (arg->type) { - case BT_ARGPAR_ITEM_TYPE_OPT: + case ARGPAR_ITEM_TYPE_OPT: { - const struct bt_argpar_item_opt *arg_opt = + const struct argpar_item_opt *arg_opt = (const void *) arg; if (arg_opt->descr->long_name) { @@ -102,9 +102,9 @@ void test_succeed(const char *cmdline, break; } - case BT_ARGPAR_ITEM_TYPE_NON_OPT: + case ARGPAR_ITEM_TYPE_NON_OPT: { - const struct bt_argpar_item_non_opt *arg_non_opt = + const struct argpar_item_non_opt *arg_non_opt = (const void *) arg; g_string_append_printf(res_str, "%s<%u,%u> ", @@ -122,7 +122,7 @@ void test_succeed(const char *cmdline, } ok(strcmp(expected_cmd_line, res_str->str) == 0, - "bt_argpar_parse() returns the expected parsed arguments " + "argpar_parse() returns the expected parsed arguments " "for command line `%s`", cmdline); if (strcmp(expected_cmd_line, res_str->str) != 0) { diag("Expected: `%s`", expected_cmd_line); @@ -130,7 +130,7 @@ void test_succeed(const char *cmdline, } end: - bt_argpar_parse_ret_fini(&parse_ret); + argpar_parse_ret_fini(&parse_ret); g_string_free(res_str, TRUE); g_strfreev(argv); } @@ -140,8 +140,8 @@ void succeed_tests(void) { /* No arguments */ { - const struct bt_argpar_opt_descr descrs[] = { - BT_ARGPAR_OPT_DESCR_SENTINEL + const struct argpar_opt_descr descrs[] = { + ARGPAR_OPT_DESCR_SENTINEL }; test_succeed( @@ -152,9 +152,9 @@ void succeed_tests(void) /* Single long option */ { - const struct bt_argpar_opt_descr descrs[] = { + const struct argpar_opt_descr descrs[] = { { 0, '\0', "salut", false }, - BT_ARGPAR_OPT_DESCR_SENTINEL + ARGPAR_OPT_DESCR_SENTINEL }; test_succeed( @@ -165,9 +165,9 @@ void succeed_tests(void) /* Single short option */ { - const struct bt_argpar_opt_descr descrs[] = { + const struct argpar_opt_descr descrs[] = { { 0, 'f', NULL, false }, - BT_ARGPAR_OPT_DESCR_SENTINEL + ARGPAR_OPT_DESCR_SENTINEL }; test_succeed( @@ -178,9 +178,9 @@ void succeed_tests(void) /* Short and long option (aliases) */ { - const struct bt_argpar_opt_descr descrs[] = { + const struct argpar_opt_descr descrs[] = { { 0, 'f', "flaw", false }, - BT_ARGPAR_OPT_DESCR_SENTINEL + ARGPAR_OPT_DESCR_SENTINEL }; test_succeed( @@ -191,9 +191,9 @@ void succeed_tests(void) /* Long option with argument (space form) */ { - const struct bt_argpar_opt_descr descrs[] = { + const struct argpar_opt_descr descrs[] = { { 0, '\0', "tooth", true }, - BT_ARGPAR_OPT_DESCR_SENTINEL + ARGPAR_OPT_DESCR_SENTINEL }; test_succeed( @@ -204,9 +204,9 @@ void succeed_tests(void) /* Long option with argument (equal form) */ { - const struct bt_argpar_opt_descr descrs[] = { + const struct argpar_opt_descr descrs[] = { { 0, '\0', "polish", true }, - BT_ARGPAR_OPT_DESCR_SENTINEL + ARGPAR_OPT_DESCR_SENTINEL }; test_succeed( @@ -217,9 +217,9 @@ void succeed_tests(void) /* Short option with argument (space form) */ { - const struct bt_argpar_opt_descr descrs[] = { + const struct argpar_opt_descr descrs[] = { { 0, 'c', NULL, true }, - BT_ARGPAR_OPT_DESCR_SENTINEL + ARGPAR_OPT_DESCR_SENTINEL }; test_succeed( @@ -230,9 +230,9 @@ void succeed_tests(void) /* Short option with argument (glued form) */ { - const struct bt_argpar_opt_descr descrs[] = { + const struct argpar_opt_descr descrs[] = { { 0, 'c', NULL, true }, - BT_ARGPAR_OPT_DESCR_SENTINEL + ARGPAR_OPT_DESCR_SENTINEL }; test_succeed( @@ -243,9 +243,9 @@ void succeed_tests(void) /* Short and long option (aliases) with argument (all forms) */ { - const struct bt_argpar_opt_descr descrs[] = { + const struct argpar_opt_descr descrs[] = { { 0, 'd', "dry", true }, - BT_ARGPAR_OPT_DESCR_SENTINEL + ARGPAR_OPT_DESCR_SENTINEL }; test_succeed( @@ -256,11 +256,11 @@ void succeed_tests(void) /* Many short options, last one with argument (glued form) */ { - const struct bt_argpar_opt_descr descrs[] = { + const struct argpar_opt_descr descrs[] = { { 0, 'd', NULL, false }, { 0, 'e', NULL, false }, { 0, 'f', NULL, true }, - BT_ARGPAR_OPT_DESCR_SENTINEL + ARGPAR_OPT_DESCR_SENTINEL }; test_succeed( @@ -271,11 +271,11 @@ void succeed_tests(void) /* Many options */ { - const struct bt_argpar_opt_descr descrs[] = { + const struct argpar_opt_descr descrs[] = { { 0, 'd', NULL, false }, { 0, 'e', "east", true }, { 0, '\0', "mind", false }, - BT_ARGPAR_OPT_DESCR_SENTINEL + ARGPAR_OPT_DESCR_SENTINEL }; test_succeed( @@ -286,8 +286,8 @@ void succeed_tests(void) /* Single non-option argument */ { - const struct bt_argpar_opt_descr descrs[] = { - BT_ARGPAR_OPT_DESCR_SENTINEL + const struct argpar_opt_descr descrs[] = { + ARGPAR_OPT_DESCR_SENTINEL }; test_succeed( @@ -298,8 +298,8 @@ void succeed_tests(void) /* Two non-option arguments */ { - const struct bt_argpar_opt_descr descrs[] = { - BT_ARGPAR_OPT_DESCR_SENTINEL + const struct argpar_opt_descr descrs[] = { + ARGPAR_OPT_DESCR_SENTINEL }; test_succeed( @@ -310,10 +310,10 @@ void succeed_tests(void) /* Single non-option argument mixed with options */ { - const struct bt_argpar_opt_descr descrs[] = { + const struct argpar_opt_descr descrs[] = { { 0, 'd', NULL, false }, { 0, '\0', "squeeze", true }, - BT_ARGPAR_OPT_DESCR_SENTINEL + ARGPAR_OPT_DESCR_SENTINEL }; test_succeed( @@ -324,9 +324,9 @@ void succeed_tests(void) /* Unknown short option (space form) */ { - const struct bt_argpar_opt_descr descrs[] = { + const struct argpar_opt_descr descrs[] = { { 0, 'd', NULL, true }, - BT_ARGPAR_OPT_DESCR_SENTINEL + ARGPAR_OPT_DESCR_SENTINEL }; test_succeed( @@ -337,9 +337,9 @@ void succeed_tests(void) /* Unknown short option (glued form) */ { - const struct bt_argpar_opt_descr descrs[] = { + const struct argpar_opt_descr descrs[] = { { 0, 'd', NULL, true }, - BT_ARGPAR_OPT_DESCR_SENTINEL + ARGPAR_OPT_DESCR_SENTINEL }; test_succeed( @@ -350,9 +350,9 @@ void succeed_tests(void) /* Unknown long option (space form) */ { - const struct bt_argpar_opt_descr descrs[] = { + const struct argpar_opt_descr descrs[] = { { 0, '\0', "sink", true }, - BT_ARGPAR_OPT_DESCR_SENTINEL + ARGPAR_OPT_DESCR_SENTINEL }; test_succeed( @@ -363,9 +363,9 @@ void succeed_tests(void) /* Unknown long option (equal form) */ { - const struct bt_argpar_opt_descr descrs[] = { + const struct argpar_opt_descr descrs[] = { { 0, '\0', "sink", true }, - BT_ARGPAR_OPT_DESCR_SENTINEL + ARGPAR_OPT_DESCR_SENTINEL }; test_succeed( @@ -376,9 +376,9 @@ void succeed_tests(void) /* Unknown option before non-option argument */ { - const struct bt_argpar_opt_descr descrs[] = { + const struct argpar_opt_descr descrs[] = { { 0, '\0', "thumb", true }, - BT_ARGPAR_OPT_DESCR_SENTINEL + ARGPAR_OPT_DESCR_SENTINEL }; test_succeed( @@ -389,9 +389,9 @@ void succeed_tests(void) /* Unknown option after non-option argument */ { - const struct bt_argpar_opt_descr descrs[] = { + const struct argpar_opt_descr descrs[] = { { 0, '\0', "thumb", true }, - BT_ARGPAR_OPT_DESCR_SENTINEL + ARGPAR_OPT_DESCR_SENTINEL }; test_succeed( @@ -402,9 +402,9 @@ void succeed_tests(void) /* Valid `---opt` */ { - const struct bt_argpar_opt_descr descrs[] = { + const struct argpar_opt_descr descrs[] = { { 0, '\0', "-fuel", true }, - BT_ARGPAR_OPT_DESCR_SENTINEL + ARGPAR_OPT_DESCR_SENTINEL }; test_succeed( @@ -415,9 +415,9 @@ void succeed_tests(void) /* Long option containing `=` in argument (equal form) */ { - const struct bt_argpar_opt_descr descrs[] = { + const struct argpar_opt_descr descrs[] = { { 0, '\0', "zebra", true }, - BT_ARGPAR_OPT_DESCR_SENTINEL + ARGPAR_OPT_DESCR_SENTINEL }; test_succeed( @@ -428,9 +428,9 @@ void succeed_tests(void) /* Short option's argument starting with `-` (glued form) */ { - const struct bt_argpar_opt_descr descrs[] = { + const struct argpar_opt_descr descrs[] = { { 0, 'z', NULL, true }, - BT_ARGPAR_OPT_DESCR_SENTINEL + ARGPAR_OPT_DESCR_SENTINEL }; test_succeed( @@ -441,9 +441,9 @@ void succeed_tests(void) /* Short option's argument starting with `-` (space form) */ { - const struct bt_argpar_opt_descr descrs[] = { + const struct argpar_opt_descr descrs[] = { { 0, 'z', NULL, true }, - BT_ARGPAR_OPT_DESCR_SENTINEL + ARGPAR_OPT_DESCR_SENTINEL }; test_succeed( @@ -454,9 +454,9 @@ void succeed_tests(void) /* Long option's argument starting with `-` (space form) */ { - const struct bt_argpar_opt_descr descrs[] = { + const struct argpar_opt_descr descrs[] = { { 0, '\0', "janine", true }, - BT_ARGPAR_OPT_DESCR_SENTINEL + ARGPAR_OPT_DESCR_SENTINEL }; test_succeed( @@ -467,9 +467,9 @@ void succeed_tests(void) /* Long option's argument starting with `-` (equal form) */ { - const struct bt_argpar_opt_descr descrs[] = { + const struct argpar_opt_descr descrs[] = { { 0, '\0', "janine", true }, - BT_ARGPAR_OPT_DESCR_SENTINEL + ARGPAR_OPT_DESCR_SENTINEL }; test_succeed( @@ -480,10 +480,10 @@ void succeed_tests(void) /* Long option's empty argument (equal form) */ { - const struct bt_argpar_opt_descr descrs[] = { + const struct argpar_opt_descr descrs[] = { { 0, 'f', NULL, false }, { 0, '\0', "yeah", true }, - BT_ARGPAR_OPT_DESCR_SENTINEL + ARGPAR_OPT_DESCR_SENTINEL }; test_succeed( @@ -500,25 +500,25 @@ void succeed_tests(void) */ static void test_fail(const char *cmdline, const char *expected_error, - const struct bt_argpar_opt_descr *descrs) + const struct argpar_opt_descr *descrs) { - struct bt_argpar_parse_ret parse_ret; + struct argpar_parse_ret parse_ret; gchar **argv = g_strsplit(cmdline, " ", 0); - parse_ret = bt_argpar_parse(g_strv_length(argv), + parse_ret = argpar_parse(g_strv_length(argv), (const char * const *) argv, descrs, true); ok(!parse_ret.items, - "bt_argpar_parse() fails for command line `%s`", cmdline); + "argpar_parse() fails for command line `%s`", cmdline); ok(parse_ret.error, - "bt_argpar_parse() writes an error string for command line `%s`", + "argpar_parse() writes an error string for command line `%s`", cmdline); if (parse_ret.items) { - fail("bt_argpar_parse() writes the expected error string"); + fail("argpar_parse() writes the expected error string"); goto end; } ok(strcmp(expected_error, parse_ret.error) == 0, - "bt_argpar_parse() writes the expected error string " + "argpar_parse() writes the expected error string " "for command line `%s`", cmdline); if (strcmp(expected_error, parse_ret.error) != 0) { diag("Expected: `%s`", expected_error); @@ -526,7 +526,7 @@ void test_fail(const char *cmdline, const char *expected_error, } end: - bt_argpar_parse_ret_fini(&parse_ret); + argpar_parse_ret_fini(&parse_ret); g_strfreev(argv); } @@ -535,9 +535,9 @@ void fail_tests(void) { /* Unknown long option */ { - const struct bt_argpar_opt_descr descrs[] = { + const struct argpar_opt_descr descrs[] = { { 0, '\0', "thumb", true }, - BT_ARGPAR_OPT_DESCR_SENTINEL + ARGPAR_OPT_DESCR_SENTINEL }; test_fail( @@ -548,9 +548,9 @@ void fail_tests(void) /* Unknown short option */ { - const struct bt_argpar_opt_descr descrs[] = { + const struct argpar_opt_descr descrs[] = { { 0, '\0', "thumb", true }, - BT_ARGPAR_OPT_DESCR_SENTINEL + ARGPAR_OPT_DESCR_SENTINEL }; test_fail( @@ -561,9 +561,9 @@ void fail_tests(void) /* Missing long option argument */ { - const struct bt_argpar_opt_descr descrs[] = { + const struct argpar_opt_descr descrs[] = { { 0, '\0', "thumb", true }, - BT_ARGPAR_OPT_DESCR_SENTINEL + ARGPAR_OPT_DESCR_SENTINEL }; test_fail( @@ -574,9 +574,9 @@ void fail_tests(void) /* Missing short option argument */ { - const struct bt_argpar_opt_descr descrs[] = { + const struct argpar_opt_descr descrs[] = { { 0, 'k', NULL, true }, - BT_ARGPAR_OPT_DESCR_SENTINEL + ARGPAR_OPT_DESCR_SENTINEL }; test_fail( @@ -587,11 +587,11 @@ void fail_tests(void) /* Missing short option argument (multiple glued) */ { - const struct bt_argpar_opt_descr descrs[] = { + const struct argpar_opt_descr descrs[] = { { 0, 'a', NULL, false }, { 0, 'b', NULL, false }, { 0, 'c', NULL, true }, - BT_ARGPAR_OPT_DESCR_SENTINEL + ARGPAR_OPT_DESCR_SENTINEL }; test_fail( @@ -602,11 +602,11 @@ void fail_tests(void) /* Invalid `-` */ { - const struct bt_argpar_opt_descr descrs[] = { + const struct argpar_opt_descr descrs[] = { { 0, 'a', NULL, false }, { 0, 'b', NULL, false }, { 0, 'c', NULL, true }, - BT_ARGPAR_OPT_DESCR_SENTINEL + ARGPAR_OPT_DESCR_SENTINEL }; test_fail( @@ -617,11 +617,11 @@ void fail_tests(void) /* Invalid `--` */ { - const struct bt_argpar_opt_descr descrs[] = { + const struct argpar_opt_descr descrs[] = { { 0, 'a', NULL, false }, { 0, 'b', NULL, false }, { 0, 'c', NULL, true }, - BT_ARGPAR_OPT_DESCR_SENTINEL + ARGPAR_OPT_DESCR_SENTINEL }; test_fail( -- 2.34.1