This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
[PATCH] windres bugs - Resubmit
- From: Eric Kohl <ekohl at rz-online dot de>
- To: binutils at sources dot redhat dot com
- Date: Fri, 12 Apr 2002 19:44:06 +0200
- Subject: [PATCH] windres bugs - Resubmit
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
----
* 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.
Index: rcparse.y
===================================================================
RCS file: /cvs/src/src/binutils/rcparse.y,v
retrieving revision 1.12
diff -b -u -p -r1.12 rcparse.y
--- rcparse.y 10 Apr 2002 08:14:27 -0000 1.12
+++ rcparse.y 12 Apr 2002 17:30:44 -0000
@@ -332,7 +332,7 @@ dialog:
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;
@@ -354,7 +354,7 @@ dialog:
dialog.y = $;
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;
@@ -378,7 +378,7 @@ dialog:
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;
@@ -423,7 +423,7 @@ styles:
| styles STYLE
styleexpr
{
- dialog.style = style;
+ dialog.style = (dialog.style & ~WS_POPUP) | style;
}
| styles EXSTYLE numexpr
{
@@ -440,7 +440,7 @@ styles:
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;
style |= DS_SETFONT;
@@ -452,6 +452,7 @@ styles:
{
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.4
diff -b -u -p -r1.4 resbin.c
--- resbin.c 9 Apr 2002 17:14:59 -0000 1.4
+++ resbin.c 12 Apr 2002 17:30:47 -0000
@@ -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))
@@ -528,6 +529,7 @@ bin_to_res_dialog (data, length, big_end
{
d->ex->weight = 0;
d->ex->italic = 0;
+ d->ex->charset = 1; /* Default charset */
}
}
else
@@ -543,7 +545,8 @@ bin_to_res_dialog (data, length, big_end
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;
}
@@ -1257,6 +1260,7 @@ bin_to_res_userdata (data, length, big_e
/* 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)))
@@ -1626,12 +1630,14 @@ res_to_bin_dialog (dialog, big_endian)
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 -b -u -p -r1.6 windres.h
--- windres.h 17 Jul 2001 01:19:19 -0000 1.6
+++ windres.h 12 Apr 2002 17:30:49 -0000
@@ -315,7 +315,9 @@ struct dialog_ex
/* 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