mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-27 12:10:36 +02:00
* patch by Dean Mustakinov to improve commandline quote handling on Windows, resolves #40189
This commit is contained in:
parent
ec7f2e6871
commit
e74d89ce62
@ -223,7 +223,7 @@ var
|
||||
buf: array[0..MaxPathLen] of WideChar;
|
||||
i, len, argvw_size: longint;
|
||||
s: RawByteString;
|
||||
quote: boolean;
|
||||
quote: char;
|
||||
begin
|
||||
// Get the unicode command line
|
||||
CmdLineW:=GetCommandLineW;
|
||||
@ -248,14 +248,14 @@ begin
|
||||
Inc(pw, len);
|
||||
// Parse the command line
|
||||
argc:=0;
|
||||
quote:=False;
|
||||
quote:=' ';
|
||||
while True do
|
||||
begin
|
||||
c:=CmdLineW^;
|
||||
Inc(CmdLineW);
|
||||
case c of
|
||||
#0..#32:
|
||||
if not quote or (c = #0) then
|
||||
if (quote = ' ') or (c = #0) then
|
||||
begin
|
||||
// Are there any chars of an argument?
|
||||
if argvw[argc] <> pw then
|
||||
@ -283,8 +283,35 @@ begin
|
||||
end;
|
||||
'"':
|
||||
begin
|
||||
quote:=not quote;
|
||||
continue;
|
||||
if quote<>'''' then
|
||||
begin
|
||||
if CmdLineW^<>'"' then
|
||||
begin
|
||||
if quote='"' then
|
||||
quote:=' '
|
||||
else
|
||||
quote:='"';
|
||||
continue;
|
||||
end
|
||||
else
|
||||
Inc(CmdLineW);
|
||||
end;
|
||||
end;
|
||||
'''':
|
||||
begin
|
||||
if quote<>'"' then
|
||||
begin
|
||||
if CmdLineW^<>'''' then
|
||||
begin
|
||||
if quote='''' then
|
||||
quote:=' '
|
||||
else
|
||||
quote:='''';
|
||||
continue;
|
||||
end
|
||||
else
|
||||
Inc(CmdLineW);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
// Ignore the first argument, it is already copied
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user