1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-29 11:41:21 +03:00

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  <adhemerval.zanella@linaro.org>
This commit is contained in:
Florian Weimer
2021-12-23 15:01:07 +01:00
parent cd0c333d2e
commit 9702a7901e
5 changed files with 125 additions and 8 deletions

View File

@ -950,11 +950,26 @@ static const uint8_t jump_table[] =
\
LABEL (form_strerror): \
/* Print description of error ERRNO. */ \
string = \
(CHAR_T *) __strerror_r (save_errno, (char *) work_buffer, \
WORK_BUFFER_SIZE * sizeof (CHAR_T)); \
is_long = 0; /* This is no wide-char string. */ \
goto LABEL (print_string)
if (alt) \
string = (CHAR_T *) __get_errname (save_errno); \
else \
string = (CHAR_T *) __strerror_r (save_errno, (char *) work_buffer, \
WORK_BUFFER_SIZE * sizeof (CHAR_T));\
if (string == NULL) \
{ \
/* Print as a decimal number. */ \
base = 10; \
is_negative = save_errno < 0; \
number.word = save_errno; \
if (is_negative) \
number.word = -number.word; \
goto LABEL (number); \
} \
else \
{ \
is_long = 0; /* This is no wide-char string. */ \
goto LABEL (print_string); \
}
#ifdef COMPILE_WPRINTF
# define process_string_arg() \