unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* XCHAR2B_BYTE[12] definitions in NS
@ 2014-07-15  9:02 Daiki Ueno
  2014-07-15 13:20 ` Jan Djärv
  0 siblings, 1 reply; 4+ messages in thread
From: Daiki Ueno @ 2014-07-15  9:02 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 353 bytes --]

Hi,

While I'm doing some experiment based on the NS port, I sometimes get
unexpected glyph index, because of missing parentheses in
XCHAR2B_BYTE[12] definitions (patch attached).  I believe those macros
are not actually used by the NS port, but maybe good to fix it to avoid
any confusion.  OK to commit, or perhaps they should be completely
removed?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: nsgui.h.patch --]
[-- Type: text/x-patch, Size: 862 bytes --]

=== modified file 'src/ChangeLog'
--- src/ChangeLog	2014-07-14 19:23:18 +0000
+++ src/ChangeLog	2014-07-15 08:48:30 +0000
@@ -1,3 +1,9 @@
+2014-07-15  Daiki Ueno  <ueno@gnu.org>
+
+	* nsgui.h (XCHAR2B_BYTE1): Add missing parentheses around
+	pointer argument, before dereferencing.
+	(XCHAR2B_BYTE2): Likewise.
+
 2014-07-14  Paul Eggert  <eggert@cs.ucla.edu>
 
 	Use binary-io module, O_BINARY, and "b" flag (Bug#18006).

=== modified file 'src/nsgui.h'
--- src/nsgui.h	2014-06-02 18:01:21 +0000
+++ src/nsgui.h	2014-07-15 06:40:08 +0000
@@ -68,10 +68,10 @@
   (*(chp) = ((XChar2b)((((b1) & 0x00ff) << 8) | ((b2) & 0x00ff))))
 
 #define XCHAR2B_BYTE1(chp) \
- (((*chp) & 0xff00) >> 8)
+  ((*(chp) & 0xff00) >> 8)
 
 #define XCHAR2B_BYTE2(chp) \
- ((*chp) & 0x00ff)
+  (*(chp) & 0x00ff)
 
 
 /* XXX: xfaces requires these structures, but the question is are we


[-- Attachment #3: Type: text/plain, Size: 24 bytes --]


Regards,
--
Daiki Ueno

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: XCHAR2B_BYTE[12] definitions in NS
  2014-07-15  9:02 XCHAR2B_BYTE[12] definitions in NS Daiki Ueno
@ 2014-07-15 13:20 ` Jan Djärv
  2014-07-16  4:14   ` Daiki Ueno
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Djärv @ 2014-07-15 13:20 UTC (permalink / raw)
  To: Daiki Ueno; +Cc: emacs-devel

Hello.

15 jul 2014 kl. 11:02 skrev Daiki Ueno <ueno@gnu.org>:

> Hi,
> 
> While I'm doing some experiment based on the NS port, I sometimes get
> unexpected glyph index, because of missing parentheses in
> XCHAR2B_BYTE[12] definitions (patch attached).  I believe those macros
> are not actually used by the NS port, but maybe good to fix it to avoid
> any confusion.  OK to commit, or perhaps they should be completely
> removed?
> 

They are used in xdisp.c which is generic code.
W32 has similar macros.  Maybe move to a common h-file and remove w32 and ns-specific macros?

	Jan D.

> === modified file 'src/ChangeLog'
> --- src/ChangeLog	2014-07-14 19:23:18 +0000
> +++ src/ChangeLog	2014-07-15 08:48:30 +0000
> @@ -1,3 +1,9 @@
> +2014-07-15  Daiki Ueno  <ueno@gnu.org>
> +
> +	* nsgui.h (XCHAR2B_BYTE1): Add missing parentheses around
> +	pointer argument, before dereferencing.
> +	(XCHAR2B_BYTE2): Likewise.
> +
> 2014-07-14  Paul Eggert  <eggert@cs.ucla.edu>
> 
> 	Use binary-io module, O_BINARY, and "b" flag (Bug#18006).
> 
> === modified file 'src/nsgui.h'
> --- src/nsgui.h	2014-06-02 18:01:21 +0000
> +++ src/nsgui.h	2014-07-15 06:40:08 +0000
> @@ -68,10 +68,10 @@
>   (*(chp) = ((XChar2b)((((b1) & 0x00ff) << 8) | ((b2) & 0x00ff))))
> 
> #define XCHAR2B_BYTE1(chp) \
> - (((*chp) & 0xff00) >> 8)
> +  ((*(chp) & 0xff00) >> 8)
> 
> #define XCHAR2B_BYTE2(chp) \
> - ((*chp) & 0x00ff)
> +  (*(chp) & 0x00ff)
> 
> 
> /* XXX: xfaces requires these structures, but the question is are we
> 
> 
> Regards,
> --
> Daiki Ueno




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: XCHAR2B_BYTE[12] definitions in NS
  2014-07-15 13:20 ` Jan Djärv
@ 2014-07-16  4:14   ` Daiki Ueno
  2014-07-16  5:46     ` Daiki Ueno
  0 siblings, 1 reply; 4+ messages in thread
From: Daiki Ueno @ 2014-07-16  4:14 UTC (permalink / raw)
  To: Jan Djärv; +Cc: emacs-devel

Jan Djärv <jan.h.d@swipnet.se> writes:

> They are used in xdisp.c which is generic code.
> W32 has similar macros.  Maybe move to a common h-file and remove w32
> and ns-specific macros?

Makes sense, thanks for the suggestion.  I've pushed a patch in that way
(r117538).

Regards,
--
Daiki Ueno



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: XCHAR2B_BYTE[12] definitions in NS
  2014-07-16  4:14   ` Daiki Ueno
@ 2014-07-16  5:46     ` Daiki Ueno
  0 siblings, 0 replies; 4+ messages in thread
From: Daiki Ueno @ 2014-07-16  5:46 UTC (permalink / raw)
  To: Jan Djärv; +Cc: emacs-devel

Daiki Ueno <ueno@gnu.org> writes:

> Jan Djärv <jan.h.d@swipnet.se> writes:
>
>> They are used in xdisp.c which is generic code.
>> W32 has similar macros.  Maybe move to a common h-file and remove w32
>> and ns-specific macros?
>
> Makes sense, thanks for the suggestion.  I've pushed a patch in that way
> (r117538).

I missed the fact that s->char2b is directly passed to the
platform-dependent drawing functions: ExtTextOutW (W32) and
CGContextShowGlyphsWithAdvances (NS), and the corresponding argument
types are also platform-dependent: wchar_t * (W32) and unichar * (NS).

So, IMO merging the macros into a single place will cause more
confusion.  I reverted the change and just installed the parentheses fix
I initially posted.  Sorry for all the fuss.

Regards,
--
Daiki Ueno



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-07-16  5:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-15  9:02 XCHAR2B_BYTE[12] definitions in NS Daiki Ueno
2014-07-15 13:20 ` Jan Djärv
2014-07-16  4:14   ` Daiki Ueno
2014-07-16  5:46     ` Daiki Ueno

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).