mirror of https://gitlab.com/basile.b/dexed.git
fix #452 - Freeze at startup due to too long dastworx command line
This commit is contained in:
parent
cc43af01e1
commit
cc7f54e894
|
@ -4,7 +4,8 @@ unit u_dastworx;
|
||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, process, jsonscanner, fpjson, jsonparser, u_common;
|
Classes, SysUtils, process, jsonscanner, fpjson, jsonparser,
|
||||||
|
u_common, u_dialogs;
|
||||||
|
|
||||||
(**
|
(**
|
||||||
* Gets the module name and the imports of the source code located in
|
* Gets the module name and the imports of the source code located in
|
||||||
|
@ -18,7 +19,7 @@ procedure getModuleImports(source, imports: TStrings);
|
||||||
* source. Each line in "import" that contains double quoted text indicates
|
* source. Each line in "import" that contains double quoted text indicates
|
||||||
* that a new group of import starts.
|
* that a new group of import starts.
|
||||||
*)
|
*)
|
||||||
procedure getModulesImports(const files: string; results: TStrings);
|
procedure getModulesImports(files: string; results: TStrings);
|
||||||
|
|
||||||
procedure getHalsteadMetrics(source: TStrings; out jsn: TJSONObject);
|
procedure getHalsteadMetrics(source: TStrings; out jsn: TJSONObject);
|
||||||
|
|
||||||
|
@ -64,14 +65,49 @@ begin
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure getModulesImports(const files: string; results: TStrings);
|
procedure getModulesImports(files: string; results: TStrings);
|
||||||
var
|
var
|
||||||
str: string;
|
str: string;
|
||||||
prc: TProcess;
|
prc: TProcess;
|
||||||
|
{$ifdef WINDOWS}
|
||||||
|
cdr: string = '';
|
||||||
|
itm: string;
|
||||||
|
spl: TStringList;
|
||||||
|
i: integer;
|
||||||
|
{$endif}
|
||||||
begin
|
begin
|
||||||
str := getToolName;
|
str := getToolName;
|
||||||
if str.isEmpty then
|
if str.isEmpty then
|
||||||
exit;
|
exit;
|
||||||
|
{$ifdef WINDOWS}
|
||||||
|
if files.length > 32760{not 8 : "-f -i" length} then
|
||||||
|
begin
|
||||||
|
spl := TStringList.Create;
|
||||||
|
try
|
||||||
|
spl.LineBreak := ';';
|
||||||
|
spl.AddText(files);
|
||||||
|
cdr := commonFolder(spl);
|
||||||
|
if not cdr.dirExists then
|
||||||
|
begin
|
||||||
|
dlgOkError('Impossible to find the common directory in the list to analyze the imports: ' + shortenPath(files, 200));
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
for i:= 0 to spl.count-1 do
|
||||||
|
begin
|
||||||
|
itm := spl.strings[i];
|
||||||
|
spl.strings[i] := itm[cdr.length + 2 .. itm.length];
|
||||||
|
end;
|
||||||
|
files := spl.strictText;
|
||||||
|
if files.length > 32760 then
|
||||||
|
begin
|
||||||
|
dlgOkError('Too much files in the list to analyze the imports: ' + shortenPath(files, 200));
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
finally
|
||||||
|
spl.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
{$endif}
|
||||||
prc := TProcess.Create(nil);
|
prc := TProcess.Create(nil);
|
||||||
try
|
try
|
||||||
prc.Executable := str;
|
prc.Executable := str;
|
||||||
|
@ -79,6 +115,10 @@ begin
|
||||||
prc.Parameters.Add('-i');
|
prc.Parameters.Add('-i');
|
||||||
prc.Options := [poUsePipes {$IFDEF WINDOWS}, poNewConsole{$ENDIF}];
|
prc.Options := [poUsePipes {$IFDEF WINDOWS}, poNewConsole{$ENDIF}];
|
||||||
prc.ShowWindow := swoHIDE;
|
prc.ShowWindow := swoHIDE;
|
||||||
|
{$ifdef WINDOWS}
|
||||||
|
if cdr.isNotEmpty then
|
||||||
|
prc.CurrentDirectory := cdr;
|
||||||
|
{$endif}
|
||||||
prc.Execute;
|
prc.Execute;
|
||||||
prc.CloseInput;
|
prc.CloseInput;
|
||||||
processOutputToStrings(prc, results);
|
processOutputToStrings(prc, results);
|
||||||
|
|
Loading…
Reference in New Issue