public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] windres bugs
@ 2002-01-08 11:24 Eric Kohl
  0 siblings, 0 replies; 3+ messages in thread
From: Eric Kohl @ 2002-01-08 11:24 UTC (permalink / raw)
  To: binutils

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

Hi!

This patch fixes two bugs in windres.

1) The FONT statement in DIALOGEX resources uses five parameters instead of
four. The fifth parameter specifies the used character set, e.g. ansi, oem,
default, russian, greek, etc.

2) The default window styles for DIALOG and DIALOGEX resources are wrong.
The WS_POPUP style was always added to the given window styles. This caused
severe problems in WS_CHILD dialogs.

Best regards,

Eric Kohl

----
01-08-2002 Eric Kohl (ekohl@rz-online.de)

	* rcparse.y: Added fifth parameter (character set) to FONT statement in DIALOGEX resources. Fixed default window styles for DIALOG and DIALOGEX resources.

	*resbin.c (bin_to_res_dialog): Fixed read/write code for dialogex resource data.
	(res_to_bin_dialog): Likewise.

	*windres.h: Fixed dialog_ex resource data struct.

[-- Attachment #2: binutils.diff --]
[-- Type: text/plain, Size: 4236 bytes --]

Index: rcparse.y
===================================================================
RCS file: /cvs/src/src/binutils/rcparse.y,v
retrieving revision 1.7
diff -u -r1.7 rcparse.y
--- rcparse.y	2001/09/19 05:33:16	1.7
+++ rcparse.y	2002/01/08 17:55:07
@@ -332,7 +332,7 @@
 	      dialog.y = $6;
 	      dialog.width = $7;
 	      dialog.height = $8;
-	      dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU;
+	      dialog.style = WS_POPUP;
 	      dialog.exstyle = $4;
 	      dialog.menu.named = 1;
 	      dialog.class.named = 1;
@@ -353,7 +353,7 @@
 	      dialog.y = $6;
 	      dialog.width = $7;
 	      dialog.height = $8;
-	      dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU;
+	      dialog.style = WS_POPUP;
 	      dialog.exstyle = $4;
 	      dialog.menu.named = 1;
 	      dialog.class.named = 1;
@@ -376,7 +376,7 @@
 	      dialog.y = $6;
 	      dialog.width = $7;
 	      dialog.height = $8;
-	      dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU;
+	      dialog.style = WS_POPUP;
 	      dialog.exstyle = $4;
 	      dialog.menu.named = 1;
 	      dialog.class.named = 1;
@@ -409,6 +409,7 @@
 	  /* empty */
 	| styles CAPTION QUOTEDSTRING
 	  {
+	    dialog.style |= WS_CAPTION;
 	    unicode_from_ascii ((int *) NULL, &dialog.caption, $3);
 	  }
 	| styles CLASS id
@@ -416,10 +417,10 @@
 	    dialog.class = $3;
 	  }
 	| styles STYLE
-	    { style = dialog.style; }
+	    { style = dialog.style & ~WS_POPUP; }
 	    styleexpr
 	  {
-	    dialog.style = style;
+	    dialog.style |= style;
 	  }
 	| styles EXSTYLE numexpr
 	  {
@@ -431,7 +432,7 @@
 	    dialog.pointsize = $3;
 	    unicode_from_ascii ((int *) NULL, &dialog.font, $5);
 	  }
-	| styles FONT numexpr ',' QUOTEDSTRING cnumexpr cnumexpr
+	| styles FONT numexpr ',' QUOTEDSTRING cnumexpr cnumexpr cnumexpr
 	  {
 	    dialog.style |= DS_SETFONT;
 	    dialog.pointsize = $3;
@@ -442,6 +443,7 @@
 	      {
 		dialog.ex->weight = $6;
 		dialog.ex->italic = $7;
+		dialog.ex->charset = $8;
 	      }
 	  }
 	| styles MENU id
Index: resbin.c
===================================================================
RCS file: /cvs/src/src/binutils/resbin.c,v
retrieving revision 1.2
diff -u -r1.2 resbin.c
--- resbin.c	2001/03/13 06:43:58	1.2
+++ resbin.c	2002/01/08 17:55:15
@@ -30,6 +30,7 @@
 
 /* Macros to swap in values.  */
 
