This is the mail archive of the binutils@sourceware.org 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 problem with Boling book example


I've attached the patch.

As I already said this uses the sample code that Nick wrote. I ended up
making two changes to it :
- fix the small bug
- extend the lex pattern so more characters stop a keyword

I've run eight of the Boling book example through this. I can get most
of them to process correctly; after finding more literals that we don't
yet have in our include files. (Our project is in the process of
building up some of the include files, see
http://cegcc.sourceforge.net). That doesn't interfere with whether these
files are processed correctly though.

A couple of the files I tried don't process yet, but the original
windres behaves in the same way, so I am confident that this behaviour
is unrelated to this patch.

One remark: windres is rather bad at describing the syntax errors it
reports; it basically says something like
  arm-wince-mingw32ce-windres: gapishow.rc:82: syntax error
without further explanation. I've not tried to address this.

A proposed ChangeLog entry, if this patch is accepted :

2006-11-27  Danny Backx <dannybackx@users.sourceforge.net>

	* binutils/rclex.l : Accept keywords in lower and mixed case,
	not just upper case. Based on code by Nick Clifton.

-- Danny

On Sat, 2006-11-25 at 11:22 +0100, Danny Backx wrote:
> On Sat, 2006-11-25 at 09:24 +0000, Nick Clifton wrote:
> > Hi Dave,
> > 
> > >>>> 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 ?
> > >> It doesn't, as you would expect by reading the code. It just accepts all
> > >> upper case.
> > > 
> > >   I think it could reasonably be inferred that Nick meant to ask after
> > > windows' rc.exe and windres was a slip of the finger, no?
> > 
> > It was.  Doh!
> > 
> > So - Danny - how does rc.exe behave ?
> 
> This required kicking my kids off the Windows PC :-)
> 
> I've built the chap06/dlgdemo application with evc 4, and it did that
> flawlessly. Then I tweaked some of the "discardable" keywords so they
> contain mixed case as you asked. The resulting rc file contains lines
> such as shown here :
> 
> dannypc: {41} fgrep -i disc *.rc
> ID_MENU MENU DISCARDABLE
> ID_BTNPAGE DIALOG disCARdable 0, 0, 125,  90
> ID_EDITPAGE DIALOG DisCarDable 0, 0,  80,  80
> ID_LISTPAGE DIALOG discardable 0, 0,  125,  80
> ID_STATPAGE DIALOG discardable 0, 0, 130,  80
> <cut>
> 
> evc4 still managed to build the code.
> 
> I was inclined to reply before doing this, because the Boling book is
> published by Microsoft Press. All of the examples in there are certain
> to compile. But now we have more info: it supports mixed case keywords.
> 
> 	Danny
-- 
Danny Backx ; danny.backx - at - scarlet.be ; http://danny.backx.info
Index: binutils/binutils/rclex.l
===================================================================
--- binutils/binutils/rclex.l	(revision 819)
+++ binutils/binutils/rclex.l	(working copy)
@@ -77,82 +77,104 @@
 
 %%
 
