This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: windres: serious bug


"Dimitrie O. Paun" <dimi at intelliware dot ca> writes:

> The latest development in this saga is a nasty windres bug
> which has a _very_ ugly workaround. Here is a sample of what
> needs to happen to work around it:
> 
> -    CONTROL         108,IDC_STATIC,"Static",SS_BITMAP,11,11,83,162,
> +    CONTROL
> +#ifndef __MINGW32__
> +                    108,
> +#endif
> +                    IDC_STATIC,"Static",SS_BITMAP,11,11,83,162,
> 
> This is what people had to say about it:
> 
>     per Marco Cocco based on microsoft documentation and based on my reading
>     of the msdn pages a resource compiler/decompiler needs to be able to 
>     handle both strings and numeric types for the type and name fields, 
>     windres is therefore broken.
> 
>     borland resource workshop 4 (c) 1991, 1993 supported this.
> 
> Due to the ugliness of the solution, people decided to postpone this bug
> for a fixed version of windres. However, we're still looking to catch the
> Mozilla 1.4beta, and so I was wondering if someone can help out here.
> 
> In all honesty, given the lengthy FSF process, I was hoping someone who can
> contribute code looks into this one, so we can get a solution out there
> soon.

Here is an untested patch.  I haven't even run it, although it does
compile.  It should point out the right places to change.

Ian

Index: rcparse.y
===================================================================
RCS file: /cvs/src/src/binutils/rcparse.y,v
retrieving revision 1.16
diff -u -p -r1.16 rcparse.y
--- rcparse.y	14 Aug 2002 10:44:54 -0000	1.16
+++ rcparse.y	21 Mar 2003 07:38:35 -0000
@@ -135,11 +135,11 @@ static unsigned long class;
 %type <vervar> vertrans
 %type <res_info> suboptions memflags_move_discard memflags_move
 %type <memflags> memflag
-%type <id> id resref
+%type <id> id optresidc resref
 %type <il> exstyle parennumber
 %type <il> numexpr posnumexpr cnumexpr optcnumexpr cposnumexpr
 %type <is> acc_options acc_option menuitem_flags menuitem_flag
-%type <s> optstringc file_name resname
+%type <s> file_name resname
 %type <i> sizednumexpr sizedposnumexpr
 
 %left '|'
@@ -596,7 +596,7 @@ control:
 	  {
 	    $$ = $3;
 	  }
-	| CONTROL optstringc numexpr cnumexpr control_styleexpr cnumexpr
+	| CONTROL optresidc numexpr cnumexpr control_styleexpr cnumexpr
 	    cnumexpr cnumexpr cnumexpr optcnumexpr opt_control_data
 	  {
 	    $$ = define_control ($2, $3, $6, $7, $8, $9, $4, style, $10);
@@ -607,7 +607,7 @@ control:
 		$$->data = $11;
 	      }
 	  }
-	| CONTROL optstringc numexpr cnumexpr control_styleexpr cnumexpr
+	| CONTROL optresidc numexpr cnumexpr control_styleexpr cnumexpr
 	    cnumexpr cnumexpr cnumexpr cnumexpr cnumexpr opt_control_data
 	  {
 	    $$ = define_control ($2, $3, $6, $7, $8, $9, $4, style, $10);
@@ -616,7 +616,7 @@ control:
 	    $$->help = $11;
 	    $$->data = $12;
 	  }
-	| CONTROL optstringc numexpr ',' QUOTEDSTRING control_styleexpr
+	| CONTROL optresidc numexpr ',' QUOTEDSTRING control_styleexpr
 	    cnumexpr cnumexpr cnumexpr cnumexpr optcnumexpr opt_control_data
 	  {
 	    $$ = define_control ($2, $3, $7, $8, $9, $10, 0, style, $11);
@@ -629,7 +629,7 @@ control:
 	    $$->class.named = 1;
   	    unicode_from_ascii (&$$->class.u.n.length, &$$->class.u.n.name, $5);
 	  }
