cobjects.pas 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705
  1. {
  2. $Id$
  3. Copyright (c) 1993-98 by Florian Klaempfl
  4. This module provides some basic objects
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. {$ifdef tp}
  19. {$E+,N+,D+,F+}
  20. {$endif}
  21. {$I-}
  22. {$R-}{ necessary for crc calculation }
  23. unit cobjects;
  24. interface
  25. uses
  26. strings
  27. {$ifndef linux}
  28. ,dos
  29. {$else}
  30. ,linux
  31. {$endif}
  32. ;
  33. const hasharraysize = 253; {The size of a hasharray should be a prime
  34. number for better spreading of nodes in
  35. the array!! (DM)}
  36. type
  37. pstring = ^string;
  38. pfileposinfo = ^tfileposinfo;
  39. tfileposinfo = record
  40. line : longint;
  41. column : word;
  42. fileindex : word;
  43. end;
  44. { some help data types }
  45. pstringitem = ^tstringitem;
  46. tstringitem = record
  47. data : pstring;
  48. next : pstringitem;
  49. fileinfo : tfileposinfo; { pointer to tinputfile }
  50. end;
  51. plinkedlist_item = ^tlinkedlist_item;
  52. tlinkedlist_item = object
  53. next,previous : plinkedlist_item;
  54. { does nothing }
  55. constructor init;
  56. destructor done;virtual;
  57. function getcopy:plinkedlist_item;virtual;
  58. end;
  59. pstring_item = ^tstring_item;
  60. tstring_item = object(tlinkedlist_item)
  61. str : pstring;
  62. constructor init(const s : string);
  63. destructor done;virtual;
  64. end;
  65. { this implements a double linked list }
  66. plinkedlist = ^tlinkedlist;
  67. tlinkedlist = object
  68. first,last : plinkedlist_item;
  69. constructor init;
  70. destructor done;
  71. { disposes the items of the list }
  72. procedure clear;
  73. { concats a new item at the end }
  74. procedure concat(p : plinkedlist_item);
  75. { inserts a new item at the begin }
  76. procedure insert(p : plinkedlist_item);
  77. { inserts another list at the begin and make this list empty }
  78. procedure insertlist(p : plinkedlist);
  79. { concats another list at the end and make this list empty }
  80. procedure concatlist(p : plinkedlist);
  81. procedure concatlistcopy(p : plinkedlist);
  82. { removes p from the list (p isn't disposed) }
  83. { it's not tested if p is in the list ! }
  84. procedure remove(p : plinkedlist_item);
  85. { is the linkedlist empty ? }
  86. function empty:boolean;
  87. end;
  88. { String Queue}
  89. PStringQueue=^TStringQueue;
  90. TStringQueue=object
  91. first,last : PStringItem;
  92. constructor Init;
  93. destructor Done;
  94. function Empty:boolean;
  95. function Get:string;
  96. procedure Insert(const s:string);
  97. procedure Concat(const s:string);
  98. procedure Clear;
  99. end;
  100. { string container }
  101. pstringcontainer = ^tstringcontainer;
  102. tstringcontainer = object
  103. root,
  104. last : pstringitem;
  105. doubles : boolean; { if this is set to true, doubles are allowed }
  106. constructor init;
  107. constructor init_no_double;
  108. destructor done;
  109. { true when the container is empty }
  110. function empty:boolean;
  111. { inserts a string }
  112. procedure insert(const s : string);
  113. procedure insert_with_tokeninfo(const s : string;const file_info : tfileposinfo);
  114. { gets a string }
  115. function get : string;
  116. function get_with_tokeninfo(var file_info : tfileposinfo) : string;
  117. { true if string is in the container }
  118. function find(const s:string):boolean;
  119. { deletes all strings }
  120. procedure clear;
  121. end;
  122. Pnamed_object=^Tnamed_object;
  123. Pdictionary=^Tdictionary;
  124. Pdictionaryhasharray=^Tdictionaryhasharray;
  125. Tdictionaryhasharray=array[0..hasharraysize-1] of Pnamed_object;
  126. Tcallback = procedure(p:Pnamed_object);
  127. Tdictionary=object
  128. root:Pnamed_object;
  129. hasharray:Pdictionaryhasharray;
  130. replace_existing : boolean;
  131. constructor init(usehash:boolean);
  132. procedure clear;virtual;
  133. procedure foreach(proc2call:Tcallback);
  134. function insert(obj:Pnamed_object):Pnamed_object;virtual;
  135. function search(const s:string):Pnamed_object;
  136. function speedsearch(const s:string;
  137. speedvalue:longint):Pnamed_object;virtual;
  138. destructor done;virtual;
  139. end;
  140. Tnamed_object=object
  141. _name:Pstring;
  142. left,right:Pnamed_object;
  143. speedvalue:longint;
  144. owner:Pdictionary;
  145. constructor init(const n:string);
  146. destructor done;virtual;
  147. function name:string;
  148. end;
  149. pdynamicarray = ^tdynamicarray;
  150. tdynamicarray = object
  151. posn,
  152. count,
  153. limit,
  154. elemlen,
  155. growcount : longint;
  156. data : pchar;
  157. constructor init(Aelemlen,Agrow:longint);
  158. destructor done;
  159. function size:longint;
  160. function usedsize:longint;
  161. procedure grow;
  162. procedure align(i:longint);
  163. procedure seek(i:longint);
  164. procedure write(var d;len:longint);
  165. procedure read(var d;len:longint);
  166. procedure writepos(pos:longint;var d;len:longint);
  167. procedure readpos(pos:longint;var d;len:longint);
  168. end;
  169. {$ifdef BUFFEREDFILE}
  170. { this is implemented to allow buffered binary I/O }
  171. pbufferedfile = ^tbufferedfile;
  172. tbufferedfile = object
  173. f : file;
  174. buf : pchar;
  175. bufsize,buflast,bufpos : longint;
  176. { 0 closed, 1 input, 2 output }
  177. iomode : byte;
  178. { true, if the compile should change the endian of the output }
  179. change_endian : boolean;
  180. { calcules a crc for the file, }
  181. { but it's assumed, that there no seek while do_crc is true }
  182. do_crc : boolean;
  183. crc : longint;
  184. { temporary closing feature }
  185. tempclosed : boolean;
  186. tempmode : byte;
  187. temppos : longint;
  188. { inits a buffer with the size bufsize which is assigned to }
  189. { the file filename }
  190. constructor init(const filename : string;_bufsize : longint);
  191. { closes the file, if needed, and releases the memory }
  192. destructor done;virtual;
  193. { opens the file for input, other accesses are rejected }
  194. function reset:boolean;
  195. { opens the file for output, other accesses are rejected }
  196. procedure rewrite;
  197. { reads or writes the buffer from or to disk }
  198. procedure flush;
  199. { writes a string to the file }
  200. { the string is written without a length byte }
  201. procedure write_string(const s : string);
  202. { writes a zero terminated string }
  203. procedure write_pchar(p : pchar);
  204. { write specific data types, takes care of }
  205. { byte order }
  206. procedure write_byte(b : byte);
  207. procedure write_word(w : word);
  208. procedure write_long(l : longint);
  209. procedure write_double(d : double);
  210. { writes any data }
  211. procedure write_data(var data;count : longint);
  212. { reads any data }
  213. procedure read_data(var data;bytes : longint;var count : longint);
  214. { closes the file and releases the buffer }
  215. procedure close;
  216. { temporary closing }
  217. procedure tempclose;
  218. procedure tempreopen;
  219. { goto the given position }
  220. procedure seek(l : longint);
  221. { installes an user defined buffer }
  222. { and releases the old one, but be }
  223. { careful, if the old buffer contains }
  224. { data, this data is lost }
  225. procedure setbuf(p : pchar;s : longint);
  226. { reads the file time stamp of the file, }
  227. { the file must be opened }
  228. function getftime : longint;
  229. { returns filesize }
  230. function getsize : longint;
  231. { returns the path }
  232. function getpath : string;
  233. { resets the crc }
  234. procedure clear_crc;
  235. { returns the crc }
  236. function getcrc : longint;
  237. end;
  238. {$endif BUFFEREDFILE}
  239. { releases the string p and assignes nil to p }
  240. { if p=nil then freemem isn't called }
  241. procedure stringdispose(var p : pstring);
  242. { idem for ansistrings }
  243. procedure ansistringdispose(var p : pchar;length : longint);
  244. { allocates mem for a copy of s, copies s to this mem and returns }
  245. { a pointer to this mem }
  246. function stringdup(const s : string) : pstring;
  247. { allocates memory for s and copies s as zero terminated string
  248. to that mem and returns a pointer to that mem }
  249. function strpnew(const s : string) : pchar;
  250. { makes a char lowercase, with spanish, french and german char set }
  251. function lowercase(c : char) : char;
  252. { makes zero terminated string to a pascal string }
  253. { the data in p is modified and p is returned }
  254. function pchar2pstring(p : pchar) : pstring;
  255. { ambivalent to pchar2pstring }
  256. function pstring2pchar(p : pstring) : pchar;
  257. implementation
  258. {$ifdef FPC}
  259. function getspeedvalue(const s : string) : longint;
  260. var
  261. p1,p2:^byte;
  262. begin
  263. p1:=@s;
  264. longint(p2):=longint(p1)+p1^+1;
  265. inc(longint(p1));
  266. getspeedvalue:=0;
  267. while p1<>p2 do
  268. begin
  269. inc(getspeedvalue,p1^);
  270. inc(longint(p1));
  271. end;
  272. end;
  273. {$else}
  274. function getspeedvalue(const s : string) : longint;
  275. type
  276. ptrrec=record
  277. ofs,seg:word;
  278. end;
  279. var
  280. l,w : longint;
  281. p1,p2 : ^byte;
  282. begin
  283. p1:=@s;
  284. ptrrec(p2).seg:=ptrrec(p1).seg;
  285. ptrrec(p2).ofs:=ptrrec(p1).ofs+p1^+1;
  286. inc(p1);
  287. l:=0;
  288. while p1<>p2 do
  289. begin
  290. l:=l+p1^;
  291. inc(p1);
  292. end;
  293. getspeedvalue:=l;
  294. end;
  295. {$endif}
  296. function pchar2pstring(p : pchar) : pstring;
  297. var
  298. w,i : longint;
  299. begin
  300. w:=strlen(p);
  301. for i:=w-1 downto 0 do
  302. p[i+1]:=p[i];
  303. p[0]:=chr(w);
  304. pchar2pstring:=pstring(p);
  305. end;
  306. function pstring2pchar(p : pstring) : pchar;
  307. var
  308. w,i : longint;
  309. begin
  310. w:=length(p^);
  311. for i:=1 to w do
  312. p^[i-1]:=p^[i];
  313. p^[w]:=#0;
  314. pstring2pchar:=pchar(p);
  315. end;
  316. function lowercase(c : char) : char;
  317. begin
  318. case c of
  319. #65..#90 : c := chr(ord (c) + 32);
  320. #154 : c:=#129; { german }
  321. #142 : c:=#132; { german }
  322. #153 : c:=#148; { german }
  323. #144 : c:=#130; { french }
  324. #128 : c:=#135; { french }
  325. #143 : c:=#134; { swedish/norge (?) }
  326. #165 : c:=#164; { spanish }
  327. #228 : c:=#229; { greek }
  328. #226 : c:=#231; { greek }
  329. #232 : c:=#227; { greek }
  330. end;
  331. lowercase := c;
  332. end;
  333. function strpnew(const s : string) : pchar;
  334. var
  335. p : pchar;
  336. begin
  337. getmem(p,length(s)+1);
  338. strpcopy(p,s);
  339. strpnew:=p;
  340. end;
  341. procedure stringdispose(var p : pstring);
  342. begin
  343. if assigned(p) then
  344. freemem(p,length(p^)+1);
  345. p:=nil;
  346. end;
  347. procedure ansistringdispose(var p : pchar;length : longint);
  348. begin
  349. if assigned(p) then
  350. freemem(p,length+1);
  351. p:=nil;
  352. end;
  353. function stringdup(const s : string) : pstring;
  354. var
  355. p : pstring;
  356. begin
  357. getmem(p,length(s)+1);
  358. p^:=s;
  359. stringdup:=p;
  360. end;
  361. {****************************************************************************
  362. TStringQueue
  363. ****************************************************************************}
  364. constructor TStringQueue.Init;
  365. begin
  366. first:=nil;
  367. end;
  368. function TStringQueue.Empty:boolean;
  369. begin
  370. Empty:=(first=nil);
  371. end;
  372. function TStringQueue.Get:string;
  373. var
  374. hp : pstringitem;
  375. begin
  376. if first=nil then
  377. begin
  378. Get:='';
  379. exit;
  380. end;
  381. Get:=first^.data^;
  382. stringdispose(first^.data);
  383. hp:=first;
  384. first:=first^.next;
  385. dispose(hp);
  386. end;
  387. procedure TStringQueue.Insert(const s:string);
  388. var
  389. hp : pstringitem;
  390. begin
  391. new(hp);
  392. hp^.next:=first;
  393. hp^.data:=stringdup(s);
  394. first:=hp;
  395. if last=nil then
  396. last:=hp;
  397. end;
  398. procedure TStringQueue.Concat(const s:string);
  399. var
  400. hp : pstringitem;
  401. begin
  402. new(hp);
  403. hp^.next:=nil;
  404. hp^.data:=stringdup(s);
  405. if first=nil then
  406. first:=hp
  407. else
  408. last^.next:=hp;
  409. last:=hp;
  410. end;
  411. procedure TStringQueue.Clear;
  412. var
  413. hp : pstringitem;
  414. begin
  415. while (first<>nil) do
  416. begin
  417. hp:=first;
  418. stringdispose(first^.data);
  419. first:=first^.next;
  420. dispose(hp);
  421. end;
  422. end;
  423. destructor TStringQueue.Done;
  424. begin
  425. Clear;
  426. end;
  427. {****************************************************************************
  428. TSTRINGCONTAINER
  429. ****************************************************************************}
  430. constructor tstringcontainer.init;
  431. begin
  432. root:=nil;
  433. last:=nil;
  434. doubles:=true;
  435. end;
  436. constructor tstringcontainer.init_no_double;
  437. begin
  438. root:=nil;
  439. last:=nil;
  440. doubles:=false;
  441. end;
  442. destructor tstringcontainer.done;
  443. begin
  444. clear;
  445. end;
  446. function tstringcontainer.empty:boolean;
  447. begin
  448. empty:=(root=nil);
  449. end;
  450. procedure tstringcontainer.insert(const s : string);
  451. var
  452. hp : pstringitem;
  453. begin
  454. if not(doubles) then
  455. begin
  456. hp:=root;
  457. while assigned(hp) do
  458. begin
  459. if hp^.data^=s then exit;
  460. hp:=hp^.next;
  461. end;
  462. end;
  463. new(hp);
  464. hp^.next:=nil;
  465. hp^.data:=stringdup(s);
  466. if root=nil then root:=hp
  467. else last^.next:=hp;
  468. last:=hp;
  469. end;
  470. procedure tstringcontainer.insert_with_tokeninfo(const s : string; const file_info : tfileposinfo);
  471. var
  472. hp : pstringitem;
  473. begin
  474. if not(doubles) then
  475. begin
  476. hp:=root;
  477. while assigned(hp) do
  478. begin
  479. if hp^.data^=s then exit;
  480. hp:=hp^.next;
  481. end;
  482. end;
  483. new(hp);
  484. hp^.next:=nil;
  485. hp^.data:=stringdup(s);
  486. hp^.fileinfo:=file_info;
  487. if root=nil then root:=hp
  488. else last^.next:=hp;
  489. last:=hp;
  490. end;
  491. procedure tstringcontainer.clear;
  492. var
  493. hp : pstringitem;
  494. begin
  495. hp:=root;
  496. while assigned(hp) do
  497. begin
  498. stringdispose(hp^.data);
  499. root:=hp^.next;
  500. dispose(hp);
  501. hp:=root;
  502. end;
  503. last:=nil;
  504. root:=nil;
  505. end;
  506. function tstringcontainer.get : string;
  507. var
  508. hp : pstringitem;
  509. begin
  510. if root=nil then
  511. get:=''
  512. else
  513. begin
  514. get:=root^.data^;
  515. hp:=root;
  516. root:=root^.next;
  517. stringdispose(hp^.data);
  518. dispose(hp);
  519. end;
  520. end;
  521. function tstringcontainer.get_with_tokeninfo(var file_info : tfileposinfo) : string;
  522. var
  523. hp : pstringitem;
  524. begin
  525. if root=nil then
  526. begin
  527. get_with_tokeninfo:='';
  528. file_info.fileindex:=0;
  529. file_info.line:=0;
  530. file_info.column:=0;
  531. end
  532. else
  533. begin
  534. get_with_tokeninfo:=root^.data^;
  535. hp:=root;
  536. root:=root^.next;
  537. stringdispose(hp^.data);
  538. file_info:=hp^.fileinfo;
  539. dispose(hp);
  540. end;
  541. end;
  542. function tstringcontainer.find(const s:string):boolean;
  543. var
  544. hp : pstringitem;
  545. begin
  546. find:=false;
  547. hp:=root;
  548. while assigned(hp) do
  549. begin
  550. if hp^.data^=s then
  551. begin
  552. find:=true;
  553. exit;
  554. end;
  555. hp:=hp^.next;
  556. end;
  557. end;
  558. {****************************************************************************
  559. TLINKEDLIST_ITEM
  560. ****************************************************************************}
  561. constructor tlinkedlist_item.init;
  562. begin
  563. previous:=nil;
  564. next:=nil;
  565. end;
  566. destructor tlinkedlist_item.done;
  567. begin
  568. end;
  569. function tlinkedlist_item.getcopy:plinkedlist_item;
  570. var
  571. l : longint;
  572. p : plinkedlist_item;
  573. begin
  574. l:=sizeof(self);
  575. getmem(p,l);
  576. move(self,p^,l);
  577. getcopy:=p;
  578. end;
  579. {****************************************************************************
  580. TSTRING_ITEM
  581. ****************************************************************************}
  582. constructor tstring_item.init(const s : string);
  583. begin
  584. str:=stringdup(s);
  585. end;
  586. destructor tstring_item.done;
  587. begin
  588. stringdispose(str);
  589. inherited done;
  590. end;
  591. {****************************************************************************
  592. TLINKEDLIST
  593. ****************************************************************************}
  594. constructor tlinkedlist.init;
  595. begin
  596. first:=nil;
  597. last:=nil;
  598. end;
  599. destructor tlinkedlist.done;
  600. begin
  601. clear;
  602. end;
  603. procedure tlinkedlist.clear;
  604. var
  605. hp : plinkedlist_item;
  606. begin
  607. hp:=first;
  608. while assigned(hp) do
  609. begin
  610. first:=hp^.next;
  611. dispose(hp,done);
  612. hp:=first;
  613. end;
  614. end;
  615. procedure tlinkedlist.insertlist(p : plinkedlist);
  616. begin
  617. { empty list ? }
  618. if not(assigned(p^.first)) then
  619. exit;
  620. p^.last^.next:=first;
  621. { we have a double linked list }
  622. if assigned(first) then
  623. first^.previous:=p^.last;
  624. first:=p^.first;
  625. if not(assigned(last)) then
  626. last:=p^.last;
  627. { p becomes empty }
  628. p^.first:=nil;
  629. p^.last:=nil;
  630. end;
  631. procedure tlinkedlist.concat(p : plinkedlist_item);
  632. begin
  633. if not(assigned(first)) then
  634. begin
  635. first:=p;
  636. p^.previous:=nil;
  637. p^.next:=nil;
  638. end
  639. else
  640. begin
  641. last^.next:=p;
  642. p^.previous:=last;
  643. p^.next:=nil;
  644. end;
  645. last:=p;
  646. end;
  647. procedure tlinkedlist.insert(p : plinkedlist_item);
  648. begin
  649. if not(assigned(first)) then
  650. begin
  651. last:=p;
  652. p^.previous:=nil;
  653. p^.next:=nil;
  654. end
  655. else
  656. begin
  657. first^.previous:=p;
  658. p^.previous:=nil;
  659. p^.next:=first;
  660. end;
  661. first:=p;
  662. end;
  663. procedure tlinkedlist.remove(p : plinkedlist_item);
  664. begin
  665. if not(assigned(p)) then
  666. exit;
  667. if (first=p) and (last=p) then
  668. begin
  669. first:=nil;
  670. last:=nil;
  671. end
  672. else if first=p then
  673. begin
  674. first:=p^.next;
  675. if assigned(first) then
  676. first^.previous:=nil;
  677. end
  678. else if last=p then
  679. begin
  680. last:=last^.previous;
  681. if assigned(last) then
  682. last^.next:=nil;
  683. end
  684. else
  685. begin
  686. p^.previous^.next:=p^.next;
  687. p^.next^.previous:=p^.previous;
  688. end;
  689. p^.next:=nil;
  690. p^.previous:=nil;
  691. end;
  692. procedure tlinkedlist.concatlist(p : plinkedlist);
  693. begin
  694. if not(assigned(p^.first)) then
  695. exit;
  696. if not(assigned(first)) then
  697. first:=p^.first
  698. else
  699. begin
  700. last^.next:=p^.first;
  701. p^.first^.previous:=last;
  702. end;
  703. last:=p^.last;
  704. { make p empty }
  705. p^.last:=nil;
  706. p^.first:=nil;
  707. end;
  708. procedure tlinkedlist.concatlistcopy(p : plinkedlist);
  709. var
  710. hp,hp2 : plinkedlist_item;
  711. begin
  712. hp:=p^.first;
  713. while assigned(hp) do
  714. begin
  715. hp2:=hp^.getcopy;
  716. if assigned(hp2) then
  717. begin
  718. if not(assigned(first)) then
  719. begin
  720. first:=hp2;
  721. hp2^.previous:=nil;
  722. hp2^.next:=nil;
  723. end
  724. else
  725. begin
  726. last^.next:=hp2;
  727. hp2^.previous:=last;
  728. hp2^.next:=nil;
  729. end;
  730. last:=hp2;
  731. end;
  732. hp:=hp^.next;
  733. end;
  734. end;
  735. function tlinkedlist.empty:boolean;
  736. begin
  737. empty:=(first=nil);
  738. end;
  739. {****************************************************************************
  740. TNAMED_OBJECT
  741. ****************************************************************************}
  742. constructor Tnamed_object.init(const n:string);
  743. begin
  744. left:=nil;
  745. right:=nil;
  746. _name:=stringdup(n);
  747. speedvalue:=getspeedvalue(n);
  748. end;
  749. destructor Tnamed_object.done;
  750. begin
  751. stringdispose(_name);
  752. if assigned(left) then
  753. dispose(left,done);
  754. if assigned(right) then
  755. dispose(right,done);
  756. end;
  757. function Tnamed_object.name:string;
  758. begin
  759. name:=_name^;
  760. end;
  761. {****************************************************************************
  762. TDICTIONARY
  763. ****************************************************************************}
  764. constructor Tdictionary.init(usehash:boolean);
  765. begin
  766. root:=nil;
  767. hasharray:=nil;
  768. replace_existing:=false;
  769. if usehash then
  770. begin
  771. new(hasharray);
  772. fillchar(hasharray^,sizeof(hasharray^),0);
  773. end;
  774. end;
  775. procedure Tdictionary.clear;
  776. var w:longint;
  777. begin
  778. {remove no entry from a withsymtable as it is only a pointer to the
  779. recorddef or objectdef symtable }
  780. { remove all entry from a symbol table }
  781. if assigned(root) then
  782. dispose(root,done);
  783. if assigned(hasharray) then
  784. for w:=0 to hasharraysize-1 do
  785. if assigned(hasharray^[w]) then
  786. begin
  787. dispose(hasharray^[w],done);
  788. hasharray^[w]:=nil;
  789. end;
  790. end;
  791. procedure Tdictionary.foreach(proc2call:Tcallback);
  792. procedure a(p:Pnamed_object);
  793. { must be preorder, because it's used by reading in }
  794. { a PPU file }
  795. begin
  796. proc2call(p);
  797. if assigned(p^.left) then
  798. a(p^.left);
  799. if assigned(p^.right) then
  800. a(p^.right);
  801. end;
  802. var i:longint;
  803. begin
  804. if assigned(hasharray) then
  805. begin
  806. for i:=0 to hasharraysize-1 do
  807. if assigned(hasharray^[i]) then
  808. a(hasharray^[i]);
  809. end
  810. else
  811. if assigned(root) then
  812. a(root);
  813. end;
  814. function Tdictionary.insert(obj:Pnamed_object):Pnamed_object;
  815. function _insert(var osym:Pnamed_object):Pnamed_object;
  816. {To prevent TP from allocating temp space for temp strings, we allocate
  817. some temp strings manually. We can use two temp strings, plus a third
  818. one that TP adds, where TP alone needs five temp strings!. Storing
  819. these on the heap saves even more, totally 1016 bytes per recursion!}
  820. var s1,s2:^string;
  821. begin
  822. if osym=nil then
  823. begin
  824. osym:=obj;
  825. _insert:=osym;
  826. end
  827. { first check speedvalue, to allow a fast insert }
  828. else
  829. if osym^.speedvalue>obj^.speedvalue then
  830. _insert:=_insert(osym^.right)
  831. else
  832. if osym^.speedvalue<obj^.speedvalue then
  833. _insert:=_insert(osym^.left)
  834. else
  835. begin
  836. new(s1);
  837. new(s2);
  838. s1^:=osym^._name^;
  839. s2^:=obj^._name^;
  840. if s1^>s2^ then
  841. begin
  842. dispose(s2);
  843. dispose(s1);
  844. _insert:=_insert(osym^.right);
  845. end
  846. else
  847. if s1^<s2^ then
  848. begin
  849. dispose(s2);
  850. dispose(s1);
  851. _insert:=_insert(osym^.left);
  852. end
  853. else
  854. begin
  855. dispose(s2);
  856. dispose(s1);
  857. if replace_existing and
  858. assigned(osym) then
  859. begin
  860. obj^.left:=osym^.left;
  861. obj^.right:=osym^.right;
  862. osym:=obj;
  863. _insert:=obj;
  864. end
  865. else
  866. _insert:=osym;
  867. end;
  868. end;
  869. end;
  870. begin
  871. obj^.owner:=@self;
  872. obj^.speedvalue:=getspeedvalue(obj^._name^);
  873. if assigned(hasharray) then
  874. insert:=_insert(hasharray^[obj^.speedvalue mod hasharraysize])
  875. else
  876. insert:=_insert(root);
  877. end;
  878. function Tdictionary.search(const s:string):Pnamed_object;
  879. begin
  880. search:=speedsearch(s,getspeedvalue(s));
  881. end;
  882. function Tdictionary.speedsearch(const s:string;
  883. speedvalue:longint):Pnamed_object;
  884. var hp:Pnamed_object;
  885. begin
  886. if assigned(hasharray) then
  887. hp:=hasharray^[speedvalue mod hasharraysize]
  888. else
  889. hp:=root;
  890. while assigned(hp) do
  891. begin
  892. if speedvalue>hp^.speedvalue then
  893. hp:=hp^.left
  894. else
  895. if speedvalue<hp^.speedvalue then
  896. hp:=hp^.right
  897. else
  898. begin
  899. if (hp^._name^=s) then
  900. begin
  901. speedsearch:=hp;
  902. exit;
  903. end
  904. else
  905. if s>hp^._name^ then
  906. hp:=hp^.left
  907. else
  908. hp:=hp^.right;
  909. end;
  910. end;
  911. speedsearch:=nil;
  912. end;
  913. destructor Tdictionary.done;
  914. begin
  915. clear;
  916. if assigned(hasharray) then
  917. dispose(hasharray);
  918. end;
  919. {****************************************************************************
  920. tdynamicarray
  921. ****************************************************************************}
  922. constructor tdynamicarray.init(Aelemlen,Agrow:longint);
  923. begin
  924. posn:=0;
  925. count:=0;
  926. limit:=0;
  927. data:=nil;
  928. elemlen:=Aelemlen;
  929. growcount:=Agrow;
  930. grow;
  931. end;
  932. function tdynamicarray.size:longint;
  933. begin
  934. size:=limit*elemlen;
  935. end;
  936. function tdynamicarray.usedsize:longint;
  937. begin
  938. usedsize:=count*elemlen;
  939. end;
  940. procedure tdynamicarray.grow;
  941. var
  942. osize : longint;
  943. odata : pchar;
  944. begin
  945. osize:=size;
  946. odata:=data;
  947. inc(limit,growcount);
  948. getmem(data,size);
  949. if assigned(odata) then
  950. begin
  951. move(odata^,data^,osize);
  952. freemem(odata,osize);
  953. end;
  954. fillchar(data[osize],growcount*elemlen,0);
  955. end;
  956. procedure tdynamicarray.align(i:longint);
  957. var
  958. j : longint;
  959. begin
  960. j:=(posn*elemlen mod i);
  961. if j<>0 then
  962. begin
  963. j:=i-j;
  964. while limit<(posn+j) do
  965. grow;
  966. inc(posn,j);
  967. if (posn>count) then
  968. count:=posn;
  969. end;
  970. end;
  971. procedure tdynamicarray.seek(i:longint);
  972. begin
  973. while limit<i do
  974. grow;
  975. posn:=i;
  976. if (posn>count) then
  977. count:=posn;
  978. end;
  979. procedure tdynamicarray.write(var d;len:longint);
  980. begin
  981. while limit<(posn+len) do
  982. grow;
  983. move(d,data[posn*elemlen],len*elemlen);
  984. inc(posn,len);
  985. if (posn>count) then
  986. count:=posn;
  987. end;
  988. procedure tdynamicarray.read(var d;len:longint);
  989. begin
  990. move(data[posn*elemlen],d,len*elemlen);
  991. inc(posn,len);
  992. if (posn>count) then
  993. count:=posn;
  994. end;
  995. procedure tdynamicarray.writepos(pos:longint;var d;len:longint);
  996. begin
  997. while limit<(pos+len) do
  998. grow;
  999. move(d,data[pos*elemlen],len*elemlen);
  1000. posn:=pos+len;
  1001. if (posn>count) then
  1002. count:=posn;
  1003. end;
  1004. procedure tdynamicarray.readpos(pos:longint;var d;len:longint);
  1005. begin
  1006. while limit<(pos+len) do
  1007. grow;
  1008. move(data[pos*elemlen],d,len*elemlen);
  1009. posn:=pos+len;
  1010. if (posn>count) then
  1011. count:=posn;
  1012. end;
  1013. destructor tdynamicarray.done;
  1014. begin
  1015. if assigned(data) then
  1016. freemem(data,size);
  1017. end;
  1018. {$ifdef BUFFEREDFILE}
  1019. {****************************************************************************
  1020. TBUFFEREDFILE
  1021. ****************************************************************************}
  1022. Const
  1023. crcseed = $ffffffff;
  1024. crctable : array[0..255] of longint = (
  1025. $00000000,$77073096,$ee0e612c,$990951ba,$076dc419,$706af48f,
  1026. $e963a535,$9e6495a3,$0edb8832,$79dcb8a4,$e0d5e91e,$97d2d988,
  1027. $09b64c2b,$7eb17cbd,$e7b82d07,$90bf1d91,$1db71064,$6ab020f2,
  1028. $f3b97148,$84be41de,$1adad47d,$6ddde4eb,$f4d4b551,$83d385c7,
  1029. $136c9856,$646ba8c0,$fd62f97a,$8a65c9ec,$14015c4f,$63066cd9,
  1030. $fa0f3d63,$8d080df5,$3b6e20c8,$4c69105e,$d56041e4,$a2677172,
  1031. $3c03e4d1,$4b04d447,$d20d85fd,$a50ab56b,$35b5a8fa,$42b2986c,
  1032. $dbbbc9d6,$acbcf940,$32d86ce3,$45df5c75,$dcd60dcf,$abd13d59,
  1033. $26d930ac,$51de003a,$c8d75180,$bfd06116,$21b4f4b5,$56b3c423,
  1034. $cfba9599,$b8bda50f,$2802b89e,$5f058808,$c60cd9b2,$b10be924,
  1035. $2f6f7c87,$58684c11,$c1611dab,$b6662d3d,$76dc4190,$01db7106,
  1036. $98d220bc,$efd5102a,$71b18589,$06b6b51f,$9fbfe4a5,$e8b8d433,
  1037. $7807c9a2,$0f00f934,$9609a88e,$e10e9818,$7f6a0dbb,$086d3d2d,
  1038. $91646c97,$e6635c01,$6b6b51f4,$1c6c6162,$856530d8,$f262004e,
  1039. $6c0695ed,$1b01a57b,$8208f4c1,$f50fc457,$65b0d9c6,$12b7e950,
  1040. $8bbeb8ea,$fcb9887c,$62dd1ddf,$15da2d49,$8cd37cf3,$fbd44c65,
  1041. $4db26158,$3ab551ce,$a3bc0074,$d4bb30e2,$4adfa541,$3dd895d7,
  1042. $a4d1c46d,$d3d6f4fb,$4369e96a,$346ed9fc,$ad678846,$da60b8d0,
  1043. $44042d73,$33031de5,$aa0a4c5f,$dd0d7cc9,$5005713c,$270241aa,
  1044. $be0b1010,$c90c2086,$5768b525,$206f85b3,$b966d409,$ce61e49f,
  1045. $5edef90e,$29d9c998,$b0d09822,$c7d7a8b4,$59b33d17,$2eb40d81,
  1046. $b7bd5c3b,$c0ba6cad,$edb88320,$9abfb3b6,$03b6e20c,$74b1d29a,
  1047. $ead54739,$9dd277af,$04db2615,$73dc1683,$e3630b12,$94643b84,
  1048. $0d6d6a3e,$7a6a5aa8,$e40ecf0b,$9309ff9d,$0a00ae27,$7d079eb1,
  1049. $f00f9344,$8708a3d2,$1e01f268,$6906c2fe,$f762575d,$806567cb,
  1050. $196c3671,$6e6b06e7,$fed41b76,$89d32be0,$10da7a5a,$67dd4acc,
  1051. $f9b9df6f,$8ebeeff9,$17b7be43,$60b08ed5,$d6d6a3e8,$a1d1937e,
  1052. $38d8c2c4,$4fdff252,$d1bb67f1,$a6bc5767,$3fb506dd,$48b2364b,
  1053. $d80d2bda,$af0a1b4c,$36034af6,$41047a60,$df60efc3,$a867df55,
  1054. $316e8eef,$4669be79,$cb61b38c,$bc66831a,$256fd2a0,$5268e236,
  1055. $cc0c7795,$bb0b4703,$220216b9,$5505262f,$c5ba3bbe,$b2bd0b28,
  1056. $2bb45a92,$5cb36a04,$c2d7ffa7,$b5d0cf31,$2cd99e8b,$5bdeae1d,
  1057. $9b64c2b0,$ec63f226,$756aa39c,$026d930a,$9c0906a9,$eb0e363f,
  1058. $72076785,$05005713,$95bf4a82,$e2b87a14,$7bb12bae,$0cb61b38,
  1059. $92d28e9b,$e5d5be0d,$7cdcefb7,$0bdbdf21,$86d3d2d4,$f1d4e242,
  1060. $68ddb3f8,$1fda836e,$81be16cd,$f6b9265b,$6fb077e1,$18b74777,
  1061. $88085ae6,$ff0f6a70,$66063bca,$11010b5c,$8f659eff,$f862ae69,
  1062. $616bffd3,$166ccf45,$a00ae278,$d70dd2ee,$4e048354,$3903b3c2,
  1063. $a7672661,$d06016f7,$4969474d,$3e6e77db,$aed16a4a,$d9d65adc,
  1064. $40df0b66,$37d83bf0,$a9bcae53,$debb9ec5,$47b2cf7f,$30b5ffe9,
  1065. $bdbdf21c,$cabac28a,$53b39330,$24b4a3a6,$bad03605,$cdd70693,
  1066. $54de5729,$23d967bf,$b3667a2e,$c4614ab8,$5d681b02,$2a6f2b94,
  1067. $b40bbe37,$c30c8ea1,$5a05df1b,$2d02ef8d);
  1068. constructor tbufferedfile.init(const filename : string;_bufsize : longint);
  1069. begin
  1070. assign(f,filename);
  1071. bufsize:=_bufsize;
  1072. bufpos:=0;
  1073. buflast:=0;
  1074. do_crc:=false;
  1075. iomode:=0;
  1076. tempclosed:=false;
  1077. change_endian:=false;
  1078. clear_crc;
  1079. end;
  1080. destructor tbufferedfile.done;
  1081. begin
  1082. close;
  1083. end;
  1084. procedure tbufferedfile.clear_crc;
  1085. begin
  1086. crc:=crcseed;
  1087. end;
  1088. procedure tbufferedfile.setbuf(p : pchar;s : longint);
  1089. begin
  1090. flush;
  1091. freemem(buf,bufsize);
  1092. bufsize:=s;
  1093. buf:=p;
  1094. end;
  1095. function tbufferedfile.reset:boolean;
  1096. var
  1097. ofm : byte;
  1098. begin
  1099. ofm:=filemode;
  1100. iomode:=1;
  1101. getmem(buf,bufsize);
  1102. filemode:=0;
  1103. {$I-}
  1104. system.reset(f,1);
  1105. {$I+}
  1106. reset:=(ioresult=0);
  1107. filemode:=ofm;
  1108. end;
  1109. procedure tbufferedfile.rewrite;
  1110. begin
  1111. iomode:=2;
  1112. getmem(buf,bufsize);
  1113. system.rewrite(f,1);
  1114. end;
  1115. procedure tbufferedfile.flush;
  1116. var
  1117. {$ifdef FPC}
  1118. count : longint;
  1119. {$else}
  1120. count : integer;
  1121. {$endif}
  1122. begin
  1123. if iomode=2 then
  1124. begin
  1125. if bufpos=0 then
  1126. exit;
  1127. blockwrite(f,buf^,bufpos)
  1128. end
  1129. else if iomode=1 then
  1130. if buflast=bufpos then
  1131. begin
  1132. blockread(f,buf^,bufsize,count);
  1133. buflast:=count;
  1134. end;
  1135. bufpos:=0;
  1136. end;
  1137. function tbufferedfile.getftime : longint;
  1138. var
  1139. l : longint;
  1140. {$ifdef linux}
  1141. Info : Stat;
  1142. {$endif}
  1143. begin
  1144. {$ifndef linux}
  1145. { this only works if the file is open !! }
  1146. dos.getftime(f,l);
  1147. {$else}
  1148. Fstat(f,Info);
  1149. l:=info.mtime;
  1150. {$endif}
  1151. getftime:=l;
  1152. end;
  1153. function tbufferedfile.getsize : longint;
  1154. begin
  1155. getsize:=filesize(f);
  1156. end;
  1157. procedure tbufferedfile.seek(l : longint);
  1158. begin
  1159. if iomode=2 then
  1160. begin
  1161. flush;
  1162. system.seek(f,l);
  1163. end
  1164. else if iomode=1 then
  1165. begin
  1166. { forces a reload }
  1167. bufpos:=buflast;
  1168. system.seek(f,l);
  1169. flush;
  1170. end;
  1171. end;
  1172. type
  1173. {$ifdef tp}
  1174. bytearray1 = array [1..65535] of byte;
  1175. {$else}
  1176. bytearray1 = array [1..10000000] of byte;
  1177. {$endif}
  1178. procedure tbufferedfile.read_data(var data;bytes : longint;var count : longint);
  1179. var
  1180. p : pchar;
  1181. c,i : longint;
  1182. begin
  1183. p:=pchar(@data);
  1184. count:=0;
  1185. while bytes-count>0 do
  1186. begin
  1187. if bytes-count>buflast-bufpos then
  1188. begin
  1189. move((buf+bufpos)^,(p+count)^,buflast-bufpos);
  1190. inc(count,buflast-bufpos);
  1191. bufpos:=buflast;
  1192. flush;
  1193. { can't we read anything ? }
  1194. if bufpos=buflast then
  1195. break;
  1196. end
  1197. else
  1198. begin
  1199. move((buf+bufpos)^,(p+count)^,bytes-count);
  1200. inc(bufpos,bytes-count);
  1201. count:=bytes;
  1202. break;
  1203. end;
  1204. end;
  1205. if do_crc then
  1206. begin
  1207. c:=crc;
  1208. for i:=1 to bytes do
  1209. c:=(c shr 8) xor crctable[byte(c) xor (bytearray1(data)[i])];
  1210. crc:=c;
  1211. end;
  1212. end;
  1213. procedure tbufferedfile.write_data(var data;count : longint);
  1214. var
  1215. c,i : longint;
  1216. begin
  1217. if bufpos+count>bufsize then
  1218. flush;
  1219. move(data,(buf+bufpos)^,count);
  1220. inc(bufpos,count);
  1221. if do_crc then
  1222. begin
  1223. c:=crc;
  1224. for i:=1 to count do
  1225. c:=(c shr 8) xor crctable[byte(c) xor (bytearray1(data)[i])];
  1226. crc:=c;
  1227. end;
  1228. end;
  1229. function tbufferedfile.getcrc : longint;
  1230. begin
  1231. getcrc:=crc xor crcseed;
  1232. end;
  1233. procedure tbufferedfile.write_string(const s : string);
  1234. begin
  1235. if bufpos+length(s)>bufsize then
  1236. flush;
  1237. { why is there not CRC here ??? }
  1238. move(s[1],(buf+bufpos)^,length(s));
  1239. inc(bufpos,length(s));
  1240. { should be
  1241. write_data(s[1],length(s)); }
  1242. end;
  1243. procedure tbufferedfile.write_pchar(p : pchar);
  1244. var
  1245. l : longint;
  1246. begin
  1247. l:=strlen(p);
  1248. if l>=bufsize then
  1249. runerror(222);
  1250. { why is there not CRC here ???}
  1251. if bufpos+l>bufsize then
  1252. flush;
  1253. move(p^,(buf+bufpos)^,l);
  1254. inc(bufpos,l);
  1255. { should be
  1256. write_data(p^,l); }
  1257. end;
  1258. procedure tbufferedfile.write_byte(b : byte);
  1259. begin
  1260. write_data(b,sizeof(byte));
  1261. end;
  1262. procedure tbufferedfile.write_long(l : longint);
  1263. var
  1264. w1,w2 : word;
  1265. begin
  1266. if change_endian then
  1267. begin
  1268. w1:=l and $ffff;
  1269. w2:=l shr 16;
  1270. l:=swap(w2)+(longint(swap(w1)) shl 16);
  1271. write_data(l,sizeof(longint))
  1272. end
  1273. else
  1274. write_data(l,sizeof(longint))
  1275. end;
  1276. procedure tbufferedfile.write_word(w : word);
  1277. begin
  1278. if change_endian then
  1279. begin
  1280. w:=swap(w);
  1281. write_data(w,sizeof(word))
  1282. end
  1283. else
  1284. write_data(w,sizeof(word));
  1285. end;
  1286. procedure tbufferedfile.write_double(d : double);
  1287. begin
  1288. write_data(d,sizeof(double));
  1289. end;
  1290. function tbufferedfile.getpath : string;
  1291. begin
  1292. {$ifdef dummy}
  1293. getpath:=strpas(filerec(f).name);
  1294. {$endif}
  1295. getpath:='';
  1296. end;
  1297. procedure tbufferedfile.close;
  1298. begin
  1299. if iomode<>0 then
  1300. begin
  1301. flush;
  1302. system.close(f);
  1303. freemem(buf,bufsize);
  1304. buf:=nil;
  1305. iomode:=0;
  1306. end;
  1307. end;
  1308. procedure tbufferedfile.tempclose;
  1309. begin
  1310. if iomode<>0 then
  1311. begin
  1312. temppos:=system.filepos(f);
  1313. tempmode:=iomode;
  1314. tempclosed:=true;
  1315. system.close(f);
  1316. iomode:=0;
  1317. end
  1318. else
  1319. tempclosed:=false;
  1320. end;
  1321. procedure tbufferedfile.tempreopen;
  1322. var
  1323. ofm : byte;
  1324. begin
  1325. if tempclosed then
  1326. begin
  1327. case tempmode of
  1328. 1 : begin
  1329. ofm:=filemode;
  1330. iomode:=1;
  1331. filemode:=0;
  1332. system.reset(f,1);
  1333. filemode:=ofm;
  1334. end;
  1335. 2 : begin
  1336. iomode:=2;
  1337. system.rewrite(f,1);
  1338. end;
  1339. end;
  1340. system.seek(f,temppos);
  1341. tempclosed:=false;
  1342. end;
  1343. end;
  1344. {$endif BUFFEREDFILE}
  1345. end.
  1346. {
  1347. $Log$
  1348. Revision 1.22 1999-03-31 13:55:10 peter
  1349. * assembler inlining working for ag386bin
  1350. Revision 1.21 1999/03/19 16:35:29 pierre
  1351. * Tnamed_object done also removed left and right
  1352. Revision 1.20 1999/03/18 20:30:45 peter
  1353. + .a writer
  1354. Revision 1.19 1999/03/01 13:32:00 pierre
  1355. * external used before implemented problem fixed
  1356. Revision 1.18 1999/02/24 00:59:13 peter
  1357. * small updates for ag386bin
  1358. Revision 1.17 1999/01/19 11:00:33 daniel
  1359. + Tdictionary object: Tsymtable will become object(TTdictionary) in the
  1360. future
  1361. + Tnamed_item object: Tsym will become object(Tnamed_item) in the future
  1362. Revision 1.16 1998/11/04 10:11:37 peter
  1363. * ansistring fixes
  1364. Revision 1.15 1998/10/19 18:04:40 peter
  1365. + tstringcontainer.init_no_doubles
  1366. Revision 1.14 1998/09/18 16:03:37 florian
  1367. * some changes to compile with Delphi
  1368. Revision 1.13 1998/08/12 19:28:16 peter
  1369. * better libc support
  1370. Revision 1.12 1998/07/14 14:46:47 peter
  1371. * released NEWINPUT
  1372. Revision 1.11 1998/07/07 11:19:54 peter
  1373. + NEWINPUT for a better inputfile and scanner object
  1374. Revision 1.10 1998/07/01 15:26:59 peter
  1375. * better bufferfile.reset error handling
  1376. Revision 1.9 1998/06/03 23:40:37 peter
  1377. + unlimited file support, release tempclose
  1378. Revision 1.8 1998/05/20 09:42:33 pierre
  1379. + UseTokenInfo now default
  1380. * unit in interface uses and implementation uses gives error now
  1381. * only one error for unknown symbol (uses lastsymknown boolean)
  1382. the problem came from the label code !
  1383. + first inlined procedures and function work
  1384. (warning there might be allowed cases were the result is still wrong !!)
  1385. * UseBrower updated gives a global list of all position of all used symbols
  1386. with switch -gb
  1387. Revision 1.7 1998/05/06 18:36:53 peter
  1388. * tai_section extended with code,data,bss sections and enumerated type
  1389. * ident 'compiled by FPC' moved to pmodules
  1390. * small fix for smartlink
  1391. Revision 1.6 1998/05/06 08:38:37 pierre
  1392. * better position info with UseTokenInfo
  1393. UseTokenInfo greatly simplified
  1394. + added check for changed tree after first time firstpass
  1395. (if we could remove all the cases were it happen
  1396. we could skip all firstpass if firstpasscount > 1)
  1397. Only with ExtDebug
  1398. Revision 1.5 1998/04/30 15:59:40 pierre
  1399. * GDB works again better :
  1400. correct type info in one pass
  1401. + UseTokenInfo for better source position
  1402. * fixed one remaining bug in scanner for line counts
  1403. * several little fixes
  1404. Revision 1.4 1998/04/29 10:33:50 pierre
  1405. + added some code for ansistring (not complete nor working yet)
  1406. * corrected operator overloading
  1407. * corrected nasm output
  1408. + started inline procedures
  1409. + added starstarn : use ** for exponentiation (^ gave problems)
  1410. + started UseTokenInfo cond to get accurate positions
  1411. Revision 1.3 1998/04/27 23:10:28 peter
  1412. + new scanner
  1413. * $makelib -> if smartlink
  1414. * small filename fixes pmodule.setfilename
  1415. * moved import from files.pas -> import.pas
  1416. Revision 1.2 1998/04/07 11:09:04 peter
  1417. + filemode is set correct in tbufferedfile.reset
  1418. }