multiline strings in .rc files (was: Implementation of "start.exe", take 3)

Dan Kegel dank at kegel.com
Sat Jan 18 15:45:37 CST 2003


Dan Kegel wrote:
>>> * multiline strings from resource file are displayed with extra newline
>>> between lines in wine, but not in windows.  To reproduce, build
>>> either as winelib app or build under MSVC6, then run in wine;
>>> usage message comes out double-spaced.  Help!
>>
>   Unfortunately, if I do
>  STRING_FOO,  "This is a two-line \
> string"
> it looks good in Wine, but it's run together on one line in Windows.
> Conversely, if I do
>  STRING_FOO,   "This is a two-line \n \
> string"
> it looks good in Windows, but it's double-spaced in Wine.
> 
> Something's fishy here.  Our .rc files should be
> usable in both environments without change.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tools/rc_490l.asp
says that \ is a simple line-continuation character.  Thus \ at the
end of a line in the .rc file should not insert a newline
in the resource, I think.  And it looks like our resource compiler
is violating this.  Compiling the stringtable entry

1, "xx\
yy"

yields different results with our compiler and the one in vc6:

$ tools/wrc/wrc rsrc.rc -o x.res

$ hexdump -C x.res
00000000  00 00 00 00 20 00 00 00  ff ff 00 00 ff ff 00 00  |.... ...........|
00000010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000020  2a 00 00 00 20 00 00 00  ff ff 06 00 ff ff 07 00  |*... ...........|
00000030  00 00 00 00 00 10 09 04  00 00 00 00 00 00 00 00  |................|
00000040  00 00 00 00 00 00 00 00  00 00 05 00 78 00 78 00  |............x.x.|
00000050  0a 00 79 00 79 00 00 00  00 00 00 00 00 00 00 00  |..y.y...........|
00000060  00 00 00 00 00 00 00 00  00 00 00 00              |............|
0000006c

$ wine /dos/c/Program\ Files/Microsoft\ Visual\ Studio/Common/MSDev98/bin/rc.exe /r /fo y.res rsrc.rc

$ hexdump -C y.res
00000000  00 00 00 00 20 00 00 00  ff ff 00 00 ff ff 00 00  |.... ...........|
00000010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000020  28 00 00 00 20 00 00 00  ff ff 06 00 ff ff 07 00  |(... ...........|
00000030  00 00 00 00 30 10 09 04  00 00 00 00 00 00 00 00  |....0...........|
00000040  00 00 00 00 00 00 00 00  00 00 04 00 78 00 78 00  |............x.x.|
00000050  79 00 79 00 00 00 00 00  00 00 00 00 00 00 00 00  |y.y.............|
00000060  00 00 00 00 00 00 00 00                           |........|

After squinting at our source, I came up with a one-line patch
to fix our resource compiler (attached).
If that looks good, I can do a patch that fixes up all our .rc files
that expected backslash to behave in a nonstandard way.
- Dan

-- 
Dan Kegel
http://www.kegel.com
http://counter.li.org/cgi-bin/runscript/display-person.cgi?user=78045
-------------- next part --------------
Index: tools/wrc/parser.l
===================================================================
RCS file: /home/wine/wine/tools/wrc/parser.l,v
retrieving revision 1.22
diff -d -u -r1.22 parser.l
--- tools/wrc/parser.l	15 Aug 2002 21:57:36 -0000	1.22
+++ tools/wrc/parser.l	18 Jan 2003 21:20:42 -0000
@@ -499,7 +499,8 @@
 			}
 <yystr>\\x[0-9a-fA-F]	{  yyerror("Invalid hex escape sequence '%s'", yytext); }
 
-<yystr>\\[0-9]+		yyerror("Bad escape secuence");
+<yystr>\\[0-9]+		yyerror("Bad escape sequence");
+<yystr>\\\n		;	/* backslash at end of line just continues string on next line */
 <yystr>\\a		addcchar('\a');
 <yystr>\\b		addcchar('\b');
 <yystr>\\f		addcchar('\f');


More information about the wine-devel mailing list