Ethereal-dev: Re: [Ethereal-dev] packet-x11-keysym.h cleanup

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Ron Flory <ron.flory@xxxxxxxxxx>
Date: Wed, 03 Oct 2001 10:46:49 -0500
Motonori Shindo wrote:
> Today I looked at packet-x11-keysym.h and found that it embeds a raw
> 8-bit character in a string, which is not a good idea generally. It is
> less editable and, even worse, some compiler (notably Japanized
> version of MS Visual C++) fail to compile it because a character with
> MSB being set is recognized as the 1st byte of 2-byte character
> (Kanji) and subsequent byte (double-quote) is recognized as the second
> half of Kanji character, ending up with an open-ended string.
> 
> To avoid this problem, a character with MSB=1 should be expressed
> using an octal notation in a string (i.e. \xxx). I enclosed a patch
> that does it. I confirmed that a new code generates exactly the same
> object file as before, and hence there's no change in the executable.

>   ------------------------------------------------------------------------
> Index: packet-x11-keysym.h

> -      { 0x0a4, "¤" }, { 0x0a5, "¥" }, { 0x0a6, "¦" }, { 0x0a7, "§" },
> +      { 0x0a4, "\244" }, { 0x0a5, "\245" }, { 0x0a6, "\246" }, { 0x0a7, "\247" },

 why oh why are you using (yucky old) octal?  Now there's a confusing
mix of hex and octal in the same line.

 how about:

> +      { 0x0a4, "\x0a4" }, { 0x0a5, "\x0a5" }, { 0x0a6, "\x0a6" }, { 0x0a7, "\x0a7" },

 instead, its sure a lot easier to read and understand whats actually
being done.

ron