From 9702a7901e18460e8ffc5f56a493d41294a8e936 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Thu, 23 Dec 2021 15:01:07 +0100 Subject: stdio: Implement %#m for vfprintf and related functions %#m prints errno as an error constant if one is available, or a decimal number as a fallback. This intends to address the gap that strerrorname_np does not work well with printf for unknown error codes due to its NULL return values in those cases. Reviewed-by: Adhemerval Zanella --- manual/stdio.texi | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'manual') diff --git a/manual/stdio.texi b/manual/stdio.texi index 29d01b9ec9..1fac8e5f78 100644 --- a/manual/stdio.texi +++ b/manual/stdio.texi @@ -1949,6 +1949,9 @@ which can be parsed by the @code{strtoul} function (@pxref{Parsing of Integers}) and @code{scanf} with the @samp{%i} conversion (@pxref{Numeric Input Conversions}). +For the @samp{%m} conversion, print an error constant or decimal error +number, instead of a (possibly translated) error message. + @item @samp{'} Separate the digits into groups as specified by the locale specified for the @code{LC_NUMERIC} category; @pxref{General Numeric}. This flag is a @@ -2271,8 +2274,9 @@ is equivalent to: fprintf (stderr, "can't open `%s': %s\n", filename, strerror (errno)); @end smallexample -@noindent -The @samp{%m} conversion is a @glibcadj{} extension. +The @samp{%m} conversion can be used with the @samp{#} flag to print an +error constant, as provided by @code{strerrorname_np}. Both @samp{%m} +and @samp{%#m} are @glibcadj{} extensions. The @samp{%p} conversion prints a pointer value. The corresponding argument must be of type @code{void *}. In practice, you can use any -- cgit v1.2.3-70-g09d2