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);
var
inp: string;
cmd: string;
begin
if (fCdbProc = nil) or (key <> #13) then
exit;
//
inp := CEMainForm.expandSymbolicString(txtCdbCmd.Text) + LineEnding;
cmd := CEMainForm.expandSymbolicString(txtCdbCmd.Text);
inp := cmd + LineEnding;
fCdbProc.Input.Write(inp[1], length(inp));
//
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;
//
txtCdbCmd.Text := '';

View File

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

View File

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

View File

@ -1727,10 +1727,9 @@ var
begs, ends: boolean;
i, j, extLen: integer;
begin
if symString = '' then
exit('``');
result := '';
if symString = '' then exit;
//
elems := TStringList.Create;
try
i := 0;
@ -1766,13 +1765,16 @@ begin
continue;
'CPF', 'CurrentProjectFile':
begin
if fProject <> nil then
if fProject <> nil then begin
if fileExists(fProject.fileName) then
result += fProject.fileName;
result += fProject.fileName
else
result += '``';
end else result += '``';
end;
'CPFS', 'CurrentProjectFiles':
begin
if fProject <> nil then
if fProject <> nil then begin
for j := 0 to fProject.Sources.Count-1 do
begin
result += fProject.getAbsoluteSourceName(j);
@ -1780,47 +1782,61 @@ begin
if j <> fProject.Sources.Count-1 then
result += LineEnding;
end;
if fProject.Sources.Count = 0 then
result += '``';
end else result += '``';
end;
'CPN', 'CurrentProjectName':
begin
if fProject <> nil then
if fProject <> nil then begin
if fileExists(fProject.fileName) then
begin
result += extractFileName(fProject.fileName);
extLen := length(ExtractFileExt(result));
result := result[1..length(result)-extLen];
end;
end else result += '``';
end else result += '``';
end;
'CPP', 'CurrentProjectPath':
begin
if fProject <> nil then
if fProject <> nil then begin
if fileExists(fProject.fileName) then
result += extractFilePath(fProject.fileName);
result += extractFilePath(fProject.fileName)
else result += '``';
end else result += '``';
end;
'CPR', 'CurrentProjectRoot':
begin
if fProject <> nil then
if fProject <> nil then begin
if directoryExists(fProject.getAbsoluteFilename(fProject.RootFolder)) then
result += fProject.getAbsoluteFilename(fProject.RootFolder)
else if directoryExists(fProject.RootFolder) then
result += fProject.RootFolder;
end else result += '``';
end;
'CFF', 'CurrentFileFile':
begin
if fDoc <> nil then
if fDoc <> nil then begin
if fileExists(fDoc.fileName) then
result += fDoc.fileName;
result += fDoc.fileName
else result += '``';
end else result += '``';
end;
'CFP', 'CurrentFilePath':
begin
if fDoc <> nil then
if fDoc <> nil then begin
if fileExists(fDoc.fileName) then
result += extractFilePath(fDoc.fileName);
result += extractFilePath(fDoc.fileName)
else result += '``'
end else result += '``';
end;
'CI', 'CurrentIdentifier':
begin
if fDoc <> nil then
result += fDoc.Identifier;
if fDoc <> nil then begin
if fDoc.Identifier <> '' then
result += fDoc.Identifier
else result += '``'
end else result += '``';
end;
'CAF', 'CoeditApplicationFile':
result += application.ExeName;
@ -1831,11 +1847,6 @@ begin
finally
elems.Free;
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;
procedure PlugDispatchToHost(aPlugin: TCEPlugin; opCode: LongWord; data0: Integer; data1, data2: Pointer); cdecl;

View File

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