This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Windres problem with Boling book example
- From: Nick Clifton <nickc at redhat dot com>
- To: Danny Backx <danny dot backx at scarlet dot be>
- Cc: binutils <binutils at sourceware dot org>
- Date: Fri, 24 Nov 2006 14:17:16 +0000
- Subject: Re: Windres problem with Boling book example
- References: <1164309392.4269.5.camel@dannypc>
Hi Danny,
One of the examples in the Boling book has lines in the resource file
that look like this :
aboutbox DIALOG discardable 10, 10, 132, 40
The problem is that binutils's windres appears to expect all the
keywords such as DISCARDABLE to be in upper case.
Do you know if windres accepts mixed case keywords as well, eg
"DiScArDaBlE", or just either all-upper-case or all-lower-case ?
A trivial fix for src/binutils/binutils/rclex.l is below. Obviously this
fixes only that keyword, I'd expect all of them need to be treated in
the same way.
It would probably be neater to move the keyword recognition code into
the string recognising code and to just use strcasecmp(). eg:
[A-Za-z][^ ,\t\r\n]* {
char * s;
int i;
struct { char * word; int token } keywords[] =
{
{ "BLOCK", BLOCK },
{ "DISCARDABLE", DISCARDABLE },
...
{ NULL, STRING }
};
s = get_string (strlen (yytext) + 1);
for (i = 0; keywords[i].word != NULL; i++)
if (strcasecmp (keywords[i].word, s) == 0)
break;
if (keywords[i].word == NULL)
{
strcpy (s, yytext);
yylval.s = s;
}
MAYBE_RETURN (keywords[i].token);
}
This looks pretty lame, there must be a reason why this isn't
implemented like this to begin with. Does anyone see a reason ?
The reason is probably that the syntax that the original coders had to
work with only showed upper case keywords.
Thanks,
Danny
dannypc: {75} svn diff rclex.l
Index: rclex.l
===================================================================
--- rclex.l (revision 819)
+++ rclex.l (working copy)
@@ -151,7 +151,7 @@
"IMPURE" { MAYBE_RETURN (IMPURE); }
"PRELOAD" { MAYBE_RETURN (PRELOAD); }
"LOADONCALL" { MAYBE_RETURN (LOADONCALL); }
-"DISCARDABLE" { MAYBE_RETURN (DISCARDABLE); }
+[dD][iI][sS][cC][aA][rR][dD][aA][bB][lL][eE] { MAYBE_RETURN
(DISCARDABLE); }
"NOT" { MAYBE_RETURN (NOT); }
"BLOCK"[ \t\n]*"\""[^\#\n]*"\"" {