+#define get_8(s) (*((unsigned char *)(s)))
 #define get_16(be, s) ((be) ? bfd_getb16 (s) : bfd_getl16 (s))
 #define get_32(be, s) ((be) ? bfd_getb32 (s) : bfd_getl32 (s))
 
@@ -523,6 +524,7 @@
 	{
 	  d->ex->weight = 0;
 	  d->ex->italic = 0;
+	  d->ex->charset = 1; /* default charset */
 	}
     }
   else
@@ -538,7 +540,8 @@
 	  if (length < off + 4)
 	    toosmall (_("dialogex font information"));
 	  d->ex->weight = get_16 (big_endian, data + off);
-	  d->ex->italic = get_16 (big_endian, data + off + 2);
+	  d->ex->italic = get_8 (data + off + 2);
+	  d->ex->charset = get_8 (data + off + 3);
 	  off += 4;
 	}
 
@@ -1252,6 +1255,7 @@
 \f
 /* Macros to swap out values.  */
 
+#define put_8(v, s) (*((unsigned char *)(s)) = (unsigned char)(v))
 #define put_16(be, v, s) ((be) ? bfd_putb16 ((v), (s)) : bfd_putl16 ((v), (s)))
 #define put_32(be, v, s) ((be) ? bfd_putb32 ((v), (s)) : bfd_putl32 ((v), (s)))
 
@@ -1621,12 +1625,14 @@
 	  if (dialog->ex == NULL)
 	    {
 	      put_16 (big_endian, 0, d->data + 2);
-	      put_16 (big_endian, 0, d->data + 4);
+	      put_8 (0, d->data + 4);
+	      put_8 (1, d->data + 5);
 	    }
 	  else
 	    {
 	      put_16 (big_endian, dialog->ex->weight, d->data + 2);
-	      put_16 (big_endian, dialog->ex->italic, d->data + 4);
+	      put_8 (dialog->ex->italic, d->data + 4);
+	      put_8 (dialog->ex->charset, d->data + 5);
 	    }
 	}
 
Index: windres.h
===================================================================
RCS file: /cvs/src/src/binutils/windres.h,v
retrieving revision 1.6
diff -u -r1.6 windres.h
--- windres.h	2001/07/17 01:19:19	1.6
+++ windres.h	2002/01/08 17:55:19
@@ -315,7 +315,9 @@
   /* Font weight.  */
   unsigned short weight;
   /* Whether the font is italic.  */
-  unsigned short italic;
+  unsigned char italic;
+  /* Character set.  */
+  unsigned char charset;
 };
 
 /* Window style flags, from the winsup Defines.h header file.  These

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

* [patch] windres bugs
  2001-11-08 18:22 [patch] " Eric Kohl
@ 2001-11-18  5:14 ` Eric Kohl
  0 siblings, 0 replies; 3+ messages in thread
From: Eric Kohl @ 2001-11-18  5:14 UTC (permalink / raw)
  To: binutils

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

Hi!

This patch fixes two bugs in windres.

1) The FONT statement in DIALOGEX resources uses five parameters instead of
four. The fifth parameter specifies the used character set, e.g. ansi, oem,
default, russian, greek, etc.

2) The default window styles for DIALOG and DIALOGEX resources are wrong.
The WS_POPUP style was always added to the given window styles. This caused
severe problems in WS_CHILD dialogs.

Best regards,

Eric Kohl

----
11-18-2001 Eric Kohl (ekohl@rz-online.de)

* rcparse.y: Added fifth parameter (character set) to FONT statement in
DIALOGEX resources.
Fixed default window styles for DIALOG and DIALOGEX resources.

*resbin.c(bin_to_res_dialog): Fixed read/write code for dialogex resource
data.
(res_to_bin_dialog): Likewise.

*windres.h: Fixed dialog_ex resource data struct.


[-- Attachment #2: windres.diff --]
[-- Type: text/x-diff, Size: 4012 bytes --]

diff -r -b -u src-orig/binutils/rcparse.y src/binutils/rcparse.y
--- src-orig/binutils/rcparse.y	Sat Nov 17 23:17:36 2001
+++ src/binutils/rcparse.y	Sat Nov 17 23:57:12 2001
@@ -332,7 +332,7 @@
 	      dialog.y = $6;
 	      dialog.width = $7;
 	      dialog.height = $8;
-	      dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU;
+	      dialog.style = WS_POPUP;
 	      dialog.exstyle = $4;
 	      dialog.menu.named = 1;
 	      dialog.class.named = 1;
@@ -353,7 +353,7 @@
 	      dialog.y = $6;
 	      dialog.width = $7;
 	      dialog.height = $8;
-	      dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU;
+	      dialog.style = WS_POPUP;
 	      dialog.exstyle = $4;
 	      dialog.menu.named = 1;
 	      dialog.class.named = 1;
@@ -376,7 +376,7 @@
 	      dialog.y = $6;
 	      dialog.width = $7;
 	      dialog.height = $8;
-	      dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU;
+	      dialog.style = WS_POPUP;
 	      dialog.exstyle = $4;
 	      dialog.menu.named = 1;
 	      dialog.class.named = 1;
@@ -409,6 +409,7 @@
 	  /* empty */
 	| styles CAPTION QUOTEDSTRING
 	  {
+	    dialog.style |= WS_CAPTION;
 	    unicode_from_ascii ((int *) NULL, &dialog.caption, $3);
 	  }
 	| styles CLASS id
