From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Andy Moreton Newsgroups: gmane.emacs.devel Subject: Re: Replace XChar2b with unsigned in all font backends Date: Wed, 22 May 2019 00:04:01 +0100 Message-ID: <86tvdnmmu6.fsf@gmail.com> References: <87zhnhuhhh.fsf@gmail.com> <58ecf97c-5191-f5d6-022d-6870b9a9f9cf@gmx.at> <8736l7v6hy.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="80168"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2.50 (windows-nt) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed May 22 01:21:01 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hTE44-000Kee-V2 for ged-emacs-devel@m.gmane.org; Wed, 22 May 2019 01:21:01 +0200 Original-Received: from localhost ([127.0.0.1]:60742 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTE3x-0008AZ-6H for ged-emacs-devel@m.gmane.org; Tue, 21 May 2019 19:20:53 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:59359) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTE3B-00080q-Og for emacs-devel@gnu.org; Tue, 21 May 2019 19:20:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTDnm-0007li-Td for emacs-devel@gnu.org; Tue, 21 May 2019 19:04:12 -0400 Original-Received: from [195.159.176.226] (port=46866 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hTDnm-0007jA-Mb for emacs-devel@gnu.org; Tue, 21 May 2019 19:04:10 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.89) (envelope-from ) id 1hTDnk-00034n-Aq for emacs-devel@gnu.org; Wed, 22 May 2019 01:04:08 +0200 X-Injected-Via-Gmane: http://gmane.org/ Cancel-Lock: sha1:9PtsgOCe+vrOnLez/oIXtCaXZ1Y= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 195.159.176.226 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:236874 Archived-At: On Tue 21 May 2019, Alex Gramiak wrote: > martin rudalics writes: > >>> Does the following diff work for you? >> >> The warnings go away but characters are still displayed as empty >> boxes. > > Right, that's not unexpected since I made a flub on that patch and > didn't multiply by sizeof (wchar_t) (I posted a version that fixed that > in another message but didn't CC you, sorry). > > Here's a third version that uses SAFE_NALLOCA instead: > > diff --git a/src/w32font.c b/src/w32font.c > index bd68e22cc9..08d0f370bf 100644 > --- a/src/w32font.c > +++ b/src/w32font.c > @@ -704,11 +704,21 @@ w32font_draw (struct glyph_string *s, int from, int to, > int i; > > for (i = 0; i < len; i++) > - ExtTextOutW (s->hdc, x + i, y, options, NULL, > - s->char2b + from + i, 1, NULL); > + { > + const wchar_t ch = s->char2b[from + i]; > + ExtTextOutW (s->hdc, x + i, y, options, NULL, &ch, 1, NULL); > + } > } > else > - ExtTextOutW (s->hdc, x, y, options, NULL, s->char2b + from, len, NULL); > + { > + USE_SAFE_ALLOCA; > + wchar_t *str; > + SAFE_NALLOCA (str, 1, len); > + for (int i = 0; i < len; ++i) > + str[i] = s->char2b[from + i]; > + ExtTextOutW (s->hdc, x, y, options, NULL, str, len, NULL); > + SAFE_FREE (); > + } > > /* Restore clip region. */ > if (s->num_clips > 0) This seems much better: no more mojibake, and `view-hello-file' works. Thanks, AndyM