mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-15 12:09:18 +02:00
Better construction of commandline argv
This commit is contained in:
parent
42780da22f
commit
5dd3badc3e
@ -219,12 +219,8 @@ end;
|
|||||||
function paramstr(l : longint) : string;
|
function paramstr(l : longint) : string;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
if (l>=0) and (l+1<=argc) then
|
||||||
if (l>0) and (l+1<=argc) then
|
|
||||||
paramstr:=strpas(argv[l])
|
paramstr:=strpas(argv[l])
|
||||||
else
|
|
||||||
if l=0 then
|
|
||||||
paramstr:=strpas(GetCommandFile)
|
|
||||||
else
|
else
|
||||||
paramstr:='';
|
paramstr:='';
|
||||||
end;
|
end;
|
||||||
@ -677,8 +673,16 @@ var
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
{ create commandline, it starts with the executed filename which is argv[0] }
|
{ create commandline, it starts with the executed filename which is argv[0] }
|
||||||
cmdline:=GetCommandLine;
|
{ Win32 passes the command NOT via the args, but via getmodulefilename}
|
||||||
count:=0;
|
count:=0;
|
||||||
|
cmdline:=getcommandfile;
|
||||||
|
Arglen:=0;
|
||||||
|
while (cmdline[Arglen]<>#0) do
|
||||||
|
Inc(ArgLen);
|
||||||
|
getmem(argsbuf[count],arglen);
|
||||||
|
move(cmdline^,argsbuf[count]^,arglen);
|
||||||
|
{ Now skip the first one }
|
||||||
|
cmdline:=GetCommandLine;
|
||||||
repeat
|
repeat
|
||||||
{ skip leading spaces }
|
{ skip leading spaces }
|
||||||
while cmdline^ in [' ',#9,#13] do
|
while cmdline^ in [' ',#9,#13] do
|
||||||
@ -700,11 +704,15 @@ begin
|
|||||||
argstart:=cmdline;
|
argstart:=cmdline;
|
||||||
while (cmdline^<>#0) and not(cmdline^ in quote) do
|
while (cmdline^<>#0) and not(cmdline^ in quote) do
|
||||||
inc(longint(cmdline));
|
inc(longint(cmdline));
|
||||||
|
{ Don't copy the first one, it is already there.}
|
||||||
|
If Count<>0 then
|
||||||
|
begin
|
||||||
{ reserve some memory }
|
{ reserve some memory }
|
||||||
arglen:=cmdline-argstart;
|
arglen:=cmdline-argstart;
|
||||||
getmem(argsbuf[count],arglen+1);
|
getmem(argsbuf[count],arglen+1);
|
||||||
move(argstart^,argsbuf[count]^,arglen);
|
move(argstart^,argsbuf[count]^,arglen);
|
||||||
argsbuf[count][arglen]:=#0;
|
argsbuf[count][arglen]:=#0;
|
||||||
|
end;
|
||||||
{ skip quote }
|
{ skip quote }
|
||||||
if cmdline^ in quote then
|
if cmdline^ in quote then
|
||||||
inc(longint(cmdline));
|
inc(longint(cmdline));
|
||||||
@ -1001,7 +1009,10 @@ end.
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.41 1999-07-05 20:04:30 peter
|
Revision 1.42 1999-07-07 09:43:16 michael
|
||||||
|
Better construction of commandline argv
|
||||||
|
|
||||||
|
Revision 1.41 1999/07/05 20:04:30 peter
|
||||||
* removed temp defines
|
* removed temp defines
|
||||||
|
|
||||||
Revision 1.40 1999/06/11 16:26:40 michael
|
Revision 1.40 1999/06/11 16:26:40 michael
|
||||||
|
Loading…
Reference in New Issue
Block a user