* empty tprocess command line results on windows now in the same exception as on unix

* some code unified

git-svn-id: trunk@11343 -
This commit is contained in:
florian 2008-07-07 18:41:10 +00:00
parent d71c80b757
commit f5d9a9d1b7
10 changed files with 185 additions and 54 deletions

1
.gitattributes vendored
View File

@ -7421,6 +7421,7 @@ tests/test/opt/treg3.pp svneol=native#text/plain
tests/test/opt/treg4.pp svneol=native#text/plain
tests/test/opt/tretopt.pp svneol=native#text/plain
tests/test/opt/tspace.pp svneol=native#text/plain
tests/test/packages/fcl-process/tw11570.pp svneol=native#text/plain
tests/test/packages/fcl-registry/tregistry1.pp svneol=native#text/plain
tests/test/packages/hash/tmdtest.pp svneol=native#text/plain
tests/test/packages/webtbs/tw10045.pp svneol=native#text/plain

View File

@ -1,5 +1,5 @@
#
# Don't edit, this file is generated by FPCMake Version 2.0.0 [2008/06/15]
# Don't edit, this file is generated by FPCMake Version 2.0.0 [2008/07/07]
#
default: all
MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded
@ -437,11 +437,14 @@ endif
ifeq ($(FULL_TARGET),i386-linux)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),i386-go32v2)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),i386-win32)
override TARGET_RSTS+=simpleipc
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),i386-os2)
override TARGET_RSTS+=simpleipc
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),i386-freebsd)
override TARGET_RSTS+=process simpleipc
@ -461,17 +464,35 @@ endif
ifeq ($(FULL_TARGET),i386-qnx)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),i386-netware)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),i386-openbsd)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),i386-wdosx)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),i386-darwin)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),i386-emx)
override TARGET_RSTS+=simpleipc
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),i386-watcom)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),i386-netwlibc)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),i386-wince)
override TARGET_RSTS+=simpleipc
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),i386-embedded)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),i386-symbian)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),m68k-linux)
override TARGET_RSTS+=process simpleipc
@ -482,18 +503,42 @@ endif
ifeq ($(FULL_TARGET),m68k-netbsd)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),m68k-amiga)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),m68k-atari)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),m68k-openbsd)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),m68k-palmos)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),m68k-embedded)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),powerpc-linux)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),powerpc-netbsd)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),powerpc-amiga)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),powerpc-macos)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),powerpc-darwin)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),powerpc-morphos)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),powerpc-embedded)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),sparc-linux)
override TARGET_RSTS+=process simpleipc
endif
@ -503,6 +548,9 @@ endif
ifeq ($(FULL_TARGET),sparc-solaris)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),sparc-embedded)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),x86_64-linux)
override TARGET_RSTS+=process simpleipc
endif
@ -513,16 +561,34 @@ ifeq ($(FULL_TARGET),x86_64-darwin)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),x86_64-win64)
override TARGET_RSTS+=simpleipc
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),x86_64-embedded)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),arm-linux)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),arm-palmos)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),arm-darwin)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),arm-wince)
override TARGET_RSTS+=simpleipc
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),arm-gba)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),arm-nds)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),arm-embedded)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),arm-symbian)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),powerpc64-linux)
override TARGET_RSTS+=process simpleipc
@ -530,9 +596,18 @@ endif
ifeq ($(FULL_TARGET),powerpc64-darwin)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),powerpc64-embedded)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),avr-embedded)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),armeb-linux)
override TARGET_RSTS+=process simpleipc
endif
ifeq ($(FULL_TARGET),armeb-embedded)
override TARGET_RSTS+=process simpleipc
endif
override INSTALL_FPCPACKAGE=y
ifeq ($(FULL_TARGET),i386-linux)
override COMPILER_OPTIONS+=-S2h

View File

@ -22,20 +22,7 @@ units_wince=simpleipc dbugmsg dbugintf
units_qnx=simpleipc dbugmsg dbugintf
units_os2=simpleipc dbugmsg dbugintf
units_emx=simpleipc dbugmsg dbugintf
rsts_beos=process simpleipc
rsts_haiku=process simpleipc
rsts_freebsd=process simpleipc
rsts_darwin=process simpleipc
rsts_solaris=process simpleipc
rsts_netbsd=process simpleipc
rsts_openbsd=process simpleipc
rsts_linux=process simpleipc
rsts_qnx=process simpleipc
rsts_win32=simpleipc
rsts_win64=simpleipc
rsts_wince=simpleipc
rsts_os2=simpleipc
rsts_emx=simpleipc
rsts=process simpleipc
[compiler]
options=-S2h

View File

@ -139,6 +139,20 @@ Type
implementation
{$ifdef WINDOWS}
Uses
Windows;
{$endif WINDOWS}
{$ifdef UNIX}
uses
Unix,
Baseunix;
{$endif UNIX}
Resourcestring
SNoCommandLine = 'Cannot execute empty command-line';
SErrNoSuchProgram = 'Executable not found: "%s"';
{$i process.inc}
Constructor TProcess.Create (AOwner : TComponent);

View File

@ -1,14 +1,15 @@
{
Unix Process .inc.
}
This file is part of the Free Component Library (FCL)
Copyright (c) 1999-2008 by the Free Pascal development team
uses
Unix,
Baseunix;
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
resourcestring
SErrNoSuchProgram = 'Executable not found: "%s"';
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************}
Const
PriorityConstants : Array [TProcessPriority] of Integer =
(20,20,0,-20);
@ -17,8 +18,6 @@ Const
GeometryOption : String = '-geometry';
TitleOption : String ='-title';
procedure TProcess.CloseProcessHandles;
begin
@ -133,14 +132,11 @@ end;
Function MakeCommand(P : TProcess) : PPchar;
Const
SNoCommandLine = 'Cannot execute empty command-line';
Var
Cmd : String;
S : TStringList;
G : String;
begin
if (P.ApplicationName='') then
begin

