You've already forked lazarus-ccr
Delphi 7 compatibility fix : handle "TStringList.StrictDelimiter" + test
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3356 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -63,6 +63,9 @@ Type
|
|||||||
function LoadBufferFromFile(const AFileName : string) : TByteDynArray;
|
function LoadBufferFromFile(const AFileName : string) : TByteDynArray;
|
||||||
function LoadBufferFromStream(AStream : TStream) : TByteDynArray;
|
function LoadBufferFromStream(AStream : TStream) : TByteDynArray;
|
||||||
|
|
||||||
|
{$IFNDEF WST_HAS_STRICT_DELIMITER}
|
||||||
|
procedure SetListData(AList : TStringList; const AText : string);
|
||||||
|
{$ENDIF WST_HAS_STRICT_DELIMITER}
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
@ -256,6 +259,33 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{$IFNDEF WST_HAS_STRICT_DELIMITER}
|
||||||
|
procedure SetListData(AList : TStringList; const AText : string);
|
||||||
|
var
|
||||||
|
i, oldPos, c : Integer;
|
||||||
|
s : string;
|
||||||
|
begin
|
||||||
|
c := Length(AText);
|
||||||
|
oldPos := 1;
|
||||||
|
s := '';
|
||||||
|
i := 1;
|
||||||
|
while (i <= c) do begin
|
||||||
|
if (AText[i] = PROP_LIST_DELIMITER) then begin
|
||||||
|
s := Copy(AText,oldPos,(i-oldPos));
|
||||||
|
if (s <> '') then
|
||||||
|
AList.Add(s);
|
||||||
|
oldPos := i+1;
|
||||||
|
end;
|
||||||
|
i := i+1;
|
||||||
|
end;
|
||||||
|
if (i > oldPos) then begin
|
||||||
|
s := Copy(AText,oldPos,(i-oldPos));
|
||||||
|
if (s <> '') then
|
||||||
|
AList.Add(s);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
{$ENDIF WST_HAS_STRICT_DELIMITER}
|
||||||
|
|
||||||
procedure TPublishedPropertyManager.SetProperties(const APropsStr: string);
|
procedure TPublishedPropertyManager.SetProperties(const APropsStr: string);
|
||||||
var
|
var
|
||||||
lst : TStringList;
|
lst : TStringList;
|
||||||
@ -265,10 +295,14 @@ begin
|
|||||||
Exit;
|
Exit;
|
||||||
lst := TStringList.Create();
|
lst := TStringList.Create();
|
||||||
Try
|
Try
|
||||||
|
{$IFDEF WST_HAS_STRICT_DELIMITER}
|
||||||
lst.QuoteChar := #0;
|
lst.QuoteChar := #0;
|
||||||
lst.Delimiter := PROP_LIST_DELIMITER;
|
lst.Delimiter := PROP_LIST_DELIMITER;
|
||||||
lst.StrictDelimiter := True;
|
lst.StrictDelimiter := True;
|
||||||
lst.DelimitedText := APropsStr;
|
lst.DelimitedText := APropsStr;
|
||||||
|
{$ELSE WST_HAS_STRICT_DELIMITER}
|
||||||
|
SetListData(lst,APropsStr);
|
||||||
|
{$ENDIF WST_HAS_STRICT_DELIMITER}
|
||||||
for i := 0 to Pred(lst.Count) do
|
for i := 0 to Pred(lst.Count) do
|
||||||
SetProperty(lst.Names[i],lst.Values[lst.Names[i]]);
|
SetProperty(lst.Names[i],lst.Values[lst.Names[i]]);
|
||||||
Finally
|
Finally
|
||||||
|
@ -23,7 +23,7 @@ uses
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
TypInfo,
|
TypInfo,
|
||||||
base_service_intf, server_service_intf,
|
base_service_intf, server_service_intf,
|
||||||
library_imp_utils, parserutils;
|
library_imp_utils, parserutils, imp_utils;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -135,6 +135,9 @@ type
|
|||||||
TTest_Procs = class(TTestCase)
|
TTest_Procs = class(TTestCase)
|
||||||
published
|
published
|
||||||
procedure test_GetToken();
|
procedure test_GetToken();
|
||||||
|
{$IFNDEF WST_HAS_STRICT_DELIMITER}
|
||||||
|
procedure test_SetListData();
|
||||||
|
{$ENDIF WST_HAS_STRICT_DELIMITER}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -923,6 +926,27 @@ begin
|
|||||||
do_tests('#<#');
|
do_tests('#<#');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{$IFNDEF WST_HAS_STRICT_DELIMITER}
|
||||||
|
procedure TTest_Procs.test_SetListData();
|
||||||
|
var
|
||||||
|
ls : TStringList;
|
||||||
|
begin
|
||||||
|
ls := TStringList.Create();
|
||||||
|
try
|
||||||
|
SetListData(ls,'item1=azerty;item2=http: 123;item3=a b c');
|
||||||
|
CheckEquals(3,ls.Count,'Items count');
|
||||||
|
CheckEquals('item1',ls.Names[0]);
|
||||||
|
CheckEquals('azerty',ls.ValueFromIndex[0]);
|
||||||
|
CheckEquals('item2',ls.Names[1]);
|
||||||
|
CheckEquals('http: 123',ls.ValueFromIndex[1]);
|
||||||
|
CheckEquals('item3',ls.Names[2]);
|
||||||
|
CheckEquals('a b c',ls.ValueFromIndex[2]);
|
||||||
|
finally
|
||||||
|
ls.Free();
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
{$ENDIF WST_HAS_STRICT_DELIMITER}
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
ListToRelease := TInterfaceList.Create();
|
ListToRelease := TInterfaceList.Create();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user