emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Replace XChar2b with unsigned in all font backends


From: Alex Gramiak
Subject: Re: Replace XChar2b with unsigned in all font backends
Date: Mon, 20 May 2019 12:07:54 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux)

martin rudalics <address@hidden> writes:

> After this commit, building master on Windows here produces
>
>
>
>   CC       w32term.o
> ../../src/w32font.c: In function 'w32font_draw':
> ../../src/w32font.c:708:25: warning: passing argument 6 of 'ExtTextOutW' from 
> incompatible pointer type [-Wincompatible-pointer-types]
>         s->char2b + from + i, 1, NULL);
>         ~~~~~~~~~~~~~~~~~^~~
> In file included from 
> C:/msys64/mingw64/x86_64-w64-mingw32/include/windows.h:71,
>                  from ../../src/w32font.c:20:
> C:/msys64/mingw64/x86_64-w64-mingw32/include/wingdi.h:3347:100: note: 
> expected 'LPCWSTR' {aka 'const short unsigned int *'} but argument is of type 
> 'unsigned int *'
>    WINGDIAPI WINBOOL WINAPI ExtTextOutW(HDC hdc,int x,int y,UINT 
> options,CONST RECT *lprect,LPCWSTR lpString,UINT c,CONST INT *lpDx);
>                                                                               
>               ~~~~~~~~^~~~~~~~
> ../../src/w32font.c:711:57: warning: passing argument 6 of 'ExtTextOutW' from 
> incompatible pointer type [-Wincompatible-pointer-types]
>      ExtTextOutW (s->hdc, x, y, options, NULL, s->char2b + from, len, NULL);
>                                                ~~~~~~~~~~^~~~~~
> In file included from 
> C:/msys64/mingw64/x86_64-w64-mingw32/include/windows.h:71,
>                  from ../../src/w32font.c:20:
> C:/msys64/mingw64/x86_64-w64-mingw32/include/wingdi.h:3347:100: note: 
> expected 'LPCWSTR' {aka 'const short unsigned int *'} but argument is of type 
> 'unsigned int *'
>    WINGDIAPI WINBOOL WINAPI ExtTextOutW(HDC hdc,int x,int y,UINT 
> options,CONST RECT *lprect,LPCWSTR lpString,UINT c,CONST INT *lpDx);
>                                                                               
>               ~~~~~~~~^~~~~~~~
>   CC       w32xfns.o
>
>
>
> and the resulting build is not usable.
>
> martin

Does the following diff work for you?

diff --git a/src/w32font.c b/src/w32font.c
index bd68e22cc9..fe85601380 100644
--- a/src/w32font.c
+++ b/src/w32font.c
@@ -704,11 +704,20 @@ 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_ALLOCA (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)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]