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