[fpc-devel] TProcess empty parameter
Michael Van Canneyt
michael at freepascal.org
Thu May 7 14:41:20 CEST 2015
On Thu, 7 May 2015, Marco van de Voort wrote:
> In our previous episode, Michael Van Canneyt said:
>>> Since NIL is a termination of an array of pchar in C that is not ok.
>> if that were the case, argc would not have been introduced,
>> which is why I doubt the use of this argument ?
> Where is argc on the calling side? In the parameters of ExecVE ? Right.
>> C code that regards nil as the last element of the argv array is just
> IMHO *nix is not terribly well designed. Probably the multitude of versions
> and being interwoven with C prohibited doing massive cleanups.
This argument can be applied to any OS older than 5 years :)
Backwards compatibility probably prevents any OS from being considered 'well designed'.
>>> behaviour of strnew should be checked in both TP and Delphi (since both have
>>> strnew) and if necessary changed. (returning FPC_EMPTYCHAR or whatever)
> As for Delphi,
> var p : pchar;
> writeln(assigned(p),' ',ord(p^));
> writes "TRUE 0"
> so it seems to be the emptychar story. Better fix that as well.
> Unfortunately, FPC_emptychar is not exported from system.
No, and you cannot use that directly, because in case of an error, the items in the argv
array and the array itself are freed (or so I hope).
The FPC_emptychar pointer should not be freed...
fixing strnew() to allocate a single #0 on the heap is probably best.
More information about the fpc-devel