From b0afb8fe0ff1d87165af9df61501197a06240dda Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Sun, 28 Dec 2025 12:13:40 +0100 Subject: Sync with Gnulib stable-202507 code (a8ac9f9ce5) --- gl/printf-args.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'gl/printf-args.c') diff --git a/gl/printf-args.c b/gl/printf-args.c index eb0d2cdc..b83ec1e8 100644 --- a/gl/printf-args.c +++ b/gl/printf-args.c @@ -1,5 +1,5 @@ /* Decomposed printf argument list. - Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2024 Free Software + Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2025 Free Software Foundation, Inc. This file is free software: you can redistribute it and/or modify @@ -32,6 +32,9 @@ /* Get INT_WIDTH. */ #include +/* Get abort(). */ +#include + #ifdef STATIC STATIC #endif @@ -198,7 +201,6 @@ PRINTF_FETCHARGS (va_list args, arguments *a) if (ap->a.a_string == NULL) ap->a.a_string = "(NULL)"; break; -#if HAVE_WCHAR_T case TYPE_WIDE_STRING: ap->a.a_wide_string = va_arg (args, const wchar_t *); /* A null pointer is an invalid argument for "%ls", but in practice @@ -216,7 +218,6 @@ PRINTF_FETCHARGS (va_list args, arguments *a) ap->a.a_wide_string = wide_null_string; } break; -#endif case TYPE_POINTER: ap->a.a_pointer = va_arg (args, void *); break; @@ -298,9 +299,19 @@ PRINTF_FETCHARGS (va_list args, arguments *a) } break; #endif - default: - /* Unknown type. */ + case TYPE_NONE: + /* Argument i is not used by any directive, but some argument with + number > i is used by a format directive. POSIX says that this + is invalid: + "When numbered argument specifications are used, specifying the + Nth argument requires that all the leading arguments, from the + first to the (N-1)th, are specified in the format string." + The reason is that we cannot know how many bytes to skip in the + va_arg sequence. */ return -1; + default: + /* Unknown type. Should not happen. */ + abort (); } return 0; } -- cgit v1.2.3-74-g34f1