mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-06-26 00:58:17 +02:00
* Template fixes
This commit is contained in:
parent
0bb2b47bf8
commit
509ba3b480
@ -385,7 +385,7 @@ begin
|
||||
if (NChars=0) then Exit;
|
||||
SLen:=Length(S);
|
||||
SetLength(S,SLen+NChars);
|
||||
Move(P^,S[Slen+1],NChars);
|
||||
Move(P^,S[Slen+1],NChars*SizeOf(Char));
|
||||
end;
|
||||
|
||||
procedure TTemplateParser.GetTagParams(var TagName:String; var TagParams : TStringList) ;
|
||||
@ -415,7 +415,7 @@ begin
|
||||
if i>(TS-SP) then
|
||||
i := TS-SP;
|
||||
SetLength(TP, I);
|
||||
Move(P^, TP[1], I);
|
||||
Move(P^, TP[1], I*SizeOf(Char));
|
||||
end;
|
||||
inc(TS, Length(FParamStartDelimiter));
|
||||
I:=TS-P;//index of param name
|
||||
@ -424,7 +424,7 @@ begin
|
||||
begin//Found param value separator
|
||||
I:=TM-TS;//lenght of param name
|
||||
SetLength(PName, I);
|
||||
Move(TS^, PName[1], I);//param name
|
||||
Move(TS^, PName[1], I*SizeOf(Char));//param name
|
||||
inc(TS, Length(FParamValueSeparator) + I);
|
||||
I := TS - P;//index of param value
|
||||
end;
|
||||
@ -434,7 +434,7 @@ begin
|
||||
begin//Found param end
|
||||
I:=TE-TS;//Param length
|
||||
Setlength(PValue,I);
|
||||
Move(TS^,PValue[1],I);//Param value
|
||||
Move(TS^,PValue[1],I*SizeOf(Char));//Param value
|
||||
if TM=nil then
|
||||
TagParams.Add(Trim(PValue))
|
||||
else
|
||||
@ -475,7 +475,8 @@ begin
|
||||
If (TS=Nil) then
|
||||
begin//Tag Start Delimiter not found
|
||||
TS:=P;
|
||||
P:=SP+SLen;
|
||||
P:=SP;
|
||||
Inc(P,SLen);
|
||||
end
|
||||
else
|
||||
begin
|
||||
@ -485,7 +486,8 @@ begin
|
||||
If (TE=Nil) then
|
||||
begin//Tag End Delimiter not found
|
||||
TS:=P;
|
||||
P:=SP+SLen;
|
||||
P:=SP;
|
||||
Inc(P,SLen);
|
||||
end
|
||||
else//Found start and end delimiters for the Tag
|
||||
begin
|
||||
@ -494,7 +496,7 @@ begin
|
||||
// Retrieve the full template tag (only tag name if no params specified)
|
||||
I:=TE-TS;//full Tag length
|
||||
Setlength(PN,I);
|
||||
Move(TS^,PN[1],I);//full Tag string (only tag name if no params specified)
|
||||
Move(TS^,PN[1],I*SizeOf(Char));//full Tag string (only tag name if no params specified)
|
||||
TagParams := TStringList.Create;
|
||||
try
|
||||
TagParams.Sorted := True;
|
||||
@ -504,7 +506,8 @@ begin
|
||||
finally
|
||||
TagParams.Free;
|
||||
end;
|
||||
P:=TE+Length(FEndDelimiter);
|
||||
P:=TE;
|
||||
Inc(P,Length(FEndDelimiter));
|
||||
TS:=P;
|
||||
end;
|
||||
end
|
||||
@ -529,7 +532,8 @@ begin
|
||||
If (TS=Nil) then
|
||||
begin
|
||||
TS:=P;
|
||||
P:=SP+SLen
|
||||
P:=SP;
|
||||
Inc(P,SLen);
|
||||
end
|
||||
else
|
||||
begin
|
||||
@ -539,7 +543,8 @@ begin
|
||||
If (TE=Nil) then
|
||||
begin
|
||||
TS:=P;
|
||||
P:=SP+SLen;
|
||||
P:=SP;
|
||||
Inc(P,SLen);
|
||||
end
|
||||
else
|
||||
begin
|
||||
@ -548,7 +553,7 @@ begin
|
||||
// retrieve template name
|
||||
I:=TE-TS;
|
||||
Setlength(PN,I);
|
||||
Move(TS^,PN[1],I);
|
||||
Move(TS^,PN[1],I*SizeOf(Char));
|
||||
If GetParam(PN,PV) then
|
||||
begin
|
||||
Result:=Result+PV;
|
||||
@ -579,7 +584,7 @@ begin
|
||||
SS.Free;
|
||||
end;
|
||||
R:=ParseString(S);
|
||||
Result:=Length(R);
|
||||
Result:=Length(R)*SizeOf(Char);
|
||||
If (Result>0) then
|
||||
Dest.Write(R[1],Result);
|
||||
end;
|
||||
@ -672,7 +677,11 @@ begin
|
||||
if (FFileName<>'') then
|
||||
begin
|
||||
F:=TFileStream.Create(FFileName,fmOpenRead);
|
||||
S:=TStringStream.Create('');
|
||||
{$IF SIZEOF(Char)=2}
|
||||
S:=TStringStream.Create('',TEncoding.Unicode);
|
||||
{$ELSE}
|
||||
S:=TStringStream.Create('',TEncoding.UTF8);
|
||||
{$ENDIF}
|
||||
end;
|
||||
Try
|
||||
P:=CreateParser;
|
||||
|
Loading…
Reference in New Issue
Block a user