changed the way empty sym string are handled

This commit is contained in:
Basile Burg 2014-11-18 11:13:01 +01:00
parent 7dc4fbcc8b
commit 7896d48405
5 changed files with 49 additions and 42 deletions

View File

@ -159,15 +159,17 @@ end;
procedure TCECdbWidget.txtCdbCmdKeyPress(Sender: TObject; var Key: char); procedure TCECdbWidget.txtCdbCmdKeyPress(Sender: TObject; var Key: char);
var var
inp: string; inp: string;
cmd: string;
begin begin
if (fCdbProc = nil) or (key <> #13) then if (fCdbProc = nil) or (key <> #13) then
exit; exit;
// //
inp := CEMainForm.expandSymbolicString(txtCdbCmd.Text) + LineEnding; cmd := CEMainForm.expandSymbolicString(txtCdbCmd.Text);
inp := cmd + LineEnding;
fCdbProc.Input.Write(inp[1], length(inp)); fCdbProc.Input.Write(inp[1], length(inp));
// //
inp := lstCdbOut.Items.Item[lstCdbOut.Items.Count-1].Caption; inp := lstCdbOut.Items.Item[lstCdbOut.Items.Count-1].Caption;
inp += CEMainForm.expandSymbolicString(txtCdbCmd.Text); inp += cmd;
lstCdbOut.Items.Item[lstCdbOut.Items.Count-1].Caption := inp; lstCdbOut.Items.Item[lstCdbOut.Items.Count-1].Caption := inp;
// //
txtCdbCmd.Text := ''; txtCdbCmd.Text := '';

View File

@ -89,14 +89,11 @@ begin
fProcess.OnReadData:= @processOutput; fProcess.OnReadData:= @processOutput;
fProcess.OnTerminate:= @processOutput; fProcess.OnTerminate:= @processOutput;
fProcess.Options := fOpts; fProcess.Options := fOpts;
if fExecutable <> '' then
fProcess.Executable := CEMainForm.expandSymbolicString(fExecutable); fProcess.Executable := CEMainForm.expandSymbolicString(fExecutable);
fProcess.ShowWindow := fShowWin; fProcess.ShowWindow := fShowWin;
if fWorkingDir <> '' then
fProcess.CurrentDirectory := CEMainForm.expandSymbolicString(fWorkingDir); fProcess.CurrentDirectory := CEMainForm.expandSymbolicString(fWorkingDir);
fProcess.Parameters.Clear; fProcess.Parameters.Clear;
for i:= 0 to fParameters.Count-1 do for i:= 0 to fParameters.Count-1 do
if fParameters.Strings[i] <> '' then
fProcess.Parameters.AddText(CEMainForm.expandSymbolicString(fParameters.Strings[i])); fProcess.Parameters.AddText(CEMainForm.expandSymbolicString(fParameters.Strings[i]));
fProcess.Execute; fProcess.Execute;
end; end;

View File

@ -842,18 +842,15 @@ procedure TPathsOpts.getOpts(const aList: TStrings);
var var
str: string; str: string;
begin begin
for str in fSrcs do if str <> '' then for str in fSrcs do
begin begin
str := (CEMainForm.expandSymbolicString(str)); str := CEMainForm.expandSymbolicString(str);
if not if not listAsteriskPath(str, aList, dExtList) then
// files are directly put in aList
listAsteriskPath(str, aList, dExtList)
then
aList.Add(str); aList.Add(str);
end; end;
for str in fIncl do if str <> '' then for str in fIncl do
aList.Add('-I'+ CEMainForm.expandSymbolicString(str)); aList.Add('-I'+ CEMainForm.expandSymbolicString(str));
for str in fImpt do if str <> '' then for str in fImpt do
aList.Add('-J'+ CEMainForm.expandSymbolicString(str)); aList.Add('-J'+ CEMainForm.expandSymbolicString(str));
if fFname <> '' then if fFname <> '' then
aList.Add('-of' + CEMainForm.expandSymbolicString(fFname)); aList.Add('-of' + CEMainForm.expandSymbolicString(fFname));

View File

@ -1727,10 +1727,9 @@ var
begs, ends: boolean; begs, ends: boolean;
i, j, extLen: integer; i, j, extLen: integer;
begin begin
if symString = '' then
exit('``');
result := ''; result := '';
if symString = '' then exit;
//
elems := TStringList.Create; elems := TStringList.Create;
try try
i := 0; i := 0;
@ -1766,13 +1765,16 @@ begin
continue; continue;
'CPF', 'CurrentProjectFile': 'CPF', 'CurrentProjectFile':
begin begin
if fProject <> nil then if fProject <> nil then begin
if fileExists(fProject.fileName) then if fileExists(fProject.fileName) then
result += fProject.fileName; result += fProject.fileName
else
result += '``';
end else result += '``';
end; end;
'CPFS', 'CurrentProjectFiles': 'CPFS', 'CurrentProjectFiles':
begin begin
if fProject <> nil then if fProject <> nil then begin
for j := 0 to fProject.Sources.Count-1 do for j := 0 to fProject.Sources.Count-1 do
begin begin
result += fProject.getAbsoluteSourceName(j); result += fProject.getAbsoluteSourceName(j);
@ -1780,47 +1782,61 @@ begin
if j <> fProject.Sources.Count-1 then if j <> fProject.Sources.Count-1 then
result += LineEnding; result += LineEnding;
end; end;
if fProject.Sources.Count = 0 then
result += '``';
end else result += '``';
end; end;
'CPN', 'CurrentProjectName': 'CPN', 'CurrentProjectName':
begin begin
if fProject <> nil then if fProject <> nil then begin
if fileExists(fProject.fileName) then if fileExists(fProject.fileName) then
begin begin
result += extractFileName(fProject.fileName); result += extractFileName(fProject.fileName);
extLen := length(ExtractFileExt(result)); extLen := length(ExtractFileExt(result));
result := result[1..length(result)-extLen]; result := result[1..length(result)-extLen];
end; end else result += '``';
end else result += '``';
end; end;
'CPP', 'CurrentProjectPath': 'CPP', 'CurrentProjectPath':
begin begin
if fProject <> nil then if fProject <> nil then begin
if fileExists(fProject.fileName) then if fileExists(fProject.fileName) then
result += extractFilePath(fProject.fileName); result += extractFilePath(fProject.fileName)
else result += '``';
end else result += '``';
end; end;
'CPR', 'CurrentProjectRoot': 'CPR', 'CurrentProjectRoot':
begin begin
if fProject <> nil then if fProject <> nil then begin
if directoryExists(fProject.getAbsoluteFilename(fProject.RootFolder)) then if directoryExists(fProject.getAbsoluteFilename(fProject.RootFolder)) then
result += fProject.getAbsoluteFilename(fProject.RootFolder) result += fProject.getAbsoluteFilename(fProject.RootFolder)
else if directoryExists(fProject.RootFolder) then else if directoryExists(fProject.RootFolder) then
result += fProject.RootFolder; result += fProject.RootFolder;
end else result += '``';
end; end;
'CFF', 'CurrentFileFile': 'CFF', 'CurrentFileFile':
begin begin
if fDoc <> nil then if fDoc <> nil then begin
if fileExists(fDoc.fileName) then if fileExists(fDoc.fileName) then
result += fDoc.fileName; result += fDoc.fileName
else result += '``';
end else result += '``';
end; end;
'CFP', 'CurrentFilePath': 'CFP', 'CurrentFilePath':
begin begin
if fDoc <> nil then if fDoc <> nil then begin
if fileExists(fDoc.fileName) then if fileExists(fDoc.fileName) then
result += extractFilePath(fDoc.fileName); result += extractFilePath(fDoc.fileName)
else result += '``'
end else result += '``';
end; end;
'CI', 'CurrentIdentifier': 'CI', 'CurrentIdentifier':
begin begin
if fDoc <> nil then if fDoc <> nil then begin
result += fDoc.Identifier; if fDoc.Identifier <> '' then
result += fDoc.Identifier
else result += '``'
end else result += '``';
end; end;
'CAF', 'CoeditApplicationFile': 'CAF', 'CoeditApplicationFile':
result += application.ExeName; result += application.ExeName;
@ -1831,11 +1847,6 @@ begin
finally finally
elems.Free; elems.Free;
end; end;
// as the result may be used in TProcess.Parameter, it has not to be empty
// otherwise next parameter switch can be considered as the parameter value,
// eg --a=<CI> --b --c, the program will think that --b is --a value if <CI> is empty.
if result = '' then
result += '``';
end; end;
procedure PlugDispatchToHost(aPlugin: TCEPlugin; opCode: LongWord; data0: Integer; data1, data2: Pointer); cdecl; procedure PlugDispatchToHost(aPlugin: TCEPlugin; opCode: LongWord; data0: Integer; data1, data2: Pointer); cdecl;

View File

@ -311,7 +311,7 @@ function TCEProject.outputFilename: string;
begin begin
result := currentConfiguration.pathsOptions.outputFilename; result := currentConfiguration.pathsOptions.outputFilename;
result := CEMainForm.expandSymbolicString(result); result := CEMainForm.expandSymbolicString(result);
if result <> '``' then if result <> '' then
begin begin
if not fileExists(result) then if not fileExists(result) then
result := getAbsoluteFilename(result); result := getAbsoluteFilename(result);
@ -463,9 +463,9 @@ var
i, j: integer; i, j: integer;
begin begin
pname := CEMainForm.expandSymbolicString(processInfo.executable); pname := CEMainForm.expandSymbolicString(processInfo.executable);
if (not exeInSysPath(pname)) and (pname <> '``') then if (not exeInSysPath(pname)) and (pname <> '') then
exit(false) exit(false)
else if (pname = '``') then else if (pname = '') then
exit(true); exit(true);
// //
process := TProcess.Create(nil); process := TProcess.Create(nil);
@ -568,10 +568,10 @@ begin
repeat repeat
prm := ExtractDelimited(i, runArgs, [' ']); prm := ExtractDelimited(i, runArgs, [' ']);
prm := CEMainForm.expandSymbolicString(prm); prm := CEMainForm.expandSymbolicString(prm);
if prm <> '``' then if prm <> '' then
fRunner.Parameters.AddText(prm); fRunner.Parameters.AddText(prm);
Inc(i); Inc(i);
until prm = '``'; until prm = '';
end; end;
// //
if not fileExists(outputFilename) then if not fileExists(outputFilename) then