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]

Patch/windres: Fix handling of hex-notation escape sequences in quoted strings


The following windres bug was reported to mingw.org by Tom Bonner


 The resource
     MENUITEM "\xd6ffnen",        IDM_OPEN	
 doesn't work as it should do, instead I have to use
 something like
     MENUITEM "\xd6" "ffnen",        IDM_OPEN	
 (The latter one isn't compatible with MSVC6).
 The problem seems to be the double-f, which is
 interpreted as belonging to the previous escape sequence.
 

Here is a fix and a testcase

2005-10-11  Danny Smith  <dannysmith@users.sourceforge.net>

	* rclex.l (handle quotes): Stop parsing hex notation escaped
	chars after the first two digits,
	* testsuite/binutils-all/windres/escapex-2.rc: New file.
	* testsuite/binutils-all/windres/escapex-2.rsd: Generate.


? testsuite/binutils-all/windres/escapex-2.rc
? testsuite/binutils-all/windres/escapex-2.rsd
Index: rclex.l
===================================================================
RCS file: /cvs/src/src/binutils/rclex.l,v
retrieving revision 1.13
diff -c -3 -p -r1.13 rclex.l
*** rclex.l	8 May 2005 14:17:39 -0000	1.13
--- rclex.l	11 Oct 2005 06:57:57 -0000
*************** handle_quotes (const char *input, unsign
*** 308,313 ****
--- 308,314 ----
    char *ret, *s;
    const char *t;
    int ch;
+   int num_xdigits;
  
    ret = get_string (strlen (input) + 1);
  
*************** handle_quotes (const char *input, unsign
*** 389,395 ****
  	    case 'x':
  	      ++t;
  	      ch = 0;
! 	      while (1)
  		{
  		  if (*t >= '0' && *t <= '9')
  		    ch = (ch << 4) | (*t - '0');
--- 390,400 ----
  	    case 'x':
  	      ++t;
  	      ch = 0;
! 	      /* We only handle single byte chars here.  Make sure
! 		 we finish an escape sequence like "/xB0ABC" after
! 		 the first two digits.  */
! 	      num_xdigits = 2;
! 	      while (num_xdigits--)
  		{
  		  if (*t >= '0' && *t <= '9')
  		    ch = (ch << 4) | (*t - '0');
*** /dev/null	Tue Oct 11 20:01:16 2005
--- testsuite/binutils-all/windres/escapex-2.rc	Tue Oct 11 20:01:09 2005
***************
*** 0 ****
--- 1,5 ----
+ 101 DIALOG DISCARDABLE  0, 0, 186, 95
+ BEGIN
+     LTEXT           "\xB0ABC",-1,23,46,28,8
+ END
+

Send instant messages to your online friends http://au.messenger.yahoo.com 


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