From nobody Sun Nov 15 17:17:43 2026 X-Original-To: dev-commits-src-main@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 4jSHkJ10qVz70jCb for ; Sun, 15 Nov 2026 17:17:44 +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 4jSHkJ0Fdvz4YkZ for ; Sun, 15 Nov 2026 17:17:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794763064; 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=9wVplNRJKn298PBIEp0SgqZYpxEtfCYtC9l1OSwGsOE=; b=ujvR2JuNHO83XraIDIoo9DBMBjdbLbuz18dFT4EB+FVVNtEo5ocRkK2FB/fYWtxxq7l698 V+GC4oEc3IILUw1VZ7lliHOazhro3fV9ssSe1RG6zF+fhKWSTr5MmOJ3/FE8JQNDQ1Ookt RJ0jQ7Gfa0Ifnh5FY9B4jz/kNPfOEp6OcJApWHsIKgORuhuJk499UTssnYDDYrr7EPQhLF 3e0fO/BP9J4XVfIQRVVlhTAXMVASHav2vzKT6qHpicmmdzt2UCzRAuCed8MX4dPV1TOAYU t7lLKJ0Z0PSVXZt4n/iVX8pcS5s8o+74uGn0MBOP2CjFf2TUYgkWgYuZ723iMA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794763064; b=BRCrs/w7NWbuHJN2+PPQPOKwHWDPHZne3sCvrVSgLBFmM/jJXetrG9HvDgGflbSxymPKxY cPMRXbpX48Kx0jrSEK5mBbNmASnJvs2IM1adckktOerzI0zB8L9GsTfh7Idk9BtK428ZNa wkXTmm5sfaAZe7SojBfAnRU/eRrSTW42uCl2vTlZerzokDXw3C9ee+CAZf2Z0L06H0lCn7 OtylPMY15YP1VA9i5QlkvFJgtX3uxKlNawnAUKM90oyWbjd0IY/ITjgsi+ZwrFeNjqRGaw kU3z5yBoYgL+Je4+DXbl/NQv8WxCm6Or83SOt7+e6AdN9pYN1utEGLus/QVtyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794763064; 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=9wVplNRJKn298PBIEp0SgqZYpxEtfCYtC9l1OSwGsOE=; b=atCWlJ8omDgyhJAKw99NaAPGu9ehwnRebnhDuHwJpf+MqvLSGilC26qP9qDa0RxkfwtTCI 6COx5mJfMVvBiKQekpnMEPExJzusWoHsnBMeacc8+tFB5Y+LGDdJbM9ELw5sAPNThO18XN 2VGsm1DGTrHHxaPaYZNzmKe9DKJQxHlC9bpXW32hLiYKdfbjEJvf9CxNJo1SLmcvGojnN1 K9j4rypNT7YDs8wY1vrizd/8eAuKLyxTEzVhvA21Yl/Tym7qxFmiICGBDSux483KafZ4sL F8Gn+wrDa4vBy2k7vmu31/2z4GCqE684zllorLM1DnpMKuFLWsThrcEqDjqLRw== 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 4jSHkH7218zGDS for ; Sun, 15 Nov 2026 17:17:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 9e6a by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 15 Nov 2026 17:17:43 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav Subject: git: 5e809bf1c93f - main - stdio: Fix positional %wN / %wfN conversion List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main X-BeenThere: dev-commits-src-main@freebsd.org List-Id: Commit messages for the main branch 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: 5e809bf1c93fdc4c52fa46a7eb0e6f881b6c6140 Auto-Submitted: auto-generated Date: Sun, 15 Nov 2026 17:17:43 +0000 Message-Id: <6af9e937.9e6a.747020cc@gitrepo.freebsd.org> The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=5e809bf1c93fdc4c52fa46a7eb0e6f881b6c6140 commit 5e809bf1c93fdc4c52fa46a7eb0e6f881b6c6140 Author: Dag-Erling Smørgrav AuthorDate: 2026-11-15 16:37:42 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2026-11-15 17:16:55 +0000 stdio: Fix positional %wN / %wfN conversion MFC after: 1 week Fixes: bce0bef3c6ab ("libc: Implement N2680.") Fixes: 12b1c1e3fb44 ("libc: Add test cases for N2680.") --- 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 27b59f25b67d..fd92b3d5ad29 100644 --- a/lib/libc/stdio/printf-pos.c +++ b/lib/libc/stdio/printf-pos.c @@ -337,6 +337,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; @@ -532,6 +566,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)