Browse Source

--- Merging r15190 into '.':
U packages/fcl-base/src/fptemplate.pp
--- Merging r15191 into '.':
G packages/fcl-base/src/fptemplate.pp
--- Merging r15213 into '.':
U compiler/utils/fpcsubst.pp

git-svn-id: branches/fixes_2_4@15285 -

joost 15 years ago
parent
commit
411500ed51
2 changed files with 12 additions and 7 deletions
  1. 2 0
      compiler/utils/fpcsubst.pp
  2. 10 7
      packages/fcl-base/src/fptemplate.pp

+ 2 - 0
compiler/utils/fpcsubst.pp

@@ -28,6 +28,7 @@ Resourcestring
   SWarnIgnoringPair = 'Warning: ignoring wrong name/value pair: ';
   SStats = 'Replaced %d placeholders in %d lines.';
   SSubstInLine = 'Replaced %s placeholders in line %d.';
+  SWarningDeprecated = 'Warning: This utility is deprecated and will be removed from fpc in the future. Please use fpcmkcfg instead.';
 
 
 Var
@@ -231,6 +232,7 @@ begin
 end;
 
 begin
+  WriteLn(StdErr,SWarningDeprecated);
   Init;
   Try
     ProcessCommandLine;

+ 10 - 7
packages/fcl-base/src/fptemplate.pp

@@ -64,6 +64,7 @@ Type
     function GetValue(Key : String): String;
     procedure SetDelimiter(Index: integer; const AValue: TParseDelimiter);
     procedure SetValue(Key : String; const AValue: String);
+    Function IntParseString(Src : String) : String;
   Public
     Constructor Create;
     Destructor Destroy; override;
@@ -290,7 +291,7 @@ begin
       FOnGetParam(Self,Key,AValue);
     end;
   If Result and Recursive then
-    AValue:=ParseString(AValue);
+    AValue:=IntParseString(AValue);
 end;
 
 function TTemplateParser.ReplaceTag(const Key: String; TagParams:TStringList; out ReplaceWith: String): Boolean;
@@ -405,6 +406,12 @@ begin
 end;
 
 function TTemplateParser.ParseString(Src: String): String;
+begin
+  FParseLevel:=0;
+  Result:=IntParseString(Src);
+end;
+
+function TTemplateParser.IntParseString(Src: String): String;
 
 Var
   PN,PV,ReplaceWith : String;
@@ -485,6 +492,7 @@ begin
       else
         begin
         I:=TS-P;
+        inc(TS,Length(FStartDelimiter));
         TE:=FindDelimiter(TS,FEndDelimiter,SLen-I+1);
         If (TE=Nil) then
           begin
@@ -496,7 +504,6 @@ begin
           // Add text prior to template to result
           AddToString(Result,P,I);
           // retrieve template name
-          inc(TS,Length(FStartDelimiter));
           I:=TE-TS;
           Setlength(PN,I);
           Move(TS^,PN[1],I);
@@ -529,7 +536,6 @@ begin
   Finally
     SS.Free;
   end;
-  FParseLevel := 0;
   R:=ParseString(S);
   Result:=Length(R);
   If (Result>0) then
@@ -543,10 +549,7 @@ Var
 
 begin
   For I:=0 to Src.Count-1 do
-  begin
-    FParseLevel := 0;
     Dest.Add(ParseString(Src[i]));
-  end;
 end;
 
 { TFPCustomTemplate }
@@ -619,7 +622,7 @@ begin
           Result:=S.DataString;
           end
         else
-          Result:=P.ParseString(FTemplate);
+          Result:=P.IntParseString(FTemplate);
       Finally
         P.Free;
       end;