|
@@ -32,7 +32,7 @@ begin
|
|
|
begin
|
|
|
I:=I+1;
|
|
|
J:=J+1;
|
|
|
- if S[i]=Quote then
|
|
|
+ if S[i]=Quote then
|
|
|
begin
|
|
|
System.Insert(Result,Quote,J);
|
|
|
J:=J+1;
|
|
@@ -47,7 +47,7 @@ Var I : Longint;
|
|
|
|
|
|
begin
|
|
|
result:='';
|
|
|
- For i:=0 to count-1 do
|
|
|
+ For i:=0 to count-1 do
|
|
|
begin
|
|
|
Result:=Result+QuoteString (Strings[I],'"');
|
|
|
if I<Count-1 then Result:=Result+',';
|
|
@@ -103,14 +103,14 @@ begin
|
|
|
P1:=P+1;
|
|
|
While P1^<>#0 do
|
|
|
begin
|
|
|
- If (P1^='"') and (P1[1]<>'"') then
|
|
|
+ If (P1^='"') and (P1[1]<>'"') then
|
|
|
break;
|
|
|
P1:=P1+1;
|
|
|
If P1^='"' then P1:=P1+1;
|
|
|
end;
|
|
|
- // P1 points to last quote, or to #0;
|
|
|
+ // P1 points to last quote, or to #0;
|
|
|
P:=P+1;
|
|
|
- If P1-P>0 then
|
|
|
+ If P1-P>0 then
|
|
|
begin
|
|
|
SetLength(Result,(P1-P));
|
|
|
L:=Pointer(Result);
|
|
@@ -184,7 +184,7 @@ end;
|
|
|
|
|
|
|
|
|
|
|
|
-Procedure TStrings.DefineProperties(Filer: TFiler);
|
|
|
+Procedure TStrings.DefineProperties(Filer: TFiler);
|
|
|
|
|
|
begin
|
|
|
end;
|
|
@@ -200,7 +200,7 @@ end;
|
|
|
|
|
|
|
|
|
|
|
|
-Function TStrings.GetCapacity: Integer;
|
|
|
+Function TStrings.GetCapacity: Integer;
|
|
|
|
|
|
begin
|
|
|
Result:=Count;
|
|
@@ -208,7 +208,7 @@ end;
|
|
|
|
|
|
|
|
|
|
|
|
-Function TStrings.GetObject(Index: Integer): TObject;
|
|
|
+Function TStrings.GetObject(Index: Integer): TObject;
|
|
|
|
|
|
begin
|
|
|
Result:=Nil;
|
|
@@ -216,7 +216,7 @@ end;
|
|
|
|
|
|
|
|
|
|
|
|
-Function TStrings.GetTextStr: string;
|
|
|
+Function TStrings.GetTextStr: string;
|
|
|
|
|
|
Const
|
|
|
{$ifdef linux}
|
|
@@ -226,21 +226,20 @@ Const
|
|
|
{$endif}
|
|
|
|
|
|
Var P : Pchar;
|
|
|
- I,L : Longint;
|
|
|
+ I,L : Longint;
|
|
|
S : String;
|
|
|
- PS : Pointer;
|
|
|
|
|
|
begin
|
|
|
// Determine needed place
|
|
|
L:=0;
|
|
|
For I:=0 to count-1 do L:=L+Length(Strings[I])+NewLineSize;
|
|
|
Setlength(Result,L);
|
|
|
- P:=Pointer(Result);
|
|
|
+ P:=Pointer(Result);
|
|
|
For i:=0 To count-1 do
|
|
|
begin
|
|
|
S:=Strings[I];
|
|
|
L:=Length(S);
|
|
|
- if L<>0 then
|
|
|
+ if L<>0 then
|
|
|
System.Move(Pointer(S)^,P^,L);
|
|
|
P:=P+L;
|
|
|
{$ifndef linux}
|
|
@@ -255,7 +254,7 @@ end;
|
|
|
|
|
|
|
|
|
|
|
|
-Procedure TStrings.Put(Index: Integer; const S: string);
|
|
|
+Procedure TStrings.Put(Index: Integer; const S: string);
|
|
|
|
|
|
Var Obj : TObject;
|
|
|
|
|
@@ -267,7 +266,7 @@ end;
|
|
|
|
|
|
|
|
|
|
|
|
-Procedure TStrings.PutObject(Index: Integer; AObject: TObject);
|
|
|
+Procedure TStrings.PutObject(Index: Integer; AObject: TObject);
|
|
|
|
|
|
begin
|
|
|
// Empty.
|
|
@@ -275,14 +274,14 @@ end;
|
|
|
|
|
|
|
|
|
|
|
|
-Procedure TStrings.SetCapacity(NewCapacity: Integer);
|
|
|
+Procedure TStrings.SetCapacity(NewCapacity: Integer);
|
|
|
|
|
|
begin
|
|
|
// Empty.
|
|
|
end;
|
|
|
|
|
|
|
|
|
-Procedure TStrings.SetTextStr(const Value: string);
|
|
|
+Procedure TStrings.SetTextStr(const Value: string);
|
|
|
|
|
|
begin
|
|
|
SetText(PChar(Value));
|
|
@@ -290,14 +289,14 @@ end;
|
|
|
|
|
|
|
|
|
|
|
|
-Procedure TStrings.SetUpdateState(Updating: Boolean);
|
|
|
+Procedure TStrings.SetUpdateState(Updating: Boolean);
|
|
|
|
|
|
begin
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
-destructor TSTrings.Destroy;
|
|
|
+destructor TSTrings.Destroy;
|
|
|
|
|
|
begin
|
|
|
inherited destroy;
|
|
@@ -305,7 +304,7 @@ end;
|
|
|
|
|
|
|
|
|
|
|
|
-Function TStrings.Add(const S: string): Integer;
|
|
|
+Function TStrings.Add(const S: string): Integer;
|
|
|
|
|
|
begin
|
|
|
Result:=Count;
|
|
@@ -314,7 +313,7 @@ end;
|
|
|
|
|
|
|
|
|
|
|
|
-Function TStrings.AddObject(const S: string; AObject: TObject): Integer;
|
|
|
+Function TStrings.AddObject(const S: string; AObject: TObject): Integer;
|
|
|
|
|
|
begin
|
|
|
Result:=Add(S);
|
|
@@ -331,7 +330,7 @@ end;
|
|
|
|
|
|
|
|
|
|
|
|
-Procedure TStrings.AddStrings(TheStrings: TStrings);
|
|
|
+Procedure TStrings.AddStrings(TheStrings: TStrings);
|
|
|
|
|
|
Var Runner : longint;
|
|
|
|
|
@@ -342,7 +341,7 @@ end;
|
|
|
|
|
|
|
|
|
|
|
|
-Procedure TStrings.Assign(Source: TPersistent);
|
|
|
+Procedure TStrings.Assign(Source: TPersistent);
|
|
|
|
|
|
begin
|
|
|
If Source is TStrings then
|
|
@@ -378,14 +377,14 @@ begin
|
|
|
Result:=False;
|
|
|
Nr:=Self.Count;
|
|
|
if Nr<>TheStrings.Count then exit;
|
|
|
- For Runner:=0 to Nr-1 do
|
|
|
+ For Runner:=0 to Nr-1 do
|
|
|
If Strings[Runner]<>TheStrings[Runner] then exit;
|
|
|
Result:=True;
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
-Procedure TStrings.Exchange(Index1, Index2: Integer);
|
|
|
+Procedure TStrings.Exchange(Index1, Index2: Integer);
|
|
|
|
|
|
Var
|
|
|
Obj : TObject;
|
|
@@ -402,7 +401,7 @@ end;
|
|
|
|
|
|
|
|
|
|
|
|
-Function TStrings.GetText: PChar;
|
|
|
+Function TStrings.GetText: PChar;
|
|
|
|
|
|
begin
|
|
|
Result:=StrNew(Pchar(Self.Text));
|
|
@@ -410,7 +409,7 @@ end;
|
|
|
|
|
|
|
|
|
|
|
|
-Function TStrings.IndexOf(const S: string): Integer;
|
|
|
+Function TStrings.IndexOf(const S: string): Integer;
|
|
|
|
|
|
|
|
|
begin
|
|
@@ -433,7 +432,7 @@ begin
|
|
|
if (len>0) and (Name=Copy(Strings[Result],1,Len)) then exit;
|
|
|
inc(result);
|
|
|
end;
|
|
|
- result:=-1;
|
|
|
+ result:=-1;
|
|
|
end;
|
|
|
|
|
|
|
|
@@ -458,7 +457,7 @@ end;
|
|
|
|
|
|
|
|
|
|
|
|
-Procedure TStrings.LoadFromFile(const FileName: string);
|
|
|
+Procedure TStrings.LoadFromFile(const FileName: string);
|
|
|
|
|
|
Var TheStream : TFileStream;
|
|
|
|
|
@@ -470,18 +469,18 @@ end;
|
|
|
|
|
|
|
|
|
|
|
|
-Procedure TStrings.LoadFromStream(Stream: TStream);
|
|
|
+Procedure TStrings.LoadFromStream(Stream: TStream);
|
|
|
{
|
|
|
- Borlands method is no goed, since a pipe for
|
|
|
- Instance doesn't have a size.
|
|
|
+ Borlands method is no goed, since a pipe for
|
|
|
+ Instance doesn't have a size.
|
|
|
So we must do it the hard way.
|
|
|
}
|
|
|
Const BufSize = 1024;
|
|
|
|
|
|
Procedure ReallocMem (Var B : Pointer; OldSize :longint);
|
|
|
-
|
|
|
+
|
|
|
Var NewB : Pointer;
|
|
|
-
|
|
|
+
|
|
|
begin
|
|
|
GetMem(NewB,OldSIze+BufSize);
|
|
|
If OldSize>0 then // assume that if size=0, B also Nil
|
|
@@ -512,7 +511,7 @@ end;
|
|
|
|
|
|
|
|
|
|
|
|
-Procedure TStrings.Move(CurIndex, NewIndex: Integer);
|
|
|
+Procedure TStrings.Move(CurIndex, NewIndex: Integer);
|
|
|
|
|
|
Var Obj : TObject;
|
|
|
Str : String;
|
|
@@ -521,12 +520,12 @@ begin
|
|
|
Obj:=Objects[CurIndex];
|
|
|
Str:=Strings[CurIndex];
|
|
|
Delete(Curindex);
|
|
|
- InsertObject(NewIndex,Str,Obj);
|
|
|
+ InsertObject(NewIndex,Str,Obj);
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
-Procedure TStrings.SaveToFile(const FileName: string);
|
|
|
+Procedure TStrings.SaveToFile(const FileName: string);
|
|
|
|
|
|
Var TheStream : TFileStream;
|
|
|
|
|
@@ -538,7 +537,7 @@ end;
|
|
|
|
|
|
|
|
|
|
|
|
-Procedure TStrings.SaveToStream(Stream: TStream);
|
|
|
+Procedure TStrings.SaveToStream(Stream: TStream);
|
|
|
|
|
|
VAr S : String;
|
|
|
|
|
@@ -565,13 +564,13 @@ begin
|
|
|
end;
|
|
|
|
|
|
|
|
|
-Procedure TStrings.SetText(TheText: PChar);
|
|
|
+Procedure TStrings.SetText(TheText: PChar);
|
|
|
|
|
|
Var S : String;
|
|
|
-
|
|
|
+
|
|
|
begin
|
|
|
Clear;
|
|
|
- While GetNextLine (TheText,S) do
|
|
|
+ While GetNextLine (TheText,S) do
|
|
|
Add(S);
|
|
|
end;
|
|
|
|
|
@@ -604,11 +603,11 @@ Var Extra : Longint;
|
|
|
begin
|
|
|
If FCapacity>64 then
|
|
|
Extra:=FCapacity Div 4
|
|
|
- Else If FCapacity>8 Then
|
|
|
+ Else If FCapacity>8 Then
|
|
|
Extra:=16
|
|
|
- Else
|
|
|
+ Else
|
|
|
Extra:=4;
|
|
|
- SetCapacity(FCapacity+Extra);
|
|
|
+ SetCapacity(FCapacity+Extra);
|
|
|
end;
|
|
|
|
|
|
|
|
@@ -626,7 +625,7 @@ begin
|
|
|
Repeat
|
|
|
While AnsiCompareText(Flist^[I].Fstring,Pivot)<0 do Inc(I);
|
|
|
While AnsiCompareText(Flist^[J].Fstring,Pivot)>0 do Dec(J);
|
|
|
- If I<=J then
|
|
|
+ If I<=J then
|
|
|
begin
|
|
|
ExchangeItems(I,J); // No check, indices are correct.
|
|
|
Inc(I);
|
|
@@ -668,7 +667,7 @@ end;
|
|
|
|
|
|
|
|
|
|
|
|
-Procedure TStringList.Changed;
|
|
|
+Procedure TStringList.Changed;
|
|
|
|
|
|
begin
|
|
|
If (FUpdateCount=0) Then
|
|
@@ -678,7 +677,7 @@ end;
|
|
|
|
|
|
|
|
|
|
|
|
-Procedure TStringList.Changing;
|
|
|
+Procedure TStringList.Changing;
|
|
|
|
|
|
begin
|
|
|
If FUpdateCount=0 then
|
|
@@ -688,7 +687,7 @@ end;
|
|
|
|
|
|
|
|
|
|
|
|
-Function TStringList.Get(Index: Integer): string;
|
|
|
+Function TStringList.Get(Index: Integer): string;
|
|
|
|
|
|
begin
|
|
|
If (Index<0) or (INdex>=Fcount) then
|
|
@@ -698,7 +697,7 @@ end;
|
|
|
|
|
|
|
|
|
|
|
|
-Function TStringList.GetCapacity: Integer;
|
|
|
+Function TStringList.GetCapacity: Integer;
|
|
|
|
|
|
begin
|
|
|
Result:=FCapacity;
|
|
@@ -706,7 +705,7 @@ end;
|
|
|
|
|
|
|
|
|
|
|
|
-Function TStringList.GetCount: Integer;
|
|
|
+Function TStringList.GetCount: Integer;
|
|
|
|
|
|
begin
|
|
|
Result:=FCount;
|
|
@@ -714,7 +713,7 @@ end;
|
|
|
|
|
|
|
|
|
|
|
|
-Function TStringList.GetObject(Index: Integer): TObject;
|
|
|
+Function TStringList.GetObject(Index: Integer): TObject;
|
|
|
|
|
|
begin
|
|
|
If (Index<0) or (INdex>=Fcount) then
|
|
@@ -724,10 +723,10 @@ end;
|
|
|
|
|
|
|
|
|
|
|
|
-Procedure TStringList.Put(Index: Integer; const S: string);
|
|
|
+Procedure TStringList.Put(Index: Integer; const S: string);
|
|
|
|
|
|
begin
|
|
|
- If Sorted then
|
|
|
+ If Sorted then
|
|
|
Error(SSortedListError,0);
|
|
|
If (Index<0) or (INdex>=Fcount) then
|
|
|
Error (SListIndexError,Index);
|
|
@@ -738,26 +737,26 @@ end;
|
|
|
|
|
|
|
|
|
|
|
|
-Procedure TStringList.PutObject(Index: Integer; AObject: TObject);
|
|
|
+Procedure TStringList.PutObject(Index: Integer; AObject: TObject);
|
|
|
|
|
|
begin
|
|
|
If (Index<0) or (INdex>=Fcount) then
|
|
|
Error (SListIndexError,Index);
|
|
|
Changing;
|
|
|
- Flist^[Index].FObject:=AObject;
|
|
|
+ Flist^[Index].FObject:=AObject;
|
|
|
Changed;
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
-Procedure TStringList.SetCapacity(NewCapacity: Integer);
|
|
|
+Procedure TStringList.SetCapacity(NewCapacity: Integer);
|
|
|
|
|
|
Var NewList : Pointer;
|
|
|
MSize : Longint;
|
|
|
-
|
|
|
+
|
|
|
begin
|
|
|
- If (NewCapacity<0) then
|
|
|
- Error (SListCapacityError,NewCapacity);
|
|
|
+ If (NewCapacity<0) then
|
|
|
+ Error (SListCapacityError,NewCapacity);
|
|
|
If NewCapacity>FCapacity then
|
|
|
begin
|
|
|
GetMem (NewList,NewCapacity*SizeOf(TStringItem));
|
|
@@ -783,7 +782,7 @@ end;
|
|
|
|
|
|
|
|
|
|
|
|
-Procedure TStringList.SetUpdateState(Updating: Boolean);
|
|
|
+Procedure TStringList.SetUpdateState(Updating: Boolean);
|
|
|
|
|
|
begin
|
|
|
If Updating then
|
|
@@ -794,7 +793,7 @@ end;
|
|
|
|
|
|
|
|
|
|
|
|
-destructor TStringList.Destroy;
|
|
|
+destructor TStringList.Destroy;
|
|
|
|
|
|
Var I : Longint;
|
|
|
|
|
@@ -802,23 +801,23 @@ begin
|
|
|
FOnChange:=Nil;
|
|
|
FOnChanging:=Nil;
|
|
|
// This will force a dereference. Can be done better...
|
|
|
- For I:=0 to FCount-1 do
|
|
|
+ For I:=0 to FCount-1 do
|
|
|
FList^[I].FString:='';
|
|
|
FCount:=0;
|
|
|
- SetCapacity(0);
|
|
|
- Inherited destroy;
|
|
|
+ SetCapacity(0);
|
|
|
+ Inherited destroy;
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
-Function TStringList.Add(const S: string): Integer;
|
|
|
+Function TStringList.Add(const S: string): Integer;
|
|
|
|
|
|
begin
|
|
|
If Not Sorted then
|
|
|
Result:=FCount
|
|
|
else
|
|
|
- If Find (S,Result) then
|
|
|
- Case DUplicates of
|
|
|
+ If Find (S,Result) then
|
|
|
+ Case DUplicates of
|
|
|
DupIgnore : Exit;
|
|
|
DupError : Error(SDuplicateString,0)
|
|
|
end;
|
|
@@ -827,7 +826,7 @@ end;
|
|
|
|
|
|
|
|
|
|
|
|
-Procedure TStringList.Clear;
|
|
|
+Procedure TStringList.Clear;
|
|
|
|
|
|
Var I : longint;
|
|
|
|
|
@@ -840,7 +839,7 @@ end;
|
|
|
|
|
|
|
|
|
|
|
|
-Procedure TStringList.Delete(Index: Integer);
|
|
|
+Procedure TStringList.Delete(Index: Integer);
|
|
|
|
|
|
begin
|
|
|
If (Index<0) or (Index>=FCount) then
|
|
@@ -855,19 +854,19 @@ end;
|
|
|
|
|
|
|
|
|
|
|
|
-Procedure TStringList.Exchange(Index1, Index2: Integer);
|
|
|
+Procedure TStringList.Exchange(Index1, Index2: Integer);
|
|
|
|
|
|
begin
|
|
|
- If (Index1<0) or (Index1>=FCount) then
|
|
|
+ If (Index1<0) or (Index1>=FCount) then
|
|
|
Error(SListIndexError,Index1);
|
|
|
- If (Index2<0) or (Index2>=FCount) then
|
|
|
+ If (Index2<0) or (Index2>=FCount) then
|
|
|
Error(SListIndexError,Index1);
|
|
|
Changing;
|
|
|
ExchangeItems(Index1,Index2);
|
|
|
changed;
|
|
|
end;
|
|
|
|
|
|
-Function TStringList.Find(const S: string; var Index: Integer): Boolean;
|
|
|
+Function TStringList.Find(const S: string; var Index: Integer): Boolean;
|
|
|
|
|
|
{ Searches for the first string <= S, returns True if exact match,
|
|
|
sets index to the index f the found string. }
|
|
@@ -883,7 +882,7 @@ begin
|
|
|
begin
|
|
|
I:=(L+R) div 2;
|
|
|
Temp:=AnsiCompareText(FList^ [I].FString,S);
|
|
|
- If Temp<0 then
|
|
|
+ If Temp<0 then
|
|
|
L:=I+1
|
|
|
else
|
|
|
begin
|
|
@@ -895,38 +894,38 @@ begin
|
|
|
end;
|
|
|
end;
|
|
|
end;
|
|
|
- Index:=L;
|
|
|
+ Index:=L;
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
-Function TStringList.IndexOf(const S: string): Integer;
|
|
|
+Function TStringList.IndexOf(const S: string): Integer;
|
|
|
|
|
|
begin
|
|
|
- If Not Sorted then
|
|
|
+ If Not Sorted then
|
|
|
Result:=Inherited indexOf(S)
|
|
|
else
|
|
|
// faster using binary search...
|
|
|
- If Not Find (S,Result) then
|
|
|
+ If Not Find (S,Result) then
|
|
|
Result:=-1;
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
-Procedure TStringList.Insert(Index: Integer; const S: string);
|
|
|
+Procedure TStringList.Insert(Index: Integer; const S: string);
|
|
|
|
|
|
begin
|
|
|
If Sorted then
|
|
|
Error (SSortedListError,0)
|
|
|
- else
|
|
|
+ else
|
|
|
If (Index<0) or (Index>FCount) then
|
|
|
Error (SListIndexError,Index)
|
|
|
- else
|
|
|
+ else
|
|
|
InsertItem (Index,S);
|
|
|
end;
|
|
|
|
|
|
|
|
|
-Procedure TStringList.Sort;
|
|
|
+Procedure TStringList.Sort;
|
|
|
|
|
|
begin
|
|
|
If Not Sorted and (FCount>1) then
|
|
@@ -939,45 +938,7 @@ end;
|
|
|
|
|
|
{
|
|
|
$Log$
|
|
|
- Revision 1.14 1999-02-06 08:21:00 michael
|
|
|
- + Finally fixed loadfromstream
|
|
|
-
|
|
|
- Revision 1.13 1999/02/04 21:41:12 michael
|
|
|
- + Fixed loadfromstream bug
|
|
|
-
|
|
|
- Revision 1.12 1999/02/04 17:19:14 michael
|
|
|
- + fixed getvalue
|
|
|
-
|
|
|
- Revision 1.11 1999/02/02 23:49:23 florian
|
|
|
- * new lines for non linux system fixed (tstrings class)
|
|
|
-
|
|
|
- Revision 1.10 1999/02/02 12:54:06 florian
|
|
|
- * tstrings.gettextstr fixed, setlength got a wrong length (0 instead L)
|
|
|
-
|
|
|
- Revision 1.9 1999/01/28 23:55:43 florian
|
|
|
- * made it compilable
|
|
|
-
|
|
|
- Revision 1.8 1998/11/13 09:40:16 michael
|
|
|
- + Restored old version
|
|
|
-
|
|
|
- Revision 1.6 1998/11/09 10:07:24 michael
|
|
|
- + Bugfix in setcapacity, sizes were wrong
|
|
|
-
|
|
|
- Revision 1.5 1998/10/30 14:52:52 michael
|
|
|
- + Added format in interface
|
|
|
- + Some errors in parser fixed, it uses exceptions now
|
|
|
- + Strings now has no more syntax errors.
|
|
|
-
|
|
|
- Revision 1.4 1998/10/24 13:45:37 michael
|
|
|
- + Implemented stringlist. Untested, since classes broken.
|
|
|
-
|
|
|
- Revision 1.3 1998/05/07 14:16:51 michael
|
|
|
- + Finished TStrings implementation.
|
|
|
-
|
|
|
- Revision 1.2 1998/05/06 12:58:53 michael
|
|
|
- + Initial implementation
|
|
|
-
|
|
|
- Revision 1.1 1998/05/04 14:30:12 michael
|
|
|
- * Split file according to Class; implemented dummys for all methods, so unit compiles.
|
|
|
+ Revision 1.15 1999-04-08 10:18:56 peter
|
|
|
+ * makefile updates
|
|
|
|
|
|
}
|