[fpc-devel] TProcess empty parameter
Michael Van Canneyt
michael at freepascal.org
Tue May 5 11:35:06 CEST 2015
On Sat, 2 May 2015, Alfred wrote:
> Hello to all.
> While working on fpcup, I did encounter the following problem.
> Fpcup has modules that implement automatic download and install of packages.
> One of these modules is indy.
> Indy has a svn server that needs a username. No password is needed.
> However, if a username is given to a command line svn client, this svn-client
> wants to have a password too.
> This password has to be empty.
> Fpcup uses TProcess to execute commands.
> But it seems that TProcess cannot handle empty parameters correctly (on
That is debatable:
The question is: how does a C program interpret a Nil argv pointer ?
Because a Nil pointer is added to the Argv array, so the argument is there.
> It processes the parameters, including the empty password, by generating a
> list of (p)pchar strings.
> It uses strnew to accomplish this.
> But strnew returns nil for an empty string (Delphi does not return nil in
> this case).
Do you have a test for this ?
> My question:
> Is this expected behavior of TProcess ?
> Or should TProcess be changed.
> Or strnew (and strpas) ?
> Additional info
> Sourcefile : process.inc, inside fpc\packages\fcl-process\src\unix :
> Function StringsToPCharList(List : TStrings) : PPChar;
> I : Integer;
> S : String;
> For I:=0 to List.Count-1 do
> Result[i]:=StrNew(PChar(S)); <--------------------------- here
Pchar(S) will return a pointer to an empty string (essentially, a pointer to a #0 char)
if S is empty. That means that StrNew would need to be adapted.
However, for backwards compatibility with FPC, it may be better to simply change
TProcess to add a pointer to a zero character #0
More information about the fpc-devel