argpar: sync with upstream - adjust to iterator API
authorSimon Marchi <simon.marchi@efficios.com>
Fri, 20 Aug 2021 18:39:20 +0000 (14:39 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 17 Dec 2021 05:31:09 +0000 (00:31 -0500)
commitea76a8bbde6896bddfa656627e8f12e0b9f55a5e
tree02084bddb4f674b4a187194c0307aea559065ae9
parent5b770521bbf951df78c52ea4c2b7cf9e0dc1bd5e
argpar: sync with upstream - adjust to iterator API

Sync with commit 143cec42e14e ("Force usage of ARGPAR_ASSERT() condition
when NDEBUG is defined").

The main change in this sync is the API that changed from
parse-all-at-once (the `argpar_parse` function) to something based on an
iterator, where we need to call `argpar_iter_next` to obtain the next
item.  This was prototyped here (in lttng-tools), so this patch converts
the code to the API that was actually implemented in upstream argpar.

A difference between what we had and the current argpar API is that
argpar does not provide a formatted error string anymore.  It provides
an `argpar_error` object contaning all the raw information needed to
create such string.  The new `format_arg_error_v` function formats the
errors using the exact same syntax as argpar did, such that no changes
in the tests are necessary.

The new `parse_next_item` function factors out the code around calling
argpar_iter_next that would otherwise be duplicated at a few places.

These two new functions are placed into a new `argpar-utils` convenience
library.  I originally put them in the `libcommon.la` convenience
library, but that caused some parts of the code that don't do any
argument parsing (e.g. liblttng-ctl) to have to be linked against
argpar.  As a separate library, we can limit that to just the `lttng`
binary.

Change-Id: I94aa90ffcd93f52b6073c4cd7caca78cfd0f2e05
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
13 files changed:
configure.ac
src/bin/lttng/Makefile.am
src/bin/lttng/commands/add_trigger.c
src/bin/lttng/commands/list_triggers.c
src/bin/lttng/commands/remove_trigger.c
src/common/Makefile.am
src/common/argpar-utils/Makefile.am [new file with mode: 0644]
src/common/argpar-utils/argpar-utils.c [new file with mode: 0644]
src/common/argpar-utils/argpar-utils.h [new file with mode: 0644]
src/common/argpar/argpar.c
src/common/argpar/argpar.h
src/common/string-utils/string-utils.c
src/common/string-utils/string-utils.h
This page took 0.027897 seconds and 4 git commands to generate.