From nobody Fri Nov 20 12:04:51 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 4jWDY02Hgpz71XGm for ; Fri, 20 Nov 2026 12:04:52 +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 4jWDY003bSz3QnN for ; Fri, 20 Nov 2026 12:04:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795176292; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=llwhKPSM3IMaIZ4YOwpHw2bjQIav/7h49Pi2vAaPaPc=; b=D1mUllEma/hETyQMLhNQQSNZJHTVLO4OqHN6K8e6PO+s9phjV24p64VVNhMN6b5qV+YziT I+141TeaZK5dB4Aaog+JLEQAbaN+o3GpAKFT4PWD88+GCmCf28G6679qfuTx4TAHHvB0XP YMYzOWRnV52xKsdWIef47hpBaGzYnji6gejj/fYkQF5l0s5oUFiXHuPP10O/rOJLR42ZeA X64bEMA0vMYE6P1g/i/jdpjka3QBjJ+ZTxKwHHHY4FtEuHgzgvDjfCFCpiZlN6Bi9xeoDa ej3OfiR80vn9eV8ZevLgovkXM2BjJb78wOX3HWcTlfQEIR/ot+ZyKgcMe9fpTQ== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1795176292; b=r5XiFx1xLBcNx3+bvNr9MW2W+16tvz/W2Qol+zhtnG+sZ/RZ7uWcqZlp7INJmgw+uTLQ4j 7+5YYPlri5JEIzl8kL8ivMJccio+zTg+HkXmUKvcBR8CAGnEGncNF9Dlj2sfsZGFHaM4R+ 9t9BwladthODKtzweXH0gEJFUiFu0xLmZHFnhdePxTEsfEbH5ENRpaHcsEhST4Pc3M9I4C 79ujJQ7waqchpVr1M4EXRnEYgQuA7pbFFBQyLz+ISzs8lHWa5mYa3seOp4e3es6lEKwb58 Bj8VcE5mLqv2a/NS2QssJeB2vz8mAz1GznEQyFvQ6QZ7ZTE5fOYywpCKQyqKig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795176292; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=llwhKPSM3IMaIZ4YOwpHw2bjQIav/7h49Pi2vAaPaPc=; b=Lc0HCecr5x6mAnbvfL0cEifiKSqxfj97x20KcIy5LkpUiOalrAjH7IByZSPKVW7VSUNWKh 5YeNTCwQbucWi08XR0GUnq/xvOJXhbc7qTObHqtjRJIMlW5vogRnyVna5m1ithsqHLz1DD +w5TSDvLCNRsyGteaHHQ3McSXdzObaNIimqUulYsLfFcChmn3mPB399RvOBc0ZTl3Srf2Q Y4i8Wz/fOn2JSum9SA/kQ4fEaVkRwa01Dnp+24AUoZ6g/xaTTJD4RerfuI2RMrRhd2lS0o X1nK6Lm47KQBSa1LFLOYzq3HRHnXJGsS0HwZ6btSP1NHQdS/2Xd3TVQaO6X3RA== 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 4jWDXz6qj7znkL for ; Fri, 20 Nov 2026 12:04:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 37f0 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 20 Nov 2026 12:04:51 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav Subject: git: 4e50611f53af - stable/14 - stdio: Fix positional %wN / %wfN 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/stable/14 X-Git-Reftype: branch X-Git-Commit: 4e50611f53afcd8cbd8d768ffb55079959e331af Auto-Submitted: auto-generated Date: Fri, 20 Nov 2026 12:04:51 +0000 Message-Id: <6b003763.37f0.4e98999a@gitrepo.freebsd.org> The branch stable/14 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=4e50611f53afcd8cbd8d768ffb55079959e331af commit 4e50611f53afcd8cbd8d768ffb55079959e331af Author: Dag-Erling Smørgrav AuthorDate: 2026-11-15 16:37:42 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2026-11-20 12:04:06 +0000 stdio: Fix positional %wN / %wfN conversion MFC after: 1 week Fixes: bce0bef3c6ab ("libc: Implement N2680.") Fixes: 12b1c1e3fb44 ("libc: Add test cases for N2680.") (cherry picked from commit 5e809bf1c93fdc4c52fa46a7eb0e6f881b6c6140) --- lib/libc/stdio/printf-pos.c | 68 ++++++++++++++++++++++++++++++++++++ lib/libc/tests/stdio/snprintf_test.c | 8 +++++ lib/libc/tests/stdio/swprintf_test.c | 8 +++++ 3 files changed, 84 insertions(+) diff --git a/lib/libc/stdio/printf-pos.c b/lib/libc/stdio/printf-pos.c index 722d267c6481..47fd30578e32 100644 --- a/lib/libc/stdio/printf-pos.c +++ b/lib/libc/stdio/printf-pos.c @@ -342,6 +342,40 @@ reswitch: switch (ch) { case 't': flags |= PTRDIFFT; goto rflag; + case 'w': + flags &= ~(CHARINT|SHORTINT|LONGINT|LLONGINT|INTMAXT); + if (fmt[0] == 'f') { + flags |= FASTINT; + fmt++; + } else { + flags &= ~FASTINT; + } + if (fmt[0] == '8') { + if (!(flags & FASTINT)) + flags |= CHARINT; + else + /* no flag set = 32 */ ; + fmt += 1; + } else if (fmt[0] == '1' && fmt[1] == '6') { + if (!(flags & FASTINT)) + flags |= SHORTINT; + else + /* no flag set = 32 */ ; + fmt += 2; + } else if (fmt[0] == '3' && fmt[1] == '2') { + /* no flag set = 32 */ ; + fmt += 2; + } else if (fmt[0] == '6' && fmt[1] == '4') { + flags |= LLONGINT; + fmt += 2; + } else { + if (flags & FASTINT) { + flags &= ~FASTINT; + fmt--; + } + goto error; + } + goto rflag; case 'z': flags |= SIZET; goto rflag; @@ -541,6 +575,40 @@ reswitch: switch (ch) { case 't': flags |= PTRDIFFT; goto rflag; + case 'w': + flags &= ~(CHARINT|SHORTINT|LONGINT|LLONGINT|INTMAXT); + if (fmt[0] == 'f') { + flags |= FASTINT; + fmt++; + } else { + flags &= ~FASTINT; + } + if (fmt[0] == '8') { + if (!(flags & FASTINT)) + flags |= CHARINT; + else + /* no flag set = 32 */ ; + fmt += 1; + } else if (fmt[0] == '1' && fmt[1] == '6') { + if (!(flags & FASTINT)) + flags |= SHORTINT; + else + /* no flag set = 32 */ ; + fmt += 2; + } else if (fmt[0] == '3' && fmt[1] == '2') { + /* no flag set = 32 */ ; + fmt += 2; + } else if (fmt[0] == '6' && fmt[1] == '4') { + flags |= LLONGINT; + fmt += 2; + } else { + if (flags & FASTINT) { + flags &= ~FASTINT; + fmt--; + } + goto error; + } + goto rflag; case 'z': flags |= SIZET; goto rflag; diff --git a/lib/libc/tests/stdio/snprintf_test.c b/lib/libc/tests/stdio/snprintf_test.c index d5f056b9542d..b805f513c402 100644 --- a/lib/libc/tests/stdio/snprintf_test.c +++ b/lib/libc/tests/stdio/snprintf_test.c @@ -171,6 +171,10 @@ ATF_TC_BODY(snprintf_wN, tc) SNPRINTF_TEST("wd", "%wd", 0); SNPRINTF_TEST("w1d", "%w1d", 0); SNPRINTF_TEST("w128d", "%w128d", 0); + + SNPRINTF_TEST(" 1", "%1$*2$w16d", (int16_t)1, 2); + SNPRINTF_TEST(" 1", "%1$*2$w32d", (int32_t)1, 2); + SNPRINTF_TEST(" 1", "%1$*2$w64d", (int64_t)1, 2); } ATF_TC_WITHOUT_HEAD(snprintf_wfN); @@ -203,6 +207,10 @@ ATF_TC_BODY(snprintf_wfN, tc) SNPRINTF_TEST("wfd", "%wfd", 0); SNPRINTF_TEST("wf1d", "%wf1d", 0); SNPRINTF_TEST("wf128d", "%wf128d", 0); + + SNPRINTF_TEST(" 1", "%1$*2$w16d", (int_fast16_t)1, 2); + SNPRINTF_TEST(" 1", "%1$*2$w32d", (int_fast32_t)1, 2); + SNPRINTF_TEST(" 1", "%1$*2$w64d", (int_fast64_t)1, 2); } ATF_TP_ADD_TCS(tp) diff --git a/lib/libc/tests/stdio/swprintf_test.c b/lib/libc/tests/stdio/swprintf_test.c index 5d9c60fb9ee7..6f3d56657f4c 100644 --- a/lib/libc/tests/stdio/swprintf_test.c +++ b/lib/libc/tests/stdio/swprintf_test.c @@ -172,6 +172,10 @@ ATF_TC_BODY(swprintf_wN, tc) SWPRINTF_TEST("wd", "%wd", 0); SWPRINTF_TEST("w1d", "%w1d", 0); SWPRINTF_TEST("w128d", "%w128d", 0); + + SWPRINTF_TEST(" 1", "%1$*2$w16d", (int16_t)1, 2); + SWPRINTF_TEST(" 1", "%1$*2$w32d", (int32_t)1, 2); + SWPRINTF_TEST(" 1", "%1$*2$w64d", (int64_t)1, 2); } ATF_TC_WITHOUT_HEAD(swprintf_wfN); @@ -204,6 +208,10 @@ ATF_TC_BODY(swprintf_wfN, tc) SWPRINTF_TEST("wfd", "%wfd", 0); SWPRINTF_TEST("wf1d", "%wf1d", 0); SWPRINTF_TEST("wf128d", "%wf128d", 0); + + SWPRINTF_TEST(" 1", "%1$*2$w16d", (int_fast16_t)1, 2); + SWPRINTF_TEST(" 1", "%1$*2$w32d", (int_fast32_t)1, 2); + SWPRINTF_TEST(" 1", "%1$*2$w64d", (int_fast64_t)1, 2); } ATF_TP_ADD_TCS(tp)