| Message ID | 20260119170323.83493-1-andrew@andrewoates.com |
|---|---|
| State | New |
| Headers |
Return-Path: <newlib-bounces~patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id C84A54BA9032 for <patchwork@sourceware.org>; Mon, 19 Jan 2026 17:04:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C84A54BA9032 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=U/xP7A5W X-Original-To: newlib@sourceware.org Delivered-To: newlib@sourceware.org Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by sourceware.org (Postfix) with ESMTPS id 334694BA2E06 for <newlib@sourceware.org>; Mon, 19 Jan 2026 17:03:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 334694BA2E06 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=andrewoates.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 334694BA2E06 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::743 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1768842219; cv=none; b=WjmnEup00YBvcx/Qrv3bvB1ZzmVXxfzyEceHBYYNe88GS5kBQyvAuLNQbNHR/3CXADa0B9FXPLTtUiBMGVY5kVbJCQmVGrVvKe/huwLFJoenc6L85Ce26nUr1iEkAj1HGE5qVp5ubMWyFvLDeNj0bQAT9pV5GJ7hHGWVFyFLJiI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1768842219; c=relaxed/simple; bh=4ZyLPs6q/yYdX1BZbIbJCb6/RI55sXWH/ruDw321a9Q=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=x4LcsiSNMI54sJyCrZcOLR/QerGt6oCsGT+sK40e2N6ZybVrdxzOTLQlLdsk1Qs3NRuZ3MuXXgbQtL/Y4SQCN7Yc/Wzv3Cw60qZ1toUdpWvSSj5xTWjyop+y08Rzy3tY1vYHcv7IjzFJH9Vl/bnF2EBqbgk7Aif/nNT6mAC9JSM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 334694BA2E06 Received: by mail-qk1-x743.google.com with SMTP id af79cd13be357-8c59bce68a1so285097385a.0 for <newlib@sourceware.org>; Mon, 19 Jan 2026 09:03:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768842218; x=1769447018; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:from:to:cc:subject:date:message-id:reply-to; bh=s1z+oMqLCdXQJNzgD1MJktDSJ4iAm7XIuV/YS+xjue4=; b=U/xP7A5WFiZ2EiDRg64V9wN6XizC0qJT3OVWB5OabCnADotfENiaw3oKMiFWXghQ96 rfYBt7S/tiDnMY1iKPSNuOrnii/Djz8olUdBEeia9TBBsY6BJF234ESg9nZKRoOuie2B QxJTpd0KxmEohp7Z2MgWXSiaFW3DeHkKP3QSzmcMUwHgw9IdjKmN9NSfl4ERxHnyv+kB 1bgEp/UvlrO7t1BxkqtLZDafPaVb2kbEyvBLkMR9g6e0Exn9IOmM/pi39EYp6cviWxWP CU1N+XcWYnMHc9CeaH7EOQqUKc8c2NQqfZshmw4kiug+fs8osbjRWrcx5+xaCpkgQDZy ae0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768842218; x=1769447018; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=s1z+o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40e with SMTP id af79cd13be357-8c6a67c657emr1648902885a.86.1768842213662; Mon, 19 Jan 2026 09:03:33 -0800 (PST) Received: from localhost.localdomain ([2601:189:8501:c220:4895:9d03:e50a:771e]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8c6a71ad797sm842440085a.8.2026.01.19.09.03.32 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 19 Jan 2026 09:03:33 -0800 (PST) Sender: Andrew Oates <andrewoates@gmail.com> From: andrew@andrewoates.com To: newlib@sourceware.org Cc: Andrew Oates <andrew@andrewoates.com> Subject: [PATCH] newlib/libc/ctype: Bypass _jp2uc/_uc2jp if _MB_CAPABLE is not set Date: Mon, 19 Jan 2026 12:03:20 -0500 Message-ID: <20260119170323.83493-1-andrew@andrewoates.com> X-Mailer: git-send-email 2.52.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Newlib mailing list <newlib.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/newlib>, <mailto:newlib-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/newlib/> List-Post: <mailto:newlib@sourceware.org> List-Help: <mailto:newlib-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/newlib>, <mailto:newlib-request@sourceware.org?subject=subscribe> Errors-To: newlib-bounces~patchwork=sourceware.org@sourceware.org |
| Series |
newlib/libc/ctype: Bypass _jp2uc/_uc2jp if _MB_CAPABLE is not set
|
|
Commit Message
Andrew Oates
Jan. 19, 2026, 5:03 p.m. UTC
From: Andrew Oates <andrew@andrewoates.com>
Currently, if an application uses towctrans or towctrans_l with a newlib
compiled without _MB_CAPABLE, it will fail to link due to _jp2uc/_uc2jp
being undefined. This extends the cygwin behavior to all
non-_MB_CAPABLE builds.
---
newlib/libc/ctype/local.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
Hi Andrew, On Jan 19 12:03, andrew@andrewoates.com wrote: > From: Andrew Oates <andrew@andrewoates.com> > > Currently, if an application uses towctrans or towctrans_l with a newlib > compiled without _MB_CAPABLE, it will fail to link due to _jp2uc/_uc2jp > being undefined. This extends the cygwin behavior to all > non-_MB_CAPABLE builds. I don't think this is the right thing to do. Check with other wide-char functions calling _jp2uc_l, for instance, iswprint_l(). The functions fall back to the equivalent functions for singlebyte charsets. Since there's no `toctrans' function, we have to call toupper/tolower from here. We can also exlude building the touupper/toulower functions in the same file, which reduces the footprint of the file for not _MB_CAPABLE systems. So I'd propose the following patch instead: From cb7f1ad1061c8cc55d2ff4b659bbff3395809d90 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen <corinna@vinschen.de> Date: Tue, 20 Jan 2026 10:35:20 +0100 Subject: [PATCH] towctrans_l: handle not _MB_CAPABLE targets towctrans_l neglected to special case systems for which newlib has been built without _MB_CAPABLE. Add that code equivalent to other wide-char functions, calling the singlebyte functions toupper/tolower. --- newlib/libc/ctype/towctrans_l.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/newlib/libc/ctype/towctrans_l.c b/newlib/libc/ctype/towctrans_l.c index b829266a49cd..e94d6f492c8c 100644 --- a/newlib/libc/ctype/towctrans_l.c +++ b/newlib/libc/ctype/towctrans_l.c @@ -1,10 +1,13 @@ /* Modified (m) 2017 Thomas Wolff: revise Unicode and locale/wchar handling */ #include <_ansi.h> +#include <ctype.h> #include <wctype.h> #include <stdint.h> //#include <errno.h> #include "local.h" +#ifdef _MB_CAPABLE + /* struct caseconv_entry describes the case conversion behaviour of a range of Unicode characters. @@ -139,9 +142,12 @@ touupper (wint_t c) return c; } +#endif /* _MB_CAPABLE */ + wint_t towctrans_l (wint_t c, wctrans_t w, struct __locale_t *locale) { +#ifdef _MB_CAPABLE wint_t u = _jp2uc_l (c, locale); wint_t res; if (w == WCT_TOLOWER) @@ -159,4 +165,14 @@ towctrans_l (wint_t c, wctrans_t w, struct __locale_t *locale) return _uc2jp_l (res, locale); else return c; +#else + if (c < (wint_t)0x100) + { + if (w == WCT_TOLOWER) + return tolower (c); + if (w == WCT_TOUPPER) + return toupper (c); + } + return c; +#endif /* _MB_CAPABLE */ }
On Jan 20 10:40, Corinna Vinschen wrote: > Hi Andrew, > > On Jan 19 12:03, andrew@andrewoates.com wrote: > > From: Andrew Oates <andrew@andrewoates.com> > > > > Currently, if an application uses towctrans or towctrans_l with a newlib > > compiled without _MB_CAPABLE, it will fail to link due to _jp2uc/_uc2jp > > being undefined. This extends the cygwin behavior to all > > non-_MB_CAPABLE builds. > > I don't think this is the right thing to do. Check with other wide-char > functions calling _jp2uc_l, for instance, iswprint_l(). The functions > fall back to the equivalent functions for singlebyte charsets. > > Since there's no `toctrans' function, we have to call toupper/tolower > from here. We can also exlude building the touupper/toulower functions > in the same file, which reduces the footprint of the file for not > _MB_CAPABLE systems. > > So I'd propose the following patch instead: Pushed. Corinna
diff --git a/newlib/libc/ctype/local.h b/newlib/libc/ctype/local.h index 5c293c83d..1acdfd277 100644 --- a/newlib/libc/ctype/local.h +++ b/newlib/libc/ctype/local.h @@ -32,7 +32,7 @@ * for towupper and towlower, the result must be back-transformed into the respective locale encoding; currently NOT IMPLEMENTED */ -#ifdef __CYGWIN__ +#if defined(__CYGWIN__) || !defined(_MB_CAPABLE) /* Under Cygwin, wchar_t (or its extension wint_t) is Unicode */ #define _jp2uc(c) (c) #define _jp2uc_l(c, l) (c)