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>
Thu, 16 Dec 2021 00:10:16 +0000 (19:10 -0500)
commitd50d200af8d01f4b58a14e384cabd46b1afb4817
treecb48c43992962b0f453b1d921bc81af72dcfaf36
parent411b31544f22b773b4aad6cdb81faa81dc05e641
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>
15 files changed:
configure.ac
src/bin/lttng/Makefile.am
src/bin/lttng/commands/add_trigger.cpp
src/bin/lttng/commands/list_triggers.cpp
src/bin/lttng/commands/remove_trigger.cpp
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/error.h
src/common/macros.h
src/common/string-utils/string-utils.cpp
src/common/string-utils/string-utils.h
This page took 0.027827 seconds and 4 git commands to generate.