-"BEGIN"			{ MAYBE_RETURN (BEG); }
+[A-Za-z][^ ,\t\r\n();,]* {
+	char	*s;
+	int	i;
+
+	struct {
+		char	*word;
+		int	token;
+	} keywords[] = {
+		{ "BEGIN", BEG },
+		{ "END", END },
+		{ "ACCELERATORS", ACCELERATORS },
+		{ "VIRTKEY", VIRTKEY },
+		{ "ASCII", ASCII },
+		{ "NOINVERT", NOINVERT },
+		{ "SHIFT", SHIFT },
+		{ "CONTROL", CONTROL },
+		{ "ALT", ALT },
+		{ "BITMAP", BITMAP },
+		{ "CURSOR", CURSOR },
+		{ "DIALOG", DIALOG },
+		{ "DIALOGEX", DIALOGEX },
+		{ "EXSTYLE", EXSTYLE },
+		{ "CAPTION", CAPTION },
+		{ "CLASS", CLASS },
+		{ "STYLE", STYLE },
+		{ "AUTO3STATE", AUTO3STATE },
+		{ "AUTOCHECKBOX", AUTOCHECKBOX },
+		{ "AUTORADIOBUTTON", AUTORADIOBUTTON },
+		{ "CHECKBOX", CHECKBOX },
+		{ "COMBOBOX", COMBOBOX },
+		{ "CTEXT", CTEXT },
+		{ "DEFPUSHBUTTON", DEFPUSHBUTTON },
+		{ "EDITTEXT", EDITTEXT },
+		{ "GROUPBOX", GROUPBOX },
+		{ "LISTBOX", LISTBOX },
+		{ "LTEXT", LTEXT },
+		{ "PUSHBOX", PUSHBOX },
+		{ "PUSHBUTTON", PUSHBUTTON },
+		{ "RADIOBUTTON", RADIOBUTTON },
+		{ "RTEXT", RTEXT },
+		{ "SCROLLBAR", SCROLLBAR },
+		{ "STATE3", STATE3 },
+		{ "USERBUTTON", USERBUTTON },
+		{ "BEDIT", BEDIT },
+		{ "HEDIT", HEDIT },
+		{ "IEDIT", IEDIT },
+		{ "FONT", FONT },
+		{ "ICON", ICON },
+		{ "LANGUAGE", LANGUAGE },
+		{ "CHARACTERISTICS", CHARACTERISTICS },
+		{ "VERSION", VERSIONK },
+		{ "MENU", MENU },
+		{ "MENUEX", MENUEX },
+		{ "MENUITEM", MENUITEM },
+		{ "SEPARATOR", SEPARATOR },
+		{ "POPUP", POPUP },
+		{ "CHECKED", CHECKED },
+		{ "GRAYED", GRAYED },
+		{ "HELP", HELP },
+		{ "INACTIVE", INACTIVE },
+		{ "MENUBARBREAK", MENUBARBREAK },
+		{ "MENUBREAK", MENUBREAK },
+		{ "MESSAGETABLE", MESSAGETABLE },
+		{ "RCDATA", RCDATA },
+		{ "STRINGTABLE", STRINGTABLE },
+		{ "VERSIONINFO", VERSIONINFO },
+		{ "FILEVERSION", FILEVERSION },
+		{ "PRODUCTVERSION", PRODUCTVERSION },
+		{ "FILEFLAGSMASK", FILEFLAGSMASK },
+		{ "FILEFLAGS", FILEFLAGS },
+		{ "FILEOS", FILEOS },
+		{ "FILETYPE", FILETYPE },
+		{ "FILESUBTYPE", FILESUBTYPE },
+		{ "VALUE", VALUE },
+		{ "MOVEABLE", MOVEABLE },
+		{ "FIXED", FIXED },
+		{ "PURE", PURE },
+		{ "IMPURE", IMPURE },
+		{ "PRELOAD", PRELOAD },
+		{ "LOADONCALL", LOADONCALL },
+		{ "DISCARDABLE", DISCARDABLE },
+		{ "NOT", NOT },
+		{ NULL, STRING }
+	};
+
+	s = get_string (strlen (yytext) + 1);
+	for (i=0; keywords[i].word != NULL; i++)
+		if (strcasecmp (keywords[i].word, yytext) == 0)
+			break;
+	if (keywords[i].word == 0) {
+		strcpy (s, yytext);
+		yylval.s = s;
+	}
+	MAYBE_RETURN (keywords[i].token);
+}
+
 "{"			{ MAYBE_RETURN (BEG); }
-"END"			{ MAYBE_RETURN (END); }
 "}"			{ MAYBE_RETURN (END); }
