Still no luck on command line parse
lawson_whitney at juno.com
lawson_whitney at juno.com
Fri Feb 1 21:06:19 CST 2002
On Thu, 31 Jan 2002, Bill Medland wrote:
> I have a little test program that I threw together for investigating the
> DrawTextEx function. (You can find it in the patches but Alexandre hasn't
> accepted it yet). It takes input from the szCommandLine passed to WinMain.
> Under windows I can pass a set of arguments, including a string enclosed in
> quotes. I use those quotes to recognise which part of szCommandLine is "the
> string". (Yes, I know it's lazy and bad argument processing). However
> under Wine the quotes don't get through and if I escape them with \ then the
> \ goes through too (which messes up "the string"). I haven't looked yet but
> there is something weird in there. I guess one problem is that the quotes
> will be removed by the shell before even reaching Wine.
>
> Bill
>
True. If wine sees the effect of a quote the shell has removed (spaces
in an argument), it will quote the string with \", because if it
doesn't, the C runtime will parse the spaces:
[whit at giftie cmdl]$ wine cmdl.exe "quoted string"
arg 0: /cmdl.exe/
arg 1: /quoted string/
[whit at giftie cmdl]$ wine cmdl.exe \"quoted string\"
arg 0: /cmdl.exe/
arg 1: /"quoted/
arg 2: /string"/
[whit at giftie cmdl]$ wine --dll msvcrt=n cmdl.exe "quoted string"
arg 0: /cmdl.exe/
arg 1: /quoted string/
[whit at giftie cmdl]$ wine --dll msvcrt=n cmdl.exe \"quoted string\"
arg 0: /cmdl.exe/
arg 1: /"quoted/
arg 2: /string"/
[whit at giftie cmdl]$
I know, in my example, it is actually the unix shell that is breaking
the argument in half, but I am confident the windows C runtime startup
routines do the same. Unlike the unix shell, they only preserve spaces
in an argument quoted by \", and treat " as an ordinary character.
Just follow the URL earlier in this thread. It is where I got the
program I compiled with lcc-win as cmdl.exe:
#include <stdio.h>
main(int argc, char **argv)
{
int i;
for (i = 0; i < argc; i++)
printf("arg %d: /%s/\n", i, argv[i]);
}
Lawson
More information about the wine-users
mailing list