-	| CONTROL optstringc numexpr ',' QUOTEDSTRING control_styleexpr
+	| CONTROL optresidc numexpr ',' QUOTEDSTRING control_styleexpr
 	    cnumexpr cnumexpr cnumexpr cnumexpr cnumexpr cnumexpr opt_control_data
 	  {
 	    $$ = define_control ($2, $3, $7, $8, $9, $10, 0, style, $11);
@@ -809,13 +809,13 @@ control:
 	  {
 	    $$ = $3;
 	  }
-	| USERBUTTON QUOTEDSTRING ',' numexpr ',' numexpr ',' numexpr ','
+	| USERBUTTON resref numexpr ',' numexpr ',' numexpr ','
 	    numexpr ',' numexpr ',' 
 	    { style = WS_CHILD | WS_VISIBLE; }
 	    styleexpr optcnumexpr
 	  {
-	    $$ = define_control ($2, $4, $6, $8, $10, $12, CTL_BUTTON,
-				 style, $16);
+	    $$ = define_control ($2, $3, $5, $7, $9, $11, CTL_BUTTON,
+				 style, $15);
 	  }
 	;
 
@@ -827,7 +827,7 @@ control:
    style.  CLASS is the class of the control.  */
 
 control_params:
-	  optstringc numexpr cnumexpr cnumexpr cnumexpr cnumexpr
+	  optresidc numexpr cnumexpr cnumexpr cnumexpr cnumexpr
 	    opt_control_data
 	  {
 	    $$ = define_control ($1, $2, $3, $4, $5, $6, class,
@@ -839,7 +839,7 @@ control_params:
 		$$->data = $7;
 	      }
 	  }
-	| optstringc numexpr cnumexpr cnumexpr cnumexpr cnumexpr
+	| optresidc numexpr cnumexpr cnumexpr cnumexpr cnumexpr
 	    control_params_styleexpr optcnumexpr opt_control_data
 	  {
 	    $$ = define_control ($1, $2, $3, $4, $5, $6, class, style, $8);
@@ -850,7 +850,7 @@ control_params:
 		$$->data = $9;
 	      }
 	  }
-	| optstringc numexpr cnumexpr cnumexpr cnumexpr cnumexpr
+	| optresidc numexpr cnumexpr cnumexpr cnumexpr cnumexpr
 	    control_params_styleexpr cnumexpr cnumexpr opt_control_data
 	  {
 	    $$ = define_control ($1, $2, $3, $4, $5, $6, class, style, $8);
@@ -861,18 +861,23 @@ control_params:
 	  }
 	;
 
-optstringc:
+optresidc:
 	  /* empty */
 	  {
-	    $$ = NULL;
+	    res_string_to_id(&$$, "");
+	  }
+	| posnumexpr ','
+	  {
+	    $$.named = 0;
+	    $$.u.id = $1;
 	  }
 	| QUOTEDSTRING
 	  {
-	    $$ = $1;
+	    res_string_to_id(&$$, $1);
 	  }
 	| QUOTEDSTRING ','
 	  {
-	    $$ = $1;
+	    res_string_to_id(&$$, $1);
 	  }
 	;
 
Index: resrc.c
===================================================================
RCS file: /cvs/src/src/binutils/resrc.c,v
retrieving revision 1.20
diff -u -p -r1.20 resrc.c
--- resrc.c	23 May 2002 04:11:57 -0000	1.20
+++ resrc.c	21 Mar 2003 07:38:36 -0000
@@ -818,8 +818,8 @@ define_dialog (id, resinfo, dialog)
    merely allocates and fills in a structure.  */
 
 struct dialog_control *
-define_control (text, id, x, y, width, height, class, style, exstyle)
-     const char *text;
+define_control (iid, id, x, y, width, height, class, style, exstyle)
+     struct res_id iid;
      unsigned long id;
      unsigned long x;
      unsigned long y;
@@ -842,9 +842,7 @@ define_control (text, id, x, y, width, h
   n->height = height;
   n->class.named = 0;
   n->class.u.id = class;
-  if (text == NULL)
-    text = "";
-  res_string_to_id (&n->text, text);
+  n->text = iid;
   n->data = NULL;
   n->help = 0;
 
@@ -864,9 +862,11 @@ define_icon_control (iid, id, x, y, styl
      struct dialog_ex *ex;
 {
   struct dialog_control *n;
+  struct res_id tid;
   if (style == 0)
     style = SS_ICON | WS_CHILD | WS_VISIBLE;
-  n = define_control (0, id, x, y, 0, 0, CTL_STATIC, style, exstyle);
+  res_string_to_id (&tid, "");
+  n = define_control (tid, id, x, y, 0, 0, CTL_STATIC, style, exstyle);
   n->text = iid;
   if (help && !ex)
     rcparse_warning (_("help ID requires DIALOGEX"));
Index: windres.h
===================================================================
RCS file: /cvs/src/src/binutils/windres.h,v
retrieving revision 1.8
diff -u -p -r1.8 windres.h
--- windres.h	25 May 2002 12:51:38 -0000	1.8
+++ windres.h	21 Mar 2003 07:38:36 -0000
@@ -813,7 +813,7 @@ extern void define_cursor
 extern void define_dialog
   PARAMS ((struct res_id, const struct res_res_info *, const struct dialog *));
 extern struct dialog_control *define_control
-  PARAMS ((const char *, unsigned long, unsigned long, unsigned long,
+  PARAMS ((struct res_id, unsigned long, unsigned long, unsigned long,
 	   unsigned long, unsigned long, unsigned long, unsigned long,
 	   unsigned long));
 extern struct dialog_control *define_icon_control


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]