-"ACCELERATORS"		{ MAYBE_RETURN (ACCELERATORS); }
-"VIRTKEY"		{ MAYBE_RETURN (VIRTKEY); }
-"ASCII"			{ MAYBE_RETURN (ASCII); }
-"NOINVERT"		{ MAYBE_RETURN (NOINVERT); }
-"SHIFT"			{ MAYBE_RETURN (SHIFT); }
-"CONTROL"		{ MAYBE_RETURN (CONTROL); }
-"ALT"			{ MAYBE_RETURN (ALT); }
-"BITMAP"		{ MAYBE_RETURN (BITMAP); }
-"CURSOR"		{ MAYBE_RETURN (CURSOR); }
-"DIALOG"		{ MAYBE_RETURN (DIALOG); }
-"DIALOGEX"		{ MAYBE_RETURN (DIALOGEX); }
-"EXSTYLE"		{ MAYBE_RETURN (EXSTYLE); }
-"CAPTION"		{ MAYBE_RETURN (CAPTION); }
-"CLASS"			{ MAYBE_RETURN (CLASS); }
-"STYLE"			{ MAYBE_RETURN (STYLE); }
-"AUTO3STATE"		{ MAYBE_RETURN (AUTO3STATE); }
-"AUTOCHECKBOX"		{ MAYBE_RETURN (AUTOCHECKBOX); }
-"AUTORADIOBUTTON"	{ MAYBE_RETURN (AUTORADIOBUTTON); }
-"CHECKBOX"		{ MAYBE_RETURN (CHECKBOX); }
-"COMBOBOX"		{ MAYBE_RETURN (COMBOBOX); }
-"CTEXT"			{ MAYBE_RETURN (CTEXT); }
-"DEFPUSHBUTTON"		{ MAYBE_RETURN (DEFPUSHBUTTON); }
-"EDITTEXT"		{ MAYBE_RETURN (EDITTEXT); }
-"GROUPBOX"		{ MAYBE_RETURN (GROUPBOX); }
-"LISTBOX"		{ MAYBE_RETURN (LISTBOX); }
-"LTEXT"			{ MAYBE_RETURN (LTEXT); }
-"PUSHBOX"		{ MAYBE_RETURN (PUSHBOX); }
-"PUSHBUTTON"		{ MAYBE_RETURN (PUSHBUTTON); }
-"RADIOBUTTON"		{ MAYBE_RETURN (RADIOBUTTON); }
-"RTEXT"			{ MAYBE_RETURN (RTEXT); }
-"SCROLLBAR"		{ MAYBE_RETURN (SCROLLBAR); }
-"STATE3"		{ MAYBE_RETURN (STATE3); }
-"USERBUTTON"		{ MAYBE_RETURN (USERBUTTON); }
-"BEDIT"			{ MAYBE_RETURN (BEDIT); }
-"HEDIT"			{ MAYBE_RETURN (HEDIT); }
-"IEDIT"			{ MAYBE_RETURN (IEDIT); }
-"FONT"			{ MAYBE_RETURN (FONT); }
-"ICON"			{ MAYBE_RETURN (ICON); }
-"LANGUAGE"		{ MAYBE_RETURN (LANGUAGE); }
-"CHARACTERISTICS"	{ MAYBE_RETURN (CHARACTERISTICS); }
-"VERSION"		{ MAYBE_RETURN (VERSIONK); }
-"MENU"			{ MAYBE_RETURN (MENU); }
-"MENUEX"		{ MAYBE_RETURN (MENUEX); }
-"MENUITEM"		{ MAYBE_RETURN (MENUITEM); }
-"SEPARATOR"		{ MAYBE_RETURN (SEPARATOR); }
-"POPUP"			{ MAYBE_RETURN (POPUP); }
-"CHECKED"		{ MAYBE_RETURN (CHECKED); }
-"GRAYED"		{ MAYBE_RETURN (GRAYED); }
-"HELP"			{ MAYBE_RETURN (HELP); }
-"INACTIVE"		{ MAYBE_RETURN (INACTIVE); }
-"MENUBARBREAK"		{ MAYBE_RETURN (MENUBARBREAK); }
-"MENUBREAK"		{ MAYBE_RETURN (MENUBREAK); }
-"MESSAGETABLE"		{ MAYBE_RETURN (MESSAGETABLE); }
-"RCDATA"		{ MAYBE_RETURN (RCDATA); }
-"STRINGTABLE"		{ MAYBE_RETURN (STRINGTABLE); }
-"VERSIONINFO"		{ MAYBE_RETURN (VERSIONINFO); }
-"FILEVERSION"		{ MAYBE_RETURN (FILEVERSION); }
-"PRODUCTVERSION"	{ MAYBE_RETURN (PRODUCTVERSION); }
-"FILEFLAGSMASK"		{ MAYBE_RETURN (FILEFLAGSMASK); }
-"FILEFLAGS"		{ MAYBE_RETURN (FILEFLAGS); }
-"FILEOS"		{ MAYBE_RETURN (FILEOS); }
-"FILETYPE"		{ MAYBE_RETURN (FILETYPE); }
-"FILESUBTYPE"		{ MAYBE_RETURN (FILESUBTYPE); }
-"VALUE"			{ MAYBE_RETURN (VALUE); }
-"MOVEABLE"		{ MAYBE_RETURN (MOVEABLE); }
-"FIXED"			{ MAYBE_RETURN (FIXED); }
-"PURE"			{ MAYBE_RETURN (PURE); }
-"IMPURE"		{ MAYBE_RETURN (IMPURE); }
-"PRELOAD"		{ MAYBE_RETURN (PRELOAD); }
-"LOADONCALL"		{ MAYBE_RETURN (LOADONCALL); }
-"DISCARDABLE"		{ MAYBE_RETURN (DISCARDABLE); }
-"NOT"			{ MAYBE_RETURN (NOT); }
 
 "BLOCK"[ \t\n]*"\""[^\#\n]*"\"" {
 			  char *s, *send;
@@ -217,21 +239,6 @@
 			    }
 			}
 
-[A-Za-z][^ ,\t\r\n]*	{
-			  char *s;
-
-			  /* I rejected comma in a string in order to
-			     handle VIRTKEY, CONTROL in an accelerator
-			     resource.  This means that an unquoted
-			     file name can not contain a comma.  I
-			     don't know what rc permits.  */
-
-			  s = get_string (strlen (yytext) + 1);
-			  strcpy (s, yytext);
-			  yylval.s = s;
-			  MAYBE_RETURN (STRING);
-			}
-
 [\n]			{ ++rc_lineno; }
 [ \t\r]+		{ /* ignore whitespace */ }
 .			{ MAYBE_RETURN (*yytext); }

Attachment: signature.asc
Description: This is a digitally signed message part


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