From d5985e3606a0e17fbb5c8d575b4f8adb088bc71a Mon Sep 17 00:00:00 2001 From: mattias Date: Thu, 27 Jan 2011 18:59:48 +0000 Subject: [PATCH] codetools: fixed TCodeToolsOptions.LoadFromFile to not expand empty settings, bug #18364 git-svn-id: trunk@29219 - --- components/codetools/codetoolsconfig.pas | 6 +++--- .../codetools/examples/finddeclaration.lpr | 2 +- .../codetools/examples/methodjumping.lpi | 13 ++++++++++--- .../codetools/examples/methodjumping.pas | 18 +++++++++++++++++- 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/components/codetools/codetoolsconfig.pas b/components/codetools/codetoolsconfig.pas index 7e77868846..21ca877a19 100644 --- a/components/codetools/codetoolsconfig.pas +++ b/components/codetools/codetoolsconfig.pas @@ -173,7 +173,7 @@ procedure TCodeToolsOptions.SetFPCPath(const AValue: string); var NewValue: String; begin - NewValue:=ExpandFileNameUTF8(AValue); + NewValue:=TrimAndExpandFilename(AValue); if FFPCPath=NewValue then exit; FFPCPath:=NewValue; FUnitLinkListValid:=false; @@ -184,7 +184,7 @@ procedure TCodeToolsOptions.SetFPCSrcDir(const AValue: string); var NewValue: String; begin - NewValue:=ExpandFileNameUTF8(AValue); + NewValue:=TrimAndExpandFilename(AValue); if FFPCSrcDir=NewValue then exit; FFPCSrcDir:=NewValue; FUnitLinkListValid:=false; @@ -203,7 +203,7 @@ procedure TCodeToolsOptions.SetLazarusSrcDir(const AValue: string); var NewValue: String; begin - NewValue:=ExpandFileNameUTF8(AValue); + NewValue:=TrimAndExpandFilename(AValue); if FLazarusSrcDir=NewValue then exit; FLazarusSrcDir:=NewValue; Modified:=true; diff --git a/components/codetools/examples/finddeclaration.lpr b/components/codetools/examples/finddeclaration.lpr index 43dad8d5f4..eeb25c1107 100644 --- a/components/codetools/examples/finddeclaration.lpr +++ b/components/codetools/examples/finddeclaration.lpr @@ -87,7 +87,7 @@ begin writeln('TARGET=',Options.TargetOS); writeln('TARGETCPU=',Options.TargetProcessor); if (ParamCount>=3) then begin - Options.TestPascalFile:=ExpandFileName(ParamStr(1)); + Options.TestPascalFile:=ExpandFileNameUTF8(ParamStr(1)); X:=StrToInt(ParamStr(2)); Y:=StrToInt(ParamStr(3)); end; diff --git a/components/codetools/examples/methodjumping.lpi b/components/codetools/examples/methodjumping.lpi index 40b264cca3..671bbb66b2 100644 --- a/components/codetools/examples/methodjumping.lpi +++ b/components/codetools/examples/methodjumping.lpi @@ -1,15 +1,17 @@ - + - + + + @@ -35,7 +37,12 @@ - + + + + + + diff --git a/components/codetools/examples/methodjumping.pas b/components/codetools/examples/methodjumping.pas index debc0c8533..05f249ae50 100644 --- a/components/codetools/examples/methodjumping.pas +++ b/components/codetools/examples/methodjumping.pas @@ -36,12 +36,28 @@ var NewCode: TCodeBuffer; NewX, NewY, NewTopLine: integer; RevertableJump: boolean; + X: Integer; + Y: Integer; begin + if (ParamCount>=1) and (Paramcount<3) then begin + writeln('Usage:'); + writeln(' ',ParamStr(0)); + writeln(' ',ParamStr(0),' '); + end; + ExpandedFilename:=ExpandFileNameUTF8('scanexamples/methodjump1.pas'); + X:=14; + Y:=10; + if (ParamCount>=3) then begin + ExpandedFilename:=ExpandFileNameUTF8(ParamStr(1)); + X:=StrToInt(ParamStr(2)); + Y:=StrToInt(ParamStr(3)); + end; + CodeBuf:=CodeToolBoss.LoadFile(ExpandedFilename,true,false); if CodeBuf=nil then raise Exception.Create('failed loading '+ExpandedFilename); - if CodeToolBoss.JumpToMethod(CodeBuf,14,10,NewCode,NewX,NewY,NewTopLine, + if CodeToolBoss.JumpToMethod(CodeBuf,X,Y,NewCode,NewX,NewY,NewTopLine, RevertableJump) then writeln(NewCode.Filename,' ',NewX,',',NewY,' TopLine=',NewTopLine,