[fpc-devel] TProcess empty parameter
Marco van de Voort
marcov at stack.nl
Thu May 7 14:41:55 CEST 2015
In our previous episode, Michael Van Canneyt said:
> >>> The C standard says that argv[argc] shall be a null pointer.
> >>
> >> So if argc is 15, there should be no problem to have a Nil at position 5 ?
> >
> > The standard also says that argv[0] to argv[argc-1] shall contain
> > pointers to strings. NULL is not a pointer to a string, so that would
> > be a problem.
>
> Indeed.
> So, in any case, we'll need to adapt TProcess.
No, strnew, since it is not delphi compatible and should simply always
allocate a string.
Index: syspch.inc
===================================================================
--- syspch.inc (revision 30815)
+++ syspch.inc (working copy)
@@ -28,6 +28,11 @@
{ Processor independent part, shared with strings unit }
{$i stringsi.inc }
+var
+ { widechar, because also used by widestring -> pwidechar conversions }
+ emptychar : widechar;external name 'FPC_EMPTYCHAR';
+
+
{ StrPas converts a PChar to a pascal string }
function StrPas(Str: PChar): string;
@@ -56,8 +61,8 @@
len : longint;
begin
Result:=nil;
- if (p=nil) or (p^=#0) then
- exit;
+ if (p=nil) then
+ p:=@emptychar;
len:=strlen(p)+1;
Result:=StrAlloc(Len);
if Result<>nil then
(not committed since the same must be done for the wideroutines too.
More information about the fpc-devel
mailing list