From beafda1869e0f80d6adc55377c5d6e0427110087 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Mon, 13 Jun 2022 12:01:51 +0200 Subject: [PATCH] include/c: add print_version_with_features() Signed-off-by: Karel Zak --- include/c.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/include/c.h b/include/c.h index db0c58b509..bb6c436cd1 100644 --- a/include/c.h +++ b/include/c.h @@ -438,6 +438,27 @@ static inline int xusleep(useconds_t usec) exit(eval); \ }) +static inline void print_features(const char **features) +{ + if (features && *features) { + const char **p = features; + while (p && *p) { + fputs(p == features ? " (" : ", ", stdout); + fputs(*p++, stdout); + } + fputc(')', stdout); + } +} + +#define UTIL_LINUX_VERSION_NOBREAK _("%s from %s"), program_invocation_short_name, PACKAGE_STRING + +#define print_version_with_features(eval, features) __extension__ ({ \ + printf(UTIL_LINUX_VERSION_NOBREAK); \ + print_features(features); \ + fputc('\n', stdout); \ + exit(eval); \ +}) + /* * seek stuff */ -- 2.47.2