From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 0E5FE385842E for ; Mon, 12 Jun 2023 15:19:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0E5FE385842E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 034C42189B; Mon, 12 Jun 2023 15:19:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1686583152; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Mthjs5Rtzkx87KCo+QHPIfqerMC1z8okguyDlf9K//Q=; b=kh8EHcgiDg5Cg+Yqy8I2uNIw5sGK7iY801ukrNVN+g/FM/bGdW3k9VE18iLjIkBDu6f858 Da53tEQfhPaPxjgOkv5xWl/tXkcB/sZc5SxAo1dpzig7mtvRVR/96XMyPOrDZMr+8TdPVd ZbNT5LhoS4gdnxVYT1NUhk0Aatzxyok= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1686583152; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Mthjs5Rtzkx87KCo+QHPIfqerMC1z8okguyDlf9K//Q=; b=trf7MLYokmgupy0MNVy/hV+Hp5sxQSTXhcInuVdvjbZq1UdhidR3Cr4FHxlg3te5yHNZ+U 2MUyNuuBLoagumAA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id E41E3138EC; Mon, 12 Jun 2023 15:19:11 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 4B6KNm83h2QjNwAAMHmgww (envelope-from ); Mon, 12 Jun 2023 15:19:11 +0000 Message-ID: <3fb08009-9266-8bc3-cf0e-1764f6d67e9e@suse.de> Date: Mon, 12 Jun 2023 17:19:29 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH v2 2/2] [gdb/tui] Handle unicode chars in prompt Content-Language: en-US To: Tom Tromey , Tom de Vries via Gdb-patches References: <20230609091850.21301-1-tdevries@suse.de> <20230609091850.21301-2-tdevries@suse.de> <87h6rg7ih7.fsf@tromey.com> From: Tom de Vries In-Reply-To: <87h6rg7ih7.fsf@tromey.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 6/9/23 17:39, Tom Tromey wrote: >>>>>> "Tom" == Tom de Vries via Gdb-patches writes: > > Tom> +#ifdef HAVE_BTOWC > Tom> + { > Tom> + int mb_len; > Tom> + if (is_mb_char (string, mb_len) && mb_len != 1) > Tom> + { > Tom> + if (mb_len == 0) > Tom> + { > Tom> + /* Multi-byte null char. */ > Tom> + break; > Tom> + } > Tom> + > Tom> + waddnstr (w, string, mb_len); > Tom> + string += mb_len; > Tom> + handled = true; > Tom> + } > Tom> + } > Tom> +#endif > > I wonder if this would be simplified by using wchar_iterator. > > This iterator tries to convert just a single character, and has out > parameters that reflect which input bytes were converted. > > The main benefit would be less #ifdef and no need for is_mb_char in > tui-io.c. > The iterator constructor also needs a specification of encoding and width. I suppose for encoding we could use host_charset (), but I don't know how to get the base width of that char set. ISTM that's a problem that the multibyte functions take care of for us. Thanks, - Tom > You may need to add a method to wchar_iterator to let the caller skip > some bytes (you wouldn't want to create a new one on each iteration, as > it calls iconv_open). That way the escape handling could stay pretty > much the same. > > Tom