diff --git a/ide/initialsetupdlgs.pas b/ide/initialsetupdlgs.pas index 9706645e96..13d7ded94b 100644 --- a/ide/initialsetupdlgs.pas +++ b/ide/initialsetupdlgs.pas @@ -43,7 +43,7 @@ uses Classes, SysUtils, strutils, contnrs, LCLProc, Forms, Controls, Buttons, Dialogs, FileUtil, Laz2_XMLCfg, lazutf8classes, LazFileUtils, LazFileCache, LazLogger, Graphics, ComCtrls, ExtCtrls, StdCtrls, DefineTemplates, - CodeToolManager, TransferMacros, MacroDefIntf, GDBMIDebugger, + CodeToolManager, FileProcs, TransferMacros, MacroDefIntf, GDBMIDebugger, DbgIntfDebuggerBase, LazarusIDEStrConsts, LazConf, EnvironmentOpts, IDEProcs, AboutFrm, IDETranslations, InitialSetupProc; diff --git a/ide/initialsetupproc.pas b/ide/initialsetupproc.pas index 470ae161c2..5652ce6a5a 100644 --- a/ide/initialsetupproc.pas +++ b/ide/initialsetupproc.pas @@ -34,8 +34,8 @@ interface uses Classes, SysUtils, strutils, LazFileCache, LazUTF8Classes, LazFileUtils, LazLoggerBase, LazUTF8, Laz2_XMLCfg, LazLogger, DefineTemplates, - CodeToolManager, LazarusIDEStrConsts, LazConf, EnvironmentOpts, IDEProcs, - contnrs; + CodeToolManager, FileProcs, LazarusIDEStrConsts, LazConf, EnvironmentOpts, + IDEProcs, contnrs; type TSDFilenameQuality = ( @@ -106,7 +106,6 @@ function GetValueFromSecondaryConfig(OptionFilename, Path: string): string; function GetValueFromIDEConfig(OptionFilename, Path: string): string; function SafeFormat(const Fmt: String; const Args: Array of const): String; -function SimpleFormat(const Fmt: String; const Args: Array of const): String; implementation @@ -912,44 +911,6 @@ begin Result:=SimpleFormat(Fmt,Args); end; -function SimpleFormat(const Fmt: String; const Args: array of const): String; -var - p: Integer; - i: Integer; - s: String; -begin - Result:=Fmt; - p:=1; - for i:=Low(Args) to High(Args) do - begin - case Args[i].VType of - vtString: s:=Args[i].VString^; - vtAnsiString: s:=AnsiString(Args[i].VAnsiString); - vtChar: s:=Args[i].VChar; - else continue; - end; - while (p replace - ReplaceSubstring(Result,p,2,s); - inc(p,length(s)); - end else begin - // missing %s => append - Result+=', '+s; - p:=length(s)+1; - end; - end; -end; - { TSDFileInfoList } function TSDFileInfoList.AddNewItem(aFilename, aCaption: string): TSDFileInfo; diff --git a/test/codetoolstests/testbasiccodetools.pas b/test/codetoolstests/testbasiccodetools.pas index d6fae26c62..75da9f1c55 100644 --- a/test/codetoolstests/testbasiccodetools.pas +++ b/test/codetoolstests/testbasiccodetools.pas @@ -8,6 +8,7 @@ ./runtests --format=plain --suite=TestCompareTextIgnoringSpace ./runtests --format=plain --suite=TestGuessIndentSize ./runtests --format=plain --suite=TestReindent + ./runtests --format=plain --suite=TestSimpleFormat } unit TestBasicCodetools; @@ -31,6 +32,7 @@ type procedure TestCompareTextIgnoringSpace; procedure TestGuessIndentSize; procedure TestReIndent; + procedure TestSimpleFormat; end; implementation @@ -215,6 +217,29 @@ begin t('A'#10' B'#10,2,4, 3,0,'A'#10' B'#10); end; +procedure TTestBasicCodeTools.TestSimpleFormat; + + procedure t(const Fmt: string; Args: array of const; const Expected: string); + var + Actual: String; + begin + Actual:=SimpleFormat(Fmt,Args); + if Expected=Actual then exit; + writeln(dbgsDiff(Expected,Actual)); + AssertEquals('"'+DbgStr(Fmt)+'"('+dbgs(High(Args)-Low(Args)+1)+')',true,false); + end; + +begin + t('A',['Foo'],'A,Foo'); + t('A%sB',['Foo'],'AFooB'); + t('A%sB%sC',['Foo'],'AFooB%sC'); + t('A%sB',['Foo','Bar'],'AFooB,Bar'); + t('A%0B',['Foo','Bar'],'AFooB,Bar'); + t('A%1B',['Foo','Bar'],'ABarB,Foo'); + t('A%1%0B',['Foo','Bar'],'ABarFooB'); + t('A%1:s%0:sB',['Foo','Bar'],'ABarFooB'); +end; + initialization AddToCodetoolsTestSuite(TTestBasicCodeTools); diff --git a/test/lazutils/testlazutils.pas b/test/lazutils/testlazutils.pas index 5f395047e6..2771cd07c0 100644 --- a/test/lazutils/testlazutils.pas +++ b/test/lazutils/testlazutils.pas @@ -66,6 +66,7 @@ begin AssertEquals('last multi','adef',r('abc',2,2,'def')); AssertEquals('middle chars same','abcde',r('abcde',2,3,'bcd')); AssertEquals('middle chars shorten','axe',r('abcde',2,3,'x')); + AssertEquals('after chars','abcx',r('abc',4,3,'x')); end; procedure TTestLazUtils.TestSplitCmdLineParams; diff --git a/test/runtests.lpi b/test/runtests.lpi index 7fa49bc80c..1a06f8fc9b 100644 --- a/test/runtests.lpi +++ b/test/runtests.lpi @@ -48,11 +48,7 @@ - - - - @@ -90,37 +86,30 @@ - - - - - - - @@ -135,17 +124,14 @@ - - - @@ -155,22 +141,18 @@ - - - - @@ -206,11 +188,7 @@ - - - -