stringl.inc 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999
  1. {
  2. $Id$
  3. This file is part of the Free Component Library (FCL)
  4. Copyright (c) 1999-2000 by the Free Pascal development team
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. {****************************************************************************}
  12. {* TStrings *}
  13. {****************************************************************************}
  14. // Function to quote text. Should move maybe to sysutils !!
  15. // Also, it is not clear at this point what exactly should be done.
  16. { //!! is used to mark unsupported things. }
  17. Function QuoteString (Const S : String; Quote : String) : String;
  18. Var I,J : Longint;
  19. begin
  20. I:=0;
  21. J:=0;
  22. Result:=S;
  23. While I<Length(S) do
  24. begin
  25. I:=I+1;
  26. J:=J+1;
  27. if S[i]=Quote then
  28. begin
  29. System.Insert(Result,Quote,J);
  30. J:=J+1;
  31. end;
  32. end;
  33. Result:=Quote+Result+Quote;
  34. end;
  35. function TStrings.GetCommaText: string;
  36. Var I : Longint;
  37. begin
  38. result:='';
  39. For i:=0 to count-1 do
  40. begin
  41. Result:=Result+QuoteString (Strings[I],'"');
  42. if I<Count-1 then Result:=Result+',';
  43. end;
  44. If Length(Result)=0 then Result:='""';
  45. end;
  46. function TStrings.GetName(Index: Integer): string;
  47. Var L : longint;
  48. begin
  49. Result:=Strings[Index];
  50. L:=Pos('=',Result);
  51. If L<>0 then
  52. Result:=Copy(Result,1,L-1)
  53. else
  54. Result:='';
  55. end;
  56. Function TStrings.GetValue(const Name: string): string;
  57. Var L : longint;
  58. begin
  59. Result:='';
  60. L:=IndexOfName(Name);
  61. If L<>-1 then
  62. begin
  63. Result:=Strings[L];
  64. L:=Pos('=',Result);
  65. System.Delete (Result,1,L);
  66. end;
  67. end;
  68. Procedure TStrings.ReadData(Reader: TReader);
  69. begin
  70. end;
  71. Function GetQuotedString (Var P : Pchar) : AnsiString;
  72. Var P1,L : Pchar;
  73. begin
  74. Result:='';
  75. P1:=P+1;
  76. While P1^<>#0 do
  77. begin
  78. If (P1^='"') and (P1[1]<>'"') then
  79. break;
  80. P1:=P1+1;
  81. If P1^='"' then P1:=P1+1;
  82. end;
  83. // P1 points to last quote, or to #0;
  84. P:=P+1;
  85. If P1-P>0 then
  86. begin
  87. SetLength(Result,(P1-P));
  88. L:=Pointer(Result);
  89. Move (P^,L^,P1-P);
  90. P:=P1+1;
  91. end;
  92. end;
  93. Function GetNextQuotedChar (P : PChar; Var S : String): Boolean;
  94. Var PS,L : PChar;
  95. begin
  96. Result:=False;
  97. If P^=#0 then exit;
  98. S:='';
  99. While (p^<>#0) and (byte(p^)<=byte(' ')) do P:=P+1;
  100. PS:=P;
  101. If P^='"' then
  102. S:=GetQuotedString(P)
  103. else
  104. begin
  105. While (p^>' ') and (P^<>',') do P:=P+1;
  106. Setlength (S,P-PS);
  107. L:=Pointer(S);
  108. Move (PS^,L,P-PS);
  109. end;
  110. Result:=True;
  111. end;
  112. Procedure TStrings.SetCommaText(const Value: string);
  113. Var P : Pointer;
  114. S : String;
  115. begin
  116. Self.Clear;
  117. P:=Pointer(Value);
  118. While GetNextQuotedChar (P,S) do Add (S);
  119. end;
  120. Procedure TStrings.SetStringsAdapter(const Value: IStringsAdapter);
  121. begin
  122. end;
  123. Procedure TStrings.SetValue(const Name, Value: string);
  124. Var L : longint;
  125. begin
  126. L:=IndexOfName(Name);
  127. if L=-1 then
  128. Add (Name+'='+Value)
  129. else
  130. Strings[L]:=Name+'='+value;
  131. end;
  132. Procedure TStrings.WriteData(Writer: TWriter);
  133. begin
  134. end;
  135. Procedure TStrings.DefineProperties(Filer: TFiler);
  136. begin
  137. end;
  138. Procedure TStrings.Error(const Msg: string; Data: Integer);
  139. begin
  140. //!! Need to get correct address !!
  141. Raise EStringListError.CreateFmt(Msg,[Data]);
  142. end;
  143. Function TStrings.GetCapacity: Integer;
  144. begin
  145. Result:=Count;
  146. end;
  147. Function TStrings.GetObject(Index: Integer): TObject;
  148. begin
  149. Result:=Nil;
  150. end;
  151. Function TStrings.GetTextStr: string;
  152. Const
  153. {$ifdef linux}
  154. NewLineSize=1;
  155. {$else}
  156. NewLineSize=2;
  157. {$endif}
  158. Var P : Pchar;
  159. I,L : Longint;
  160. S : String;
  161. begin
  162. // Determine needed place
  163. L:=0;
  164. For I:=0 to count-1 do
  165. L:=L+Length(Strings[I])+NewLineSize;
  166. Setlength(Result,L);
  167. P:=Pointer(Result);
  168. For i:=0 To count-1 do
  169. begin
  170. S:=Strings[I];
  171. L:=Length(S);
  172. if L<>0 then
  173. System.Move(Pointer(S)^,P^,L);
  174. P:=P+L;
  175. {$ifndef linux}
  176. p[0]:=#13;
  177. p[1]:=#10;
  178. {$else}
  179. p[0]:=#10;
  180. {$endif}
  181. P:=P+NewLineSize;
  182. end;
  183. end;
  184. Procedure TStrings.Put(Index: Integer; const S: string);
  185. Var Obj : TObject;
  186. begin
  187. Obj:=Objects[Index];
  188. Delete(Index);
  189. InsertObject(Index,S,Obj);
  190. end;
  191. Procedure TStrings.PutObject(Index: Integer; AObject: TObject);
  192. begin
  193. // Empty.
  194. end;
  195. Procedure TStrings.SetCapacity(NewCapacity: Integer);
  196. begin
  197. // Empty.
  198. end;
  199. Procedure TStrings.SetTextStr(const Value: string);
  200. begin
  201. SetText(PChar(Value));
  202. end;
  203. Procedure TStrings.SetUpdateState(Updating: Boolean);
  204. begin
  205. end;
  206. destructor TSTrings.Destroy;
  207. begin
  208. inherited destroy;
  209. end;
  210. Function TStrings.Add(const S: string): Integer;
  211. begin
  212. Result:=Count;
  213. Insert (Count,S);
  214. end;
  215. Function TStrings.AddObject(const S: string; AObject: TObject): Integer;
  216. begin
  217. Result:=Add(S);
  218. Objects[result]:=AObject;
  219. end;
  220. Procedure TStrings.Append(const S: string);
  221. begin
  222. Add (S);
  223. end;
  224. Procedure TStrings.AddStrings(TheStrings: TStrings);
  225. Var Runner : longint;
  226. begin
  227. try
  228. beginupdate;
  229. For Runner:=0 to TheStrings.Count-1 do
  230. self.AddObject (Thestrings[Runner],TheStrings.Objects[Runner]);
  231. finally
  232. EndUpdate;
  233. end;
  234. end;
  235. Procedure TStrings.Assign(Source: TPersistent);
  236. begin
  237. Try
  238. BeginUpdate;
  239. If Source is TStrings then
  240. begin
  241. clear;
  242. AddStrings(TStrings(Source));
  243. exit;
  244. end;
  245. Inherited Assign(Source);
  246. finally
  247. EndUpdate;
  248. end;
  249. end;
  250. Procedure TStrings.BeginUpdate;
  251. begin
  252. inc(FUpdateCount);
  253. if FUpdateCount = 1 then SetUpdateState(true);
  254. end;
  255. Procedure TStrings.EndUpdate;
  256. begin
  257. If FUpdateCount>0 then
  258. Dec(FUpdateCount);
  259. if FUpdateCount=0 then
  260. SetUpdateState(False);
  261. end;
  262. Function TStrings.Equals(TheStrings: TStrings): Boolean;
  263. Var Runner,Nr : Longint;
  264. begin
  265. Result:=False;
  266. Nr:=Self.Count;
  267. if Nr<>TheStrings.Count then exit;
  268. For Runner:=0 to Nr-1 do
  269. If Strings[Runner]<>TheStrings[Runner] then exit;
  270. Result:=True;
  271. end;
  272. Procedure TStrings.Exchange(Index1, Index2: Integer);
  273. Var
  274. Obj : TObject;
  275. Str : String;
  276. begin
  277. Try
  278. beginUpdate;
  279. Obj:=Objects[Index1];
  280. Str:=Strings[Index1];
  281. Objects[Index1]:=Objects[Index2];
  282. Strings[Index1]:=Strings[Index2];
  283. Objects[Index2]:=Obj;
  284. Strings[Index2]:=Str;
  285. finally
  286. EndUpdate;
  287. end;
  288. end;
  289. Function TStrings.GetText: PChar;
  290. begin
  291. Result:=StrNew(Pchar(Self.Text));
  292. end;
  293. Function TStrings.IndexOf(const S: string): Integer;
  294. begin
  295. Result:=0;
  296. While (Result<Count) and (Strings[Result]<>S) do Result:=Result+1;
  297. if Result=Count then Result:=-1;
  298. end;
  299. Function TStrings.IndexOfName(const Name: string): Integer;
  300. Var len : longint;
  301. begin
  302. Result:=0;
  303. while (Result<Count) do
  304. begin
  305. len:=pos('=',Strings[Result])-1;
  306. if (len>0) and (Name=Copy(Strings[Result],1,Len)) then exit;
  307. inc(result);
  308. end;
  309. result:=-1;
  310. end;
  311. Function TStrings.IndexOfObject(AObject: TObject): Integer;
  312. begin
  313. Result:=0;
  314. While (Result<count) and (Objects[Result]<>AObject) do Result:=Result+1;
  315. If Result=Count then Result:=-1;
  316. end;
  317. Procedure TStrings.InsertObject(Index: Integer; const S: string;
  318. AObject: TObject);
  319. begin
  320. Insert (Index,S);
  321. Objects[Index]:=AObject;
  322. end;
  323. Procedure TStrings.LoadFromFile(const FileName: string);
  324. Var TheStream : TFileStream;
  325. begin
  326. TheStream:=TFileStream.Create(FileName,fmOpenRead);
  327. LoadFromStream(TheStream);
  328. TheStream.Free;
  329. end;
  330. Procedure TStrings.LoadFromStream(Stream: TStream);
  331. {
  332. Borlands method is no goed, since a pipe for
  333. Instance doesn't have a size.
  334. So we must do it the hard way.
  335. }
  336. Const
  337. BufSize = 1024;
  338. Var
  339. Buffer : Pointer;
  340. BytesRead,
  341. BufLen : Longint;
  342. begin
  343. // reread into a buffer
  344. try
  345. beginupdate;
  346. Buffer:=Nil;
  347. BufLen:=0;
  348. Repeat
  349. ReAllocMem(Buffer,BufLen+BufSize);
  350. BytesRead:=Stream.Read((Buffer+BufLen)^,BufSize);
  351. inc(BufLen,BufSize);
  352. Until BytesRead<>BufSize;
  353. // Null-terminate !!
  354. Pchar(Buffer)[BufLen-BufSize+BytesRead]:=#0;
  355. Text:=PChar(Buffer);
  356. FreeMem(Buffer);
  357. finally
  358. EndUpdate;
  359. end;
  360. end;
  361. Procedure TStrings.Move(CurIndex, NewIndex: Integer);
  362. Var
  363. Obj : TObject;
  364. Str : String;
  365. begin
  366. Obj:=Objects[CurIndex];
  367. Str:=Strings[CurIndex];
  368. Delete(Curindex);
  369. InsertObject(NewIndex,Str,Obj);
  370. end;
  371. Procedure TStrings.SaveToFile(const FileName: string);
  372. Var TheStream : TFileStream;
  373. begin
  374. TheStream:=TFileStream.Create(FileName,fmCreate);
  375. SaveToStream(TheStream);
  376. TheStream.Free;
  377. end;
  378. Procedure TStrings.SaveToStream(Stream: TStream);
  379. Var
  380. S : String;
  381. begin
  382. S:=Text;
  383. Stream.Write(Pointer(S)^,Length(S));
  384. end;
  385. Function GetNextLine (Var P : Pchar; Var S : String) : Boolean;
  386. Var PS : PChar;
  387. begin
  388. S:='';
  389. Result:=False;
  390. If P^=#0 then exit;
  391. PS:=P;
  392. While not (P^ in [#0,#10,#13]) do P:=P+1;
  393. SetLength (S,P-PS);
  394. System.Move (PS^,Pointer(S)^,P-PS);
  395. If P^=#13 then P:=P+1;
  396. If P^=#10 then
  397. P:=P+1; // Point to character after #10(#13)
  398. Result:=True;
  399. end;
  400. Procedure TStrings.SetText(TheText: PChar);
  401. Var S : String;
  402. begin
  403. Try
  404. beginUpdate;
  405. Clear;
  406. While GetNextLine (TheText,S) do
  407. Add(S);
  408. finally
  409. EndUpdate;
  410. end;
  411. end;
  412. {****************************************************************************}
  413. {* TStringList *}
  414. {****************************************************************************}
  415. Procedure TStringList.ExchangeItems(Index1, Index2: Integer);
  416. Var P1,P2 : Pointer;
  417. begin
  418. P1:=Pointer(Flist^[Index1].FString);
  419. P2:=Pointer(Flist^[Index1].FObject);
  420. Pointer(Flist^[Index1].Fstring):=Pointer(Flist^[Index2].Fstring);
  421. Pointer(Flist^[Index1].FObject):=Pointer(Flist^[Index2].FObject);
  422. Pointer(Flist^[Index2].Fstring):=P1;
  423. Pointer(Flist^[Index2].FObject):=P2;
  424. end;
  425. Procedure TStringList.Grow;
  426. Var Extra : Longint;
  427. begin
  428. If FCapacity>64 then
  429. Extra:=FCapacity Div 4
  430. Else If FCapacity>8 Then
  431. Extra:=16
  432. Else
  433. Extra:=4;
  434. SetCapacity(FCapacity+Extra);
  435. end;
  436. Procedure TStringList.QuickSort(L, R: Integer);
  437. Var I,J : Longint;
  438. Pivot : String;
  439. begin
  440. Repeat;
  441. I:=L;
  442. J:=R;
  443. Pivot:=Flist^[(L+R) div 2].FString;
  444. Repeat
  445. While AnsiCompareText(Flist^[I].Fstring,Pivot)<0 do Inc(I);
  446. While AnsiCompareText(Flist^[J].Fstring,Pivot)>0 do Dec(J);
  447. If I<=J then
  448. begin
  449. ExchangeItems(I,J); // No check, indices are correct.
  450. Inc(I);
  451. Dec(j);
  452. end;
  453. until I>J;
  454. If L<J then QuickSort(L,J);
  455. L:=I;
  456. Until I>=R;
  457. end;
  458. Procedure TStringList.InsertItem(Index: Integer; const S: string);
  459. begin
  460. Changing;
  461. If FCount=Fcapacity then Grow;
  462. If Index<FCount then
  463. System.Move (FList^[Index],FList^[Index+1],
  464. (FCount-Index)*SizeOf(TStringItem));
  465. Pointer(Flist^[Index].Fstring):=Nil; // Needed to initialize...
  466. Flist^[Index].FString:=S;
  467. Flist^[Index].Fobject:=Nil;
  468. Inc(FCount);
  469. Changed;
  470. end;
  471. Procedure TStringList.SetSorted(Value: Boolean);
  472. begin
  473. If FSorted<>Value then
  474. begin
  475. If Value then sort;
  476. FSorted:=VAlue
  477. end;
  478. end;
  479. Procedure TStringList.Changed;
  480. begin
  481. If (FUpdateCount=0) Then
  482. If Assigned(FOnChange) then
  483. FOnchange(Self);
  484. end;
  485. Procedure TStringList.Changing;
  486. begin
  487. If FUpdateCount=0 then
  488. if Assigned(FOnChanging) then
  489. FOnchanging(Self);
  490. end;
  491. Function TStringList.Get(Index: Integer): string;
  492. begin
  493. If (Index<0) or (INdex>=Fcount) then
  494. Error (SListIndexError,Index);
  495. Result:=Flist^[Index].FString;
  496. end;
  497. Function TStringList.GetCapacity: Integer;
  498. begin
  499. Result:=FCapacity;
  500. end;
  501. Function TStringList.GetCount: Integer;
  502. begin
  503. Result:=FCount;
  504. end;
  505. Function TStringList.GetObject(Index: Integer): TObject;
  506. begin
  507. If (Index<0) or (INdex>=Fcount) then
  508. Error (SListIndexError,Index);
  509. Result:=Flist^[Index].FObject;
  510. end;
  511. Procedure TStringList.Put(Index: Integer; const S: string);
  512. begin
  513. If Sorted then
  514. Error(SSortedListError,0);
  515. If (Index<0) or (INdex>=Fcount) then
  516. Error (SListIndexError,Index);
  517. Changing;
  518. Flist^[Index].FString:=S;
  519. Changed;
  520. end;
  521. Procedure TStringList.PutObject(Index: Integer; AObject: TObject);
  522. begin
  523. If (Index<0) or (INdex>=Fcount) then
  524. Error (SListIndexError,Index);
  525. Changing;
  526. Flist^[Index].FObject:=AObject;
  527. Changed;
  528. end;
  529. Procedure TStringList.SetCapacity(NewCapacity: Integer);
  530. Var NewList : Pointer;
  531. MSize : Longint;
  532. begin
  533. If (NewCapacity<0) then
  534. Error (SListCapacityError,NewCapacity);
  535. If NewCapacity>FCapacity then
  536. begin
  537. GetMem (NewList,NewCapacity*SizeOf(TStringItem));
  538. If NewList=Nil then
  539. Error (SListCapacityError,NewCapacity);
  540. If Assigned(FList) then
  541. begin
  542. MSize:=FCapacity*Sizeof(TStringItem);
  543. System.Move (FList^,NewList^,MSize);
  544. FillWord (Pchar(NewList)[MSize],(NewCapacity-FCapacity)*WordRatio, 0);
  545. FreeMem (Flist,MSize);
  546. end;
  547. Flist:=NewList;
  548. FCapacity:=NewCapacity;
  549. end
  550. else if NewCapacity<FCapacity then
  551. begin
  552. NewList:=Flist+NewCapacity*SizeOf(TStringItem);
  553. FreeMem (NewList, (FCapacity-NewCapacity)*SizeOf(TStringItem));
  554. FCapacity:=NewCapacity;
  555. end;
  556. end;
  557. Procedure TStringList.SetUpdateState(Updating: Boolean);
  558. begin
  559. If Updating then
  560. Changing
  561. else
  562. Changed
  563. end;
  564. destructor TStringList.Destroy;
  565. Var I : Longint;
  566. begin
  567. FOnChange:=Nil;
  568. FOnChanging:=Nil;
  569. // This will force a dereference. Can be done better...
  570. For I:=0 to FCount-1 do
  571. FList^[I].FString:='';
  572. FCount:=0;
  573. SetCapacity(0);
  574. Inherited destroy;
  575. end;
  576. Function TStringList.Add(const S: string): Integer;
  577. begin
  578. If Not Sorted then
  579. Result:=FCount
  580. else
  581. If Find (S,Result) then
  582. Case DUplicates of
  583. DupIgnore : Exit;
  584. DupError : Error(SDuplicateString,0)
  585. end;
  586. InsertItem (Result,S);
  587. end;
  588. Procedure TStringList.Clear;
  589. Var I : longint;
  590. begin
  591. For I:=0 to FCount-1 do
  592. Flist^[I].FString:='';
  593. FCount:=0;
  594. SetCapacity(0);
  595. end;
  596. Procedure TStringList.Delete(Index: Integer);
  597. begin
  598. If (Index<0) or (Index>=FCount) then
  599. Error(SlistINdexError,Index);
  600. Flist^[Index].FString:='';
  601. Dec(FCount);
  602. If Index<FCount then
  603. System.Move(Flist^[Index+1],
  604. Flist^[Index],
  605. (Fcount-Index)*SizeOf(TStringItem));
  606. end;
  607. Procedure TStringList.Exchange(Index1, Index2: Integer);
  608. begin
  609. If (Index1<0) or (Index1>=FCount) then
  610. Error(SListIndexError,Index1);
  611. If (Index2<0) or (Index2>=FCount) then
  612. Error(SListIndexError,Index1);
  613. Changing;
  614. ExchangeItems(Index1,Index2);
  615. changed;
  616. end;
  617. Function TStringList.Find(const S: string; var Index: Integer): Boolean;
  618. { Searches for the first string <= S, returns True if exact match,
  619. sets index to the index f the found string. }
  620. Var I,L,R,Temp : Longint;
  621. begin
  622. Result:=False;
  623. // Use binary search.
  624. L:=0;
  625. R:=FCount-1;
  626. While L<=R do
  627. begin
  628. I:=(L+R) div 2;
  629. Temp:=AnsiCompareText(FList^ [I].FString,S);
  630. If Temp<0 then
  631. L:=I+1
  632. else
  633. begin
  634. R:=I-1;
  635. If Temp=0 then
  636. begin
  637. Result:=True;
  638. If Duplicates<>DupAccept then L:=I;
  639. end;
  640. end;
  641. end;
  642. Index:=L;
  643. end;
  644. Function TStringList.IndexOf(const S: string): Integer;
  645. begin
  646. If Not Sorted then
  647. Result:=Inherited indexOf(S)
  648. else
  649. // faster using binary search...
  650. If Not Find (S,Result) then
  651. Result:=-1;
  652. end;
  653. Procedure TStringList.Insert(Index: Integer; const S: string);
  654. begin
  655. If Sorted then
  656. Error (SSortedListError,0)
  657. else
  658. If (Index<0) or (Index>FCount) then
  659. Error (SListIndexError,Index)
  660. else
  661. InsertItem (Index,S);
  662. end;
  663. Procedure TStringList.Sort;
  664. begin
  665. If Not Sorted and (FCount>1) then
  666. begin
  667. Changing;
  668. QuickSOrt(0,FCount-1);
  669. Changed;
  670. end;
  671. end;
  672. {
  673. $Log$
  674. Revision 1.1 2000-07-13 06:31:31 michael
  675. + Initial import
  676. Revision 1.11 2000/03/07 07:50:55 michael
  677. + Added ebginupdate/endupdate
  678. Revision 1.10 2000/01/07 01:24:33 peter
  679. * updated copyright to 2000
  680. Revision 1.9 2000/01/06 01:20:33 peter
  681. * moved out of packages/ back to topdir
  682. Revision 1.1 2000/01/03 19:33:08 peter
  683. * moved to packages dir
  684. Revision 1.7 1999/12/22 01:08:18 peter
  685. * use reallocmem/freemem/getmem from the heapmanager
  686. Revision 1.6 1999/11/25 13:28:13 michael
  687. + Fixed bug in settext
  688. Revision 1.5 1999/07/07 12:34:01 peter
  689. * removed debug writeln
  690. Revision 1.4 1999/05/26 13:22:23 michael
  691. + Fixed insertitem
  692. Revision 1.3 1999/04/27 07:46:18 michael
  693. * Fixed bug that caused error in loadfromstream when last line in stream has not CRLF pair
  694. Revision 1.2 1999/04/15 07:51:45 michael
  695. + Bugfix in strings.Loadfromstream
  696. Revision 1.1 1999/04/13 08:52:28 michael
  697. + Moved strings.inc to stringl.inc, to avoid conflict with strings unit
  698. Revision 1.15 1999/04/08 10:18:56 peter
  699. * makefile updates
  700. }