From: Pádraig Brady
Date: Fri, 16 Jan 2026 12:36:36 +0000 (+0000) Subject: doc: support highlighting printf formatted options X-Git-Tag: v9.10~66 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=507252c6f2fd0d7a672552c874b7e5ce98188667;p=thirdparty%2Fcoreutils.git doc: support highlighting printf formatted options * src/system.h (oprintf): Add a printf wrapper that calls oputs_() to markup the formatted text. --- diff --git a/src/system.h b/src/system.h index 46eb4e2ea4..d3677f6750 100644 --- a/src/system.h +++ b/src/system.h @@ -543,6 +543,7 @@ is_nul (void const *buf, size_t length) formatted with ANSI format and hyperlink codes. Any postprocessors like help2man etc. are expected to handle this, though it can be disabled in edge cases with the HELP_NO_MARKUP env var. */ + #define oputs(option) oputs_ (PROGRAM_NAME, option) static inline void oputs_ (MAYBE_UNUSED char const* program, char const *option) @@ -611,6 +612,34 @@ oputs_ (MAYBE_UNUSED char const* program, char const *option) fputs (desc_text, stdout); } +/* If required and possible, + call oputs with printf formatted message. */ + +#define oprintf(...) oprintf_ (PROGRAM_NAME, __VA_ARGS__) +ATTRIBUTE_FORMAT ((printf, 2, 3)) +static inline void +oprintf_ (char const* program, char const *message, ...) +{ + va_list args; + char *buf; + int buflen = -1; + +#if defined MANUAL_URL || defined BOLD_MAN_REFS + va_start (args, message); + buflen = vasprintf (&buf, message, args); + va_end (args); +#endif + + if (buflen < 0) + { + vprintf (message, args); + return; + } + + oputs_ (program, buf); + free (buf); +} + static inline void emit_stdin_note (void) {