mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-22 00:29:33 +02:00
* Allow sourcing program from stdn with -- option (bug ID 35945)
git-svn-id: trunk@43026 -
This commit is contained in:
parent
ccfe575645
commit
9aa024c7df
@ -65,6 +65,8 @@ begin
|
||||
writeln;
|
||||
writeln('Options:');
|
||||
writeln;
|
||||
writeln(' --');
|
||||
Writeln(' Read program from standard input');
|
||||
writeln(' --set-cache=<path to cache>');
|
||||
writeln(' Set the cache to be used. Otherwise using environment variable');
|
||||
writeln(' INSTANTFPCCACHE.');
|
||||
@ -95,7 +97,8 @@ var
|
||||
CacheDir: String;
|
||||
CacheFilename: String;
|
||||
OutputFilename: String;
|
||||
E : String;
|
||||
S,E : String;
|
||||
DeleteCache : Boolean = False;
|
||||
RunIt: boolean = true;
|
||||
|
||||
// Return true if filename found.
|
||||
@ -131,6 +134,11 @@ begin
|
||||
begin
|
||||
Filename:=p;
|
||||
Result:=True;
|
||||
end
|
||||
else if (p='--') then
|
||||
begin
|
||||
Filename:='--';
|
||||
Result:=True;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -173,7 +181,18 @@ begin
|
||||
CheckSourceName(Filename);
|
||||
Src:=TStringList.Create;
|
||||
try
|
||||
Src.LoadFromFile(Filename);
|
||||
if FileName<>'--' then
|
||||
Src.LoadFromFile(Filename)
|
||||
else
|
||||
begin
|
||||
While not EOF do
|
||||
begin
|
||||
Readln(S);
|
||||
Src.Add(S);
|
||||
end;
|
||||
FileName:=ChangeFileExt(GetTempFileName,'.pp');
|
||||
DeleteCache:=true;
|
||||
end;
|
||||
CommentShebang(Src);
|
||||
CacheDir:=GetCacheDir;
|
||||
|
||||
@ -187,10 +206,14 @@ begin
|
||||
// save source in cache to find out next time if something changed
|
||||
Src.SaveToFile(CacheFilename);
|
||||
Compile(Filename,CacheFilename,OutputFilename);
|
||||
if deleteCache then
|
||||
DeleteFile(CacheFileName);
|
||||
end;
|
||||
// run
|
||||
if RunIt then
|
||||
Run(OutputFilename);
|
||||
if DeleteCache then
|
||||
DeleteFile(OutputFileName);
|
||||
finally
|
||||
// memory is freed by OS, but for debugging puposes you can do it manually
|
||||
{$IFDEF IFFreeMem}
|
||||
|
Loading…
Reference in New Issue
Block a user