@@ -416,10 +417,10 @@
 	    dialog.class = $3;
 	  }
 	| styles STYLE
-	    { style = dialog.style; }
+	    { style = dialog.style & ~WS_POPUP; }
 	    styleexpr
 	  {
-	    dialog.style = style;
+	    dialog.style |= style;
 	  }
 	| styles EXSTYLE numexpr
 	  {
@@ -431,7 +432,7 @@
 	    dialog.pointsize = $3;
 	    unicode_from_ascii ((int *) NULL, &dialog.font, $5);
 	  }
-	| styles FONT numexpr ',' QUOTEDSTRING cnumexpr cnumexpr
+	| styles FONT numexpr ',' QUOTEDSTRING cnumexpr cnumexpr cnumexpr
 	  {
 	    dialog.style |= DS_SETFONT;
 	    dialog.pointsize = $3;
@@ -442,6 +443,7 @@
 	      {
 		dialog.ex->weight = $6;
 		dialog.ex->italic = $7;
+		dialog.ex->charset = $8;
 	      }
 	  }
 	| styles MENU id
diff -r -b -u src-orig/binutils/resbin.c src/binutils/resbin.c
--- src-orig/binutils/resbin.c	Sat Nov 17 23:17:36 2001
+++ src/binutils/resbin.c	Sat Nov 17 23:57:12 2001
@@ -30,6 +30,7 @@
 
 /* Macros to swap in values.  */
 
+#define get_8(s) (*((unsigned char *)(s)))
 #define get_16(be, s) ((be) ? bfd_getb16 (s) : bfd_getl16 (s))
 #define get_32(be, s) ((be) ? bfd_getb32 (s) : bfd_getl32 (s))
 
@@ -523,6 +524,7 @@
 	{
 	  d->ex->weight = 0;
 	  d->ex->italic = 0;
+	  d->ex->charset = 1; /* default charset */
 	}
     }
   else
@@ -538,7 +540,8 @@
 	  if (length < off + 4)
 	    toosmall (_("dialogex font information"));
 	  d->ex->weight = get_16 (big_endian, data + off);
-	  d->ex->italic = get_16 (big_endian, data + off + 2);
+	  d->ex->italic = get_8 (data + off + 2);
+	  d->ex->charset = get_8 (data + off + 3);
 	  off += 4;
 	}
 
@@ -1252,6 +1255,7 @@
 \f
 /* Macros to swap out values.  */
 
+#define put_8(v, s) (*((unsigned char *)(s)) = (unsigned char)(v))
 #define put_16(be, v, s) ((be) ? bfd_putb16 ((v), (s)) : bfd_putl16 ((v), (s)))
 #define put_32(be, v, s) ((be) ? bfd_putb32 ((v), (s)) : bfd_putl32 ((v), (s)))
 