View File

@ -1,8 +1,15 @@
{
Win32 Process .inc.
}
This file is part of the Free Component Library (FCL)
Copyright (c) 1999-2008 by the Free Pascal development team
uses Windows;
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************}
Const
PriorityConstants : Array [TProcessPriority] of Cardinal =
@ -150,8 +157,6 @@ end;
Procedure TProcess.Execute;
Var
PName,PDir,PCommandLine : PChar;
FEnv: pointer;
@ -161,16 +166,27 @@ Var
FProcessInformation : TProcessInformation;
FStartupInfo : STARTUPINFO;
HI,HO,HE : THandle;
begin
FInheritHandles:=True;
PName:=Nil;
PCommandLine:=Nil;
PDir:=Nil;
If FApplicationName<>'' then
PName:=Pchar(FApplicationName);
If FCommandLine<>'' then
PCommandLine:=Pchar(FCommandLine);
if (FApplicationName='') then
begin
If (FCommandLine='') then
Raise EProcess.Create(SNoCommandline);
PCommandLine:=Pchar(FCommandLine)
end
else
begin
PName:=Pchar(FApplicationName);
If (FCommandLine='') then
PCommandLine:=Pchar(FApplicationName)
else
PCommandLine:=Pchar(FCommandLine)
end;
If FCurrentDirectory<>'' then
PDir:=Pchar(FCurrentDirectory);
if FEnvironment.Count<>0 then

View File

@ -1,8 +1,15 @@
{
Wince Process .inc.
}
This file is part of the Free Component Library (FCL)
Copyright (c) 1999-2008 by the Free Pascal development team
uses Windows;
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************}
Const
PriorityConstants : Array [TProcessPriority] of Cardinal =
@ -167,10 +174,22 @@ begin
PName:=Nil;
PCommandLine:=Nil;
PDir:=Nil;
If FApplicationName<>'' then
PName:=PWidechar(FApplicationName);
If FCommandLine<>'' then
PCommandLine:=PWidechar(FCommandLine);
if (FApplicationName='') then
begin
If (FCommandLine='') then
Raise EProcess.Create(SNoCommandline);
PCommandLine:=PWidechar(FCommandLine)
end
else
begin
PName:=PWidechar(FApplicationName);
If (FCommandLine='') then
PCommandLine:=PWidechar(FApplicationName)
else
PCommandLine:=PWidechar(FCommandLine)
end;
If FCurrentDirectory<>'' then
PDir:=PWidechar(FCurrentDirectory);
if FEnvironment.Count<>0 then

View File

@ -1,5 +1,5 @@
#
# Don't edit, this file is generated by FPCMake Version 2.0.0 [2008/06/15]
# Don't edit, this file is generated by FPCMake Version 2.0.0 [2008/07/07]
#
default: allexectests
MAKEFILETARGETS=i386-linux i386-go32v2 i386-win32 i386-os2 i386-freebsd i386-beos i386-haiku i386-netbsd i386-solaris i386-qnx i386-netware i386-openbsd i386-wdosx i386-darwin i386-emx i386-watcom i386-netwlibc i386-wince i386-embedded i386-symbian m68k-linux m68k-freebsd m68k-netbsd m68k-amiga m68k-atari m68k-openbsd m68k-palmos m68k-embedded powerpc-linux powerpc-netbsd powerpc-amiga powerpc-macos powerpc-darwin powerpc-morphos powerpc-embedded sparc-linux sparc-netbsd sparc-solaris sparc-embedded x86_64-linux x86_64-freebsd x86_64-darwin x86_64-win64 x86_64-embedded arm-linux arm-palmos arm-darwin arm-wince arm-gba arm-nds arm-embedded arm-symbian powerpc64-linux powerpc64-darwin powerpc64-embedded avr-embedded armeb-linux armeb-embedded
@ -1442,7 +1442,7 @@ ifndef LOG
export LOG:=$(TEST_OUTPUTDIR)/log
endif
TESTSUBDIRS=cg cg/variants cg/cdecl opt units/system units/dos units/crt units/objects units/strings units/sysutils units/math units/sharemem
TESTPACKAGESUBDIRS=cg packages/win-base packages/webtbs packages/hash packages/fcl-registry
TESTPACKAGESUBDIRS=cg packages/win-base packages/webtbs packages/hash packages/fcl-registry packages/fcl-process
ifdef QUICKTEST
export QUICKTEST
else

View File

@ -123,7 +123,7 @@ endif
# Subdirs available in the test subdir
TESTSUBDIRS=cg cg/variants cg/cdecl opt units/system units/dos units/crt units/objects units/strings units/sysutils units/math units/sharemem
TESTPACKAGESUBDIRS=cg packages/win-base packages/webtbs packages/hash packages/fcl-registry
TESTPACKAGESUBDIRS=cg packages/win-base packages/webtbs packages/hash packages/fcl-registry packages/fcl-process
ifdef QUICKTEST
export QUICKTEST

View File

@ -0,0 +1,23 @@
program Project1;
{$mode objfpc}{$H+}
uses
Classes, SysUtils, Process
{ you can add units after this };
var
p: TProcess;
begin
try
p := TProcess.Create(nil);
p.Active := true;
except
on eprocess do
begin
writeln('ok');
halt(0);
end;
end;
halt(1);
end.