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]

Re: Regression in rcparse.y



> VC98 uses a syntax that wasn't accepted before my change but is
> accepted now (that's why I changed it).  The binary format for
> controls specifies a resource ID or name for that parameter, not a
> string (hence the other part of my change), implying that either is
> accepted.  I suspect that all controls (although I only fixed ICON)
> take either a string *or* a resource ID (bitmap, for example, uses the
> CONTROL keyword but takes a string, except VC98 puts an id there too).

The grammar needs to accept atleast the following four variants

ICON "myicon", 901, 30, 30
ICON "myicon"  901, 30, 30
ICON myicon,   901, 30, 30
ICON 900,      901, 30, 30

The first two are as described in the Microsoft documentation and all
versions of the resource compiler prior to VC98, and the last two are
recent additions to VC98 (but not supported by earlier implementations).

Its probably best to add new rules to the grammar such as

resname:
	  QUOTEDSTRING
          {
	    $$ = $1;
	  }
	| QUOTEDSTRING ','
	  {
	    $$ = $1;
	  }
	| STRING
	  {
	    $$ = $1;
	  }
	;


resref:
	  posnumexpr ','
	  {
	    $$.named = 0;
	    $$.u.id = $1;
	  }
	| resname
	  {
            char *copy, *s;

            /* It seems that resource ID's are forced to upper case.  */
            copy = xstrdup ($1);
            for (s = copy; *s != '\0'; s++)
              if (islower ((unsigned char) *s))
                *s = toupper ((unsigned char) *s);
            res_string_to_id (&$$, copy);
            free (copy);
	  }
	;


Then using these rules, redefine the relevant ICON clauses as

- | ICON id cnumexpr cnumexpr cnumexpr opt_control_data
+ | ICON resref numexpr cnumexpr cnumexpr opt_control_data

Notice that resref includes the trailing comma, so the second parameter
becomes numexpr.  This also makes the existing clauses consistent where
some currently use numexpr and other cnumexpr.


> For the current source, I suggest following the id with an optcnumexpr
> rather than the cnumexpr already there:
> -	| ICON id cnumexpr cnumexpr cnumexpr opt_control_data
> +	| ICON id optcnumexpr cnumexpr cnumexpr opt_control_data

Unfortunately, optcnumexpr make the entire comma and following optional
rather than just the comma optional.  It also doesn't cure the problem
that pre-VC98 resource files refer to resources by quoted strings, rather
than by unquoted strings or numbers.


> Would this work with your resources?

Back in December I converted all of my resources from the second variant
above to the first to allow them to be compiled with both the GNU and the
Microsoft tools.  The proto-patch above would allow both to be used, but
I'd be content with just the first variant, as a portable subset.

Roger
--
Roger Sayle,                         E-mail: roger@metaphorics.com
Bioinformatics Group, Metaphorics,   WWW: http://www.metaphorics.com/
Office 104, 441 Greg Avenue,         Tel: (+1) 505-954-3281
Santa Fe, New Mexico, 87501.         Fax: (+1) 505-989-1200


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