@@ -1621,12 +1625,14 @@
 	  if (dialog->ex == NULL)
 	    {
 	      put_16 (big_endian, 0, d->data + 2);
-	      put_16 (big_endian, 0, d->data + 4);
+	      put_8 (0, d->data + 4);
+	      put_8 (1, d->data + 5);
 	    }
 	  else
 	    {
 	      put_16 (big_endian, dialog->ex->weight, d->data + 2);
-	      put_16 (big_endian, dialog->ex->italic, d->data + 4);
+	      put_8 (dialog->ex->italic, d->data + 4);
+	      put_8 (dialog->ex->charset, d->data + 5);
 	    }
 	}
 
diff -r -b -u src-orig/binutils/windres.h src/binutils/windres.h
--- src-orig/binutils/windres.h	Sat Nov 17 23:17:36 2001
+++ src/binutils/windres.h	Sat Nov 17 23:57:12 2001
@@ -315,7 +315,9 @@
   /* Font weight.  */
   unsigned short weight;
   /* Whether the font is italic.  */
-  unsigned short italic;
+  unsigned char italic;
+  /* Character set.  */
+  unsigned char charset;
 };
 
 /* Window style flags, from the winsup Defines.h header file.  These

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

* [patch] windres bugs
@ 2001-11-08 18:22 Eric Kohl
  2001-11-18  5:14 ` Eric Kohl
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Kohl @ 2001-11-08 18:22 UTC (permalink / raw)
  To: binutils

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

Hi!

This patch fixes two bugs in windres.

1) The FONT statement in DIALOGEX resources uses five parameters instead of
four. The fifth parameter specifies the used character set, e.g. ansi, oem,
default, russian, greek, etc.

2) The default window styles for DIALOG and DIALOGEX resources are wrong.
The WS_POPUP style was always added to the given window styles. This caused
severe problems in WS_CHILD dialogs.

Best regards,

Eric Kohl

----
11-18-2001 Eric Kohl (ekohl@rz-online.de)

* rcparse.y: Added fifth parameter (character set) to FONT statement in
DIALOGEX resources.
Fixed default window styles for DIALOG and DIALOGEX resources.

*resbin.c(bin_to_res_dialog): Fixed read/write code for dialogex resource
data.
(res_to_bin_dialog): Likewise.

*windres.h: Fixed dialog_ex resource data struct.


[-- Attachment #2: windres.diff --]
[-- Type: application/octet-stream, Size: 4148 bytes --]

diff -r -b -u src-orig/binutils/rcparse.y src/binutils/rcparse.y
--- src-orig/binutils/rcparse.y	Sat Nov 17 23:17:36 2001
+++ src/binutils/rcparse.y	Sat Nov 17 23:57:12 2001
@@ -332,7 +332,7 @@
 	      dialog.y = $6;
 	      dialog.width = $7;
 	      dialog.height = $8;
-	      dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU;
+	      dialog.style = WS_POPUP;
 	      dialog.exstyle = $4;
 	      dialog.menu.named = 1;
 	      dialog.class.named = 1;
@@ -353,7 +353,7 @@
 	      dialog.y = $6;
 	      dialog.width = $7;
 	      dialog.height = $8;
-	      dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU;
+	      dialog.style = WS_POPUP;
 	      dialog.exstyle = $4;
 	      dialog.menu.named = 1;
 	      dialog.class.named = 1;
@@ -376,7 +376,7 @@
 	      dialog.y = $6;
 	      dialog.width = $7;
 	      dialog.height = $8;
-	      dialog.style = WS_POPUP | WS_BORDER | WS_SYSMENU;
+	      dialog.style = WS_POPUP;
 	      dialog.exstyle = $4;
 	      dialog.menu.named = 1;
 	      dialog.class.named = 1;
@@ -409,6 +409,7 @@
 	  /* empty */
 	| styles CAPTION QUOTEDSTRING
 	  {
+	    dialog.style |= WS_CAPTION;
 	    unicode_from_ascii ((int *) NULL, &dialog.caption, $3);
 	  }
 	| styles CLASS id
@@ -416,10 +417,10 @@
 	    dialog.class = $3;
 	  }
 	| styles STYLE
