From 7896d484055c921dfb0e05b69917869c5634a2f8 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Tue, 18 Nov 2014 11:13:01 +0100 Subject: [PATCH] changed the way empty sym string are handled --- src/ce_cdbcmd.pas | 6 +++-- src/ce_customtools.pas | 7 ++---- src/ce_dmdwrap.pas | 13 ++++------ src/ce_main.pas | 55 +++++++++++++++++++++++++----------------- src/ce_project.pas | 10 ++++---- 5 files changed, 49 insertions(+), 42 deletions(-) diff --git a/src/ce_cdbcmd.pas b/src/ce_cdbcmd.pas index dd39ce30..0614e62e 100644 --- a/src/ce_cdbcmd.pas +++ b/src/ce_cdbcmd.pas @@ -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 := ''; diff --git a/src/ce_customtools.pas b/src/ce_customtools.pas index 7e5900b6..ff65afa1 100644 --- a/src/ce_customtools.pas +++ b/src/ce_customtools.pas @@ -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; diff --git a/src/ce_dmdwrap.pas b/src/ce_dmdwrap.pas index 81889f44..c0100210 100644 --- a/src/ce_dmdwrap.pas +++ b/src/ce_dmdwrap.pas @@ -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)); diff --git a/src/ce_main.pas b/src/ce_main.pas index 95ac73f7..bb2288b8 100644 --- a/src/ce_main.pas +++ b/src/ce_main.pas @@ -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= --b --c, the program will think that --b is --a value if is empty. - if result = '' then - result += '``'; end; procedure PlugDispatchToHost(aPlugin: TCEPlugin; opCode: LongWord; data0: Integer; data1, data2: Pointer); cdecl; diff --git a/src/ce_project.pas b/src/ce_project.pas index 092c1c58..fab1f2c4 100644 --- a/src/ce_project.pas +++ b/src/ce_project.pas @@ -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