From nobody Sat Nov 14 15:16:22 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jRd4k6r1Qz71DQk for ; Sat, 14 Nov 2026 15:16:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jRd4k5cXJz4SFR for ; Sat, 14 Nov 2026 15:16:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794669382; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=b907LHjBxOdLj8IFVdsKVhu9roLLXG72DbptNSVMuHw=; b=IbONanMwg7mjxw7aE/sRhQ2jGM2o8WVoKojFH2OxOeYrqjrQka8sKs8fzIE4FoaNtsN4pq 4NhPZWTH/VNVI5XFcywJC5DDjrspG899I2zVNxZSCoBdPS+j/i9YGmLWRwHFsXxnEqlDOl wvhEmPn9yP+83KlLQ57HH+8UWFdCyySg7sUGxP1Kpjjcn6GLSk19xxjDHhnkzAEWh/gzHl VfMAZjpTqV1zQxSyiCt7gpCYaAFdWolqczXOD73W4Ax+9KASXYxoCTfOh8r1A2y/l+xRUP TaYCrMY1Q3jh50zl/CeUOP2R1ED8QHzLJCuzF1bL8QcvEHKmOejS/oCCrmGzvA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794669382; b=lyCuFhDdt/ukMF0Wp9GgR+27Qus8hi9dZWe29Ll4IjJRGFxz0ZxeqGPBDeM7TEgZCCwXFf Ma2ZkSpkXpS5/BkHnx1zhLfAe2j5EcuhTENTr1L1Dj0UAeBdqyUuzk/5jX5vyHZoz02/+I +IewXOXIgLd9WwwgY3HwT4p6Rj6ibKpWemqJ5Kb1ppBFtXqGr1xSfApOIeC8xh5YkbO/1n pu/SXz9zSn74oKYVi8IHC9bD18e72NLgZrM8zCwVXbi/3dXRz0d22oBTqNClcsVAfl9TMA UI/GpCoOfbO/mZPGZzACm/0bOo3hmpPAJ8dOKVgfXYwgdvmfz9mq/tUkyCILPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794669382; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=b907LHjBxOdLj8IFVdsKVhu9roLLXG72DbptNSVMuHw=; b=SBj9nKHXPviVD1xCVt5pRGNaRmFFETjBGdcFrg0A/ybz5GlDWkjRoLajbL/S0PgPU2F+P5 SavK24gRpvUUnZ4SK+GV2oQBHI5JSTTeMloQnC1GYbKtpp6JkZT9DVEP8IbppgTodsu86I fE7qwEcvHFf4KxV7+gUyihpd+vQsLhKunazpqwV3US2qmgOfWar4msQk78jAxyOjw5G35a RBcuOA0QW4PZFrLwBZTQZq9q40TcoqQX8nxWqhxH5552n1fXUVFMcIn442L9bD885ZbO+x JblqsyaN9I+wNnenLQ42saWSN7YyBlz1eRrN9UJMNoYqFSgMYIpjZy9UNz3VEQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jRd4k51cTzQ24 for ; Sat, 14 Nov 2026 15:16:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id f160 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 14 Nov 2026 15:16:22 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Showta Ishizaki From: Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav Subject: git: eb647dd28137 - main - stdio: Fix positional %F conversion List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: eb647dd28137c5f44030645a648e5a8c24e16f4f Auto-Submitted: auto-generated Date: Sat, 14 Nov 2026 15:16:22 +0000 Message-Id: <6af87b46.f160.27bad5c1@gitrepo.freebsd.org> The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=eb647dd28137c5f44030645a648e5a8c24e16f4f commit eb647dd28137c5f44030645a648e5a8c24e16f4f Author: Showta Ishizaki AuthorDate: 2026-09-28 21:55:42 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2026-11-14 14:51:37 +0000 stdio: Fix positional %F conversion When a format uses positional arguments, __find_arguments() walks it first to learn the type of every argument, and lists the floating point conversions as A a E e f G g. F is missing, so a double that is only referred to through %F never gets a type, its slot in the argument table stays unset, and the conversion reads whatever is there: printf("[%1$F]\n", -INFINITY); [0.000000] printf("[%1$F]\n", 1.5); [0.000000] printf("[%F]\n", 1.5); [1.500000] With a width taken from another argument, "%1$*2$F", vsnprintf(3) returned lengths like 2103024 for a ten character result; abseil's str_format test allocates that much and was killed for it on FreeBSD. The same format with %1$f, or with any other conversion of the same argument, works because those give it a type. Add F ahead of f in both __find_arguments() and __find_warguments(), and test %F, plain and positional, in snprintf_test and swprintf_test. MFC after: 1 week Signed-off-by: Showta Ishizaki Pull Request: https://github.com/freebsd/freebsd-src/pull/2420 --- lib/libc/stdio/printf-pos.c | 14 ++++++++------ lib/libc/tests/stdio/snprintf_test.c | 13 +++++++++++++ lib/libc/tests/stdio/swprintf_test.c | 13 +++++++++++++ 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/lib/libc/stdio/printf-pos.c b/lib/libc/stdio/printf-pos.c index 4fa99316321c..07b518c59214 100644 --- a/lib/libc/stdio/printf-pos.c +++ b/lib/libc/stdio/printf-pos.c @@ -357,13 +357,14 @@ reswitch: switch (ch) { if ((error = addsarg(&types, flags))) goto error; break; - case 'a': case 'A': - case 'e': + case 'a': case 'E': + case 'e': + case 'F': case 'f': - case 'g': case 'G': + case 'g': error = addtype(&types, (flags & LONGDBL) ? T_LONG_DOUBLE : T_DOUBLE); if (error) @@ -546,13 +547,14 @@ reswitch: switch (ch) { if ((error = addsarg(&types, flags))) goto error; break; - case 'a': case 'A': - case 'e': + case 'a': case 'E': + case 'e': + case 'F': case 'f': - case 'g': case 'G': + case 'g': error = addtype(&types, (flags & LONGDBL) ? T_LONG_DOUBLE : T_DOUBLE); if (error) diff --git a/lib/libc/tests/stdio/snprintf_test.c b/lib/libc/tests/stdio/snprintf_test.c index 29b908b65120..c8f04b7e5524 100644 --- a/lib/libc/tests/stdio/snprintf_test.c +++ b/lib/libc/tests/stdio/snprintf_test.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -81,6 +82,17 @@ ATF_TC_BODY(snprintf_d, tc) SNPRINTF_TEST("2,147,483,647", "%'d", INT_MAX); } +ATF_TC_WITHOUT_HEAD(snprintf_F); +ATF_TC_BODY(snprintf_F, tc) +{ + SNPRINTF_TEST("1.500000", "%F", 1.5); + SNPRINTF_TEST("INF", "%F", INFINITY); + SNPRINTF_TEST("-INF", "%F", -INFINITY); + SNPRINTF_TEST("1.500000", "%1$F", 1.5); + SNPRINTF_TEST("-INF", "%1$F", -INFINITY); + SNPRINTF_TEST(" 1.500000", "%1$*2$F", 1.5, 10); +} + ATF_TC_WITHOUT_HEAD(snprintf_x); ATF_TC_BODY(snprintf_x, tc) { @@ -197,6 +209,7 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, snprintf_b); ATF_TP_ADD_TC(tp, snprintf_B); ATF_TP_ADD_TC(tp, snprintf_d); + ATF_TP_ADD_TC(tp, snprintf_F); ATF_TP_ADD_TC(tp, snprintf_x); ATF_TP_ADD_TC(tp, snprintf_X); ATF_TP_ADD_TC(tp, snprintf_wN); diff --git a/lib/libc/tests/stdio/swprintf_test.c b/lib/libc/tests/stdio/swprintf_test.c index f00ecc7f1c1d..fe2957928344 100644 --- a/lib/libc/tests/stdio/swprintf_test.c +++ b/lib/libc/tests/stdio/swprintf_test.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -82,6 +83,17 @@ ATF_TC_BODY(swprintf_d, tc) SWPRINTF_TEST("2,147,483,647", "%'d", INT_MAX); } +ATF_TC_WITHOUT_HEAD(swprintf_F); +ATF_TC_BODY(swprintf_F, tc) +{ + SWPRINTF_TEST("1.500000", "%F", 1.5); + SWPRINTF_TEST("INF", "%F", INFINITY); + SWPRINTF_TEST("-INF", "%F", -INFINITY); + SWPRINTF_TEST("1.500000", "%1$F", 1.5); + SWPRINTF_TEST("-INF", "%1$F", -INFINITY); + SWPRINTF_TEST(" 1.500000", "%1$*2$F", 1.5, 10); +} + ATF_TC_WITHOUT_HEAD(swprintf_x); ATF_TC_BODY(swprintf_x, tc) { @@ -198,6 +210,7 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, swprintf_b); ATF_TP_ADD_TC(tp, swprintf_B); ATF_TP_ADD_TC(tp, swprintf_d); + ATF_TP_ADD_TC(tp, swprintf_F); ATF_TP_ADD_TC(tp, swprintf_x); ATF_TP_ADD_TC(tp, swprintf_X); ATF_TP_ADD_TC(tp, swprintf_wN);