-	    { style = dialog.style; }
+	    { style = dialog.style & ~WS_POPUP; }
 	    styleexpr
 	  {
-	    dialog.style = style;
+	    dialog.style |= style;
 	  }
 	| styles EXSTYLE numexpr
 	  {
@@ -431,7 +432,7 @@
 	    dialog.pointsize = $3;
 	    unicode_from_ascii ((int *) NULL, &dialog.font, $5);
 	  }
-	| styles FONT numexpr ',' QUOTEDSTRING cnumexpr cnumexpr
+	| styles FONT numexpr ',' QUOTEDSTRING cnumexpr cnumexpr cnumexpr
 	  {
 	    dialog.style |= DS_SETFONT;
 	    dialog.pointsize = $3;
@@ -442,6 +443,7 @@
 	      {
 		dialog.ex->weight = $6;
 		dialog.ex->italic = $7;
+		dialog.ex->charset = $8;
 	      }
 	  }
 	| styles MENU id
diff -r -b -u src-orig/binutils/resbin.c src/binutils/resbin.c
--- src-orig/binutils/resbin.c	Sat Nov 17 23:17:36 2001
+++ src/binutils/resbin.c	Sat Nov 17 23:57:12 2001
@@ -30,6 +30,7 @@
 
 /* Macros to swap in values.  */
 
+#define get_8(s) (*((unsigned char *)(s)))
 #define get_16(be, s) ((be) ? bfd_getb16 (s) : bfd_getl16 (s))
 #define get_32(be, s) ((be) ? bfd_getb32 (s) : bfd_getl32 (s))
 
@@ -523,6 +524,7 @@
 	{
 	  d->ex->weight = 0;
 	  d->ex->italic = 0;
+	  d->ex->charset = 1; /* default charset */
 	}
     }
   else
@@ -538,7 +540,8 @@
 	  if (length < off + 4)
 	    toosmall (_("dialogex font information"));
 	  d->ex->weight = get_16 (big_endian, data + off);
-	  d->ex->italic = get_16 (big_endian, data + off + 2);
+	  d->ex->italic = get_8 (data + off + 2);
+	  d->ex->charset = get_8 (data + off + 3);
 	  off += 4;
 	}
 
@@ -1252,6 +1255,7 @@
 \f
 /* Macros to swap out values.  */
 
+#define put_8(v, s) (*((unsigned char *)(s)) = (unsigned char)(v))
 #define put_16(be, v, s) ((be) ? bfd_putb16 ((v), (s)) : bfd_putl16 ((v), (s)))
 #define put_32(be, v, s) ((be) ? bfd_putb32 ((v), (s)) : bfd_putl32 ((v), (s)))
 
@@ -1621,12 +1625,14 @@
 	  if (dialog->ex == NULL)
 	    {
 	      put_16 (big_endian, 0, d->data + 2);
-	      put_16 (big_endian, 0, d->data + 4);
+	      put_8 (0, d->data + 4);
+	      put_8 (1, d->data + 5);
 	    }
 	  else
 	    {
 	      put_16 (big_endian, dialog->ex->weight, d->data + 2);
-	      put_16 (big_endian, dialog->ex->italic, d->data + 4);
+	      put_8 (dialog->ex->italic, d->data + 4);
+	      put_8 (dialog->ex->charset, d->data + 5);
 	    }
 	}
 
diff -r -b -u src-orig/binutils/windres.h src/binutils/windres.h
--- src-orig/binutils/windres.h	Sat Nov 17 23:17:36 2001
+++ src/binutils/windres.h	Sat Nov 17 23:57:12 2001
@@ -315,7 +315,9 @@
   /* Font weight.  */
   unsigned short weight;
   /* Whether the font is italic.  */
-  unsigned short italic;
+  unsigned char italic;
+  /* Character set.  */
+  unsigned char charset;
 };
 
 /* Window style flags, from the winsup Defines.h header file.  These

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

end of thread, other threads:[~2002-01-08 18:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-08 11:24 [PATCH] windres bugs Eric Kohl
  -- strict thread matches above, loose matches on Subject: below --
2001-11-08 18:22 [patch] " Eric Kohl
2001-11-18  5:14 ` Eric Kohl

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).