From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id 76ADB25B5E for ; Sun, 25 Feb 2024 09:29:25 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1708849765; b=H4feDKEZ1QhYj3mkvk+s9qGpCkE25YWK5APAjSSE4c34MDusvps9NdtXZ/Y/q4cykE3Y46ctI7 BRq1MHTGzPgau3xAIsmETIasO59Dufboq0JDGQrisYSpoCm8bU72GgnVM51VtCi47xVXrdokKl i9bB0lKz2dP7VMEbvbjOYzDu5fMWwZ8oB+h54e82OH16/QyX48IJj5EmVlhLC1c0fVnWPqAk1J wdA/Aqb7b6sLrx+qwArE8iVZULZDqK4n8QK/uTSBS4rkuHtqiI11Ko2nONV+U1g60g5jlUFDus WltURc944aBiM4TSyFSJcdgtW43Iwpbkxm3eQnrSZTa19Q==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (relay2-d.mail.gandi.net) smtp.remote-ip=217.70.183.194; dmarc=none header.from=chazelas.org; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1708849765; bh=Rv043D0/P7KIbNQG9o4B1NOCq80xub3daxTUCj0A0pg=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Transfer-Encoding:Content-Type: MIME-Version:References:Message-ID:Subject:To:From:Date:DKIM-Signature; b=DD30LLKH0thZJeW4KvnMTlm5TDR0eiA9zoKyJaPb4UV+4dqBlgj83T/EzD3+UXqPJWFYo97W0T WrEIw8ihH62RX5MODuTuJYBbSSY3TrtdMPTOv+d7GIUyC+gMNMkKnVLt9zpaqFYDVBkHX7C0DQ zVNRLyBHBXi+UNXFRX+Pe8U9P3uVZfT8/1Pl1u36qK1NMSHLdUrBv8OilwrEa/spNFWCv06I0J kjTBMPtmAagMz2bHixasZHmYK2hYTokL+z6P3zo2OjarX9cFTyRKeSC1RG0DgOO7ct8p8r0jMD wBbBSwn6MFfzzNDRWU0tpjzEe9VZpuQfEGoE1n5Rlyg1xQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:To:From:Date: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=uTtrGsMd8WOJEGx2nGim1l4KtaXUEiSEAvssqj62Z/k=; b=hRtGkhFxfcVW5K0gp6WC4khmWu 2qBDr8AihsWIb8Acw6y+d2VpzgbgVhGPFZfi1ENfmW+qXAFwQaY+RowlBx79uB7NCGvlHhoYo/Uq5 GIAYenTKZ5eByB+4iSnuctW+xLbxubdjN18nUuFUhu/LI2xtfWGcVDoUOtGlKAHNXE29BhC8trZQ1 r3VhNiZMDrYuKmSG2VAQCKXE2Jd24x0nrGIRsh8fa/AgErZwou9B7C47wtRputAyOGMqOaGpjoyw4 8AOKtfY1KNoSEMabxb85zBNhFhF3tkkLv1dN8quxAnB91tL7Ldo9ScJUHtyGa1kWoLRexPNPM8Wqn H0h2XO5A==; Received: by zero.zsh.org with local id 1re9sx-000CLc-6Y; Sun, 25 Feb 2024 08:29:23 +0000 Authentication-Results: zsh.org; iprev=pass (relay2-d.mail.gandi.net) smtp.remote-ip=217.70.183.194; dmarc=none header.from=chazelas.org; arc=none Received: from relay2-d.mail.gandi.net ([217.70.183.194]:55261) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1re9sd-000C3G-2Z; Sun, 25 Feb 2024 08:29:04 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 763AC40004; Sun, 25 Feb 2024 08:29:00 +0000 (UTC) Date: Sun, 25 Feb 2024 08:28:59 +0000 From: Stephane Chazelas To: Bart Schaefer , zsh workers Subject: typeset - (Was: metafication in error messages) Message-ID: <20240225082859.t4ersac6tyn3gn6j@chazelas.org> Mail-Followup-To: Bart Schaefer , zsh workers References: <20240222072313.7woy5vxvt4fbxyhj@chazelas.org> <20240222075528.eruaoosiuhmcrdsy@chazelas.org> <20240223192717.tczrbc63fei7d4m2@chazelas.org> <20240224094722.hnullrzrb6gsswnm@chazelas.org> <20240225072951.sxzdzoydvgqxctdj@chazelas.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240225072951.sxzdzoydvgqxctdj@chazelas.org> X-GND-Sasl: stephane@chazelas.org X-Seq: 52602 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: By the way, while looking at other culprits for missing metafication in calls to zerr*, I found (in UTF-8 locale): $ typeset -é typeset: bad option: -^ ~$ zsh -c 'typeset -é' |& sed -n l zsh:typeset:1: bad option: -^\003$ (gdb) 305 while (*fmt) (gdb) 306 if (*fmt == '%') { (gdb) 307 fmt++; (gdb) 308 switch (*fmt++) { (gdb) 348 num = va_arg(ap, int); (gdb) 350 mb_charinit(); (gdb) p num $2 = -61 (gdb) p (unsigned char) num $3 = 195 '\303' (that's 0xc3, the first byte of é, normally rendered as \M-C). We end up with a ^ because in wcs_nicechar_sel(): wcs_nicechar_sel (c=-61 L'\xffffffc3', widthp=0x0, swidep=0x0, quotable=0) at utils.c:602 602 int ret = 0; (gdb) n 603 VARARR(char, mbstr, MB_CUR_MAX); (gdb) 612 newalloc = NICECHAR_MAX; (gdb) 613 if (bufalloc != newalloc) (gdb) 619 s = buf; (gdb) 620 if (!WC_ISPRINT(c) && (c < 0x80 || !isset(PRINTEIGHTBIT))) { (gdb) 621 if (c == 0x7f) { (gdb) 629 } else if (c == L'\n') { (gdb) 632 } else if (c == L'\t') { (gdb) 635 } else if (c < 0x20) { (gdb) 636 if (quotable) { (gdb) 641 *s++ = '^'; It's < 0x20 because negative and we end up with ^<0x3> because that's -61 + 64. zerrmsg's %c expects a wchar_t when MULTIBYTE_SUPPORT is enabled, but here we're passing it the first byte (signed) of the encoding of the wide character. Calling it with (unsigned char)*arg is not much better as you end up with: zsh:typeset:1: bad option: -Ã As U+00C3 (Ã) happens to be printable. If it weren't -\M-C would not be much better anyway. And you also get zsh:typeset:1: bad option: -Ã for typeset -$'\xc3' Some options could be: - return a "no non-ASCII/multibyte option supported" error message when *arg >= 0x80 - extract and decode the full multibyte character before passing to zerrmsg. which leaves the problem of how to render byte sequences that can't be decoded. Maybe there are already functions in the code that do that? -- Stephane