globals.pas 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636
  1. {
  2. $Id$
  3. Copyright (C) 1998-2000 by Florian Klaempfl
  4. This unit implements some support functions and global variables
  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+}
  20. {$endif}
  21. unit globals;
  22. interface
  23. uses
  24. {$ifdef win32}
  25. windows,
  26. {$endif}
  27. {$ifdef linux}
  28. linux,
  29. {$endif}
  30. {$ifdef Delphi4}
  31. dmisc,
  32. sysutils,
  33. {$else}
  34. strings,dos,
  35. {$endif}
  36. {$ifdef TP}
  37. objects,
  38. {$endif}
  39. globtype,version,tokens,systems,cobjects;
  40. const
  41. {$ifdef linux}
  42. DirSep = '/';
  43. {$else}
  44. {$ifdef amiga}
  45. DirSep = '/';
  46. {$else}
  47. DirSep = '\';
  48. {$endif}
  49. {$endif}
  50. {$ifdef Splitheap}
  51. testsplit : boolean = false;
  52. {$endif Splitheap}
  53. delphimodeswitches : tmodeswitches=
  54. [m_delphi,m_tp,m_all,m_class,m_objpas,m_result,m_string_pchar,
  55. m_pointer_2_procedure,m_autoderef,m_tp_procvar,m_initfinal];
  56. fpcmodeswitches : tmodeswitches=
  57. [m_fpc,m_all,m_string_pchar,m_nested_comment,m_repeat_forward,
  58. m_cvar_support,m_initfinal,m_add_pointer];
  59. objfpcmodeswitches : tmodeswitches=
  60. [m_objfpc,m_fpc,m_all,m_class,m_objpas,m_result,m_string_pchar,m_nested_comment,
  61. m_repeat_forward,m_cvar_support,m_initfinal,m_add_pointer];
  62. tpmodeswitches : tmodeswitches=
  63. [m_tp,m_all,m_tp_procvar];
  64. gpcmodeswitches : tmodeswitches=
  65. [m_gpc,m_all];
  66. type
  67. TSearchPathList = object(TStringQueue)
  68. procedure AddPath(s:string;addfirst:boolean);
  69. procedure AddList(list:TSearchPathList;addfirst:boolean);
  70. function FindFile(const f : string;var b : boolean) : string;
  71. end;
  72. var
  73. { specified inputfile }
  74. inputdir : dirstr;
  75. inputfile : namestr;
  76. inputextension : extstr;
  77. { specified outputfile with -o parameter }
  78. outputfile : namestr;
  79. { specified with -FE or -FU }
  80. outputexedir : dirstr;
  81. outputunitdir : dirstr;
  82. { things specified with parameters }
  83. paralinkoptions,
  84. paradynamiclinker : string;
  85. parapreprocess : boolean;
  86. { directory where the utils can be found (options -FD) }
  87. utilsdirectory : dirstr;
  88. { some flags for global compiler switches }
  89. do_build,
  90. do_make : boolean;
  91. not_unit_proc : boolean;
  92. { path for searching units, different paths can be seperated by ; }
  93. exepath : dirstr; { Path to ppc }
  94. librarysearchpath,
  95. unitsearchpath,
  96. objectsearchpath,
  97. includesearchpath : TSearchPathList;
  98. { deffile }
  99. usewindowapi : boolean;
  100. description : string;
  101. dllversion : string;
  102. dllmajor,dllminor : word;
  103. { current position }
  104. token, { current token being parsed }
  105. idtoken : ttoken; { holds the token if the pattern is a known word }
  106. tokenpos, { last postion of the read token }
  107. aktfilepos : tfileposinfo; { current position }
  108. { type of currently parsed block }
  109. { isn't full implemented (FK) }
  110. block_type : tblock_type;
  111. in_args : boolean; { arguments must be checked especially }
  112. parsing_para_level : longint; { parameter level, used to convert
  113. proc calls to proc loads in firstcalln }
  114. { Must_be_valid : boolean; should the variable already have a value
  115. obsolete replace by set_varstate function }
  116. compile_level : word;
  117. make_ref : boolean;
  118. resolving_forward : boolean; { used to add forward reference as second ref }
  119. use_esp_stackframe : boolean; { to test for call with ESP as stack frame }
  120. inlining_procedure : boolean; { are we inlining a procedure }
  121. {$ifdef TP}
  122. use_big : boolean;
  123. {$endif}
  124. { commandline values }
  125. initdefines : tlinkedlist;
  126. initglobalswitches : tglobalswitches;
  127. initmoduleswitches : tmoduleswitches;
  128. initlocalswitches : tlocalswitches;
  129. initmodeswitches : tmodeswitches;
  130. {$IFDEF testvarsets}
  131. Initsetalloc, {0=fixed, 1 =var}
  132. {$ENDIF}
  133. initpackenum : longint;
  134. initpackrecords : tpackrecords;
  135. initoutputformat : tasm;
  136. initoptprocessor,
  137. initspecificoptprocessor : tprocessors;
  138. initasmmode : tasmmode;
  139. { current state values }
  140. aktglobalswitches : tglobalswitches;
  141. aktmoduleswitches : tmoduleswitches;
  142. aktlocalswitches : tlocalswitches;
  143. aktmodeswitches : tmodeswitches;
  144. {$IFDEF testvarsets}
  145. aktsetalloc,
  146. {$ENDIF}
  147. aktpackenum : longint;
  148. aktmaxfpuregisters: longint;
  149. aktpackrecords : tpackrecords;
  150. aktoutputformat : tasm;
  151. aktoptprocessor,
  152. aktspecificoptprocessor : tprocessors;
  153. aktasmmode : tasmmode;
  154. { Memory sizes }
  155. heapsize,
  156. maxheapsize,
  157. stacksize : longint;
  158. {$Ifdef EXTDEBUG}
  159. total_of_firstpass,
  160. firstpass_several : longint;
  161. {$ifdef FPC}
  162. EntryMemUsed : longint;
  163. {$endif FPC}
  164. { parameter switches }
  165. debugstop,
  166. only_one_pass : boolean;
  167. {$EndIf EXTDEBUG}
  168. { windows application type }
  169. apptype : tapptype;
  170. const
  171. RelocSection : boolean = true;
  172. RelocSectionSetExplicitly : boolean = false;
  173. DLLsource : boolean = false;
  174. DLLImageBase : pstring = nil;
  175. UseDeffileForExport : boolean = true;
  176. ForceDeffileForExport : boolean = false;
  177. { used to set all registers used for each global function
  178. this should dramatically decrease the number of
  179. recompilations needed PM }
  180. simplify_ppu : boolean = false;
  181. { should we allow non static members ? }
  182. allow_only_static : boolean = false;
  183. Inside_asm_statement : boolean = false;
  184. { for error info in pp.pas }
  185. const
  186. parser_current_file : string = '';
  187. {$ifdef debug}
  188. { if the pointer don't point to the heap then write an error }
  189. function assigned(p : pointer) : boolean;
  190. {$endif}
  191. function min(a,b : longint) : longint;
  192. function max(a,b : longint) : longint;
  193. function align(i,a:longint):longint;
  194. procedure Replace(var s:string;s1:string;const s2:string);
  195. procedure ReplaceCase(var s:string;const s1,s2:string);
  196. function upper(const s : string) : string;
  197. function lower(const s : string) : string;
  198. function trimspace(const s:string):string;
  199. {$ifdef FPC}
  200. function tostru(i:cardinal) : string;
  201. {$else}
  202. function tostru(i:longint) : string;
  203. {$endif}
  204. procedure uppervar(var s : string);
  205. function tostr(i : longint) : string;
  206. function tostr_with_plus(i : longint) : string;
  207. procedure valint(S : string;var V : longint;var code : integer);
  208. function is_number(const s : string) : boolean;
  209. function ispowerof2(value : longint;var power : longint) : boolean;
  210. { enable ansistring comparison }
  211. function compareansistrings(p1,p2 : pchar;length1,length2 : longint) : longint;
  212. function concatansistrings(p1,p2 : pchar;length1,length2 : longint) : pchar;
  213. function bstoslash(const s : string) : string;
  214. procedure abstract;
  215. function getdatestr:string;
  216. function gettimestr:string;
  217. function filetimestring( t : longint) : string;
  218. procedure DefaultReplacements(var s:string);
  219. function GetCurrentDir:string;
  220. function path_absolute(const s : string) : boolean;
  221. Function PathExists ( F : String) : Boolean;
  222. Function FileExists ( Const F : String) : Boolean;
  223. Function RemoveFile(const f:string):boolean;
  224. Function RemoveDir(d:string):boolean;
  225. Function GetFileTime ( Var F : File) : Longint;
  226. Function GetNamedFileTime ( Const F : String) : Longint;
  227. Function SplitPath(const s:string):string;
  228. Function SplitFileName(const s:string):string;
  229. Function SplitName(const s:string):string;
  230. Function SplitExtension(Const HStr:String):String;
  231. Function AddExtension(Const HStr,ext:String):String;
  232. Function ForceExtension(Const HStr,ext:String):String;
  233. Function FixPath(s:string;allowdot:boolean):string;
  234. function FixFileName(const s:string):string;
  235. procedure SplitBinCmd(const s:string;var bstr,cstr:string);
  236. procedure SynchronizeFileTime(const fn1,fn2:string);
  237. function FindFile(const f : string;path : string;var b : boolean) : string;
  238. function FindExe(bin:string;var found:boolean):string;
  239. function GetShortName(const n:string):string;
  240. Procedure Shell(const command:string);
  241. function GetEnvPChar(const envname:string):pchar;
  242. procedure FreeEnvPChar(p:pchar);
  243. procedure InitGlobals;
  244. procedure DoneGlobals;
  245. implementation
  246. uses
  247. comphook;
  248. procedure abstract;
  249. begin
  250. do_internalerror(255);
  251. end;
  252. function ngraphsearchvalue(const s1,s2 : string) : double;
  253. const
  254. n = 3;
  255. var
  256. equals,i,j : longint;
  257. hs : string;
  258. begin
  259. equals:=0;
  260. { is the string long enough ? }
  261. if min(length(s1),length(s2))-n+1<1 then
  262. begin
  263. ngraphsearchvalue:=0.0;
  264. exit;
  265. end;
  266. for i:=1 to length(s1)-n+1 do
  267. begin
  268. hs:=copy(s1,i,n);
  269. for j:=1 to length(s2)-n+1 do
  270. if hs=copy(s2,j,n) then
  271. inc(equals);
  272. end;
  273. {$ifdef fpc}
  274. ngraphsearchvalue:=equals/double(max(length(s1),length(s2))-n+1);
  275. {$else}
  276. ngraphsearchvalue:=equals/(max(length(s1),length(s2))-n+1);
  277. {$endif}
  278. end;
  279. function bstoslash(const s : string) : string;
  280. {
  281. return string s with all \ changed into /
  282. }
  283. var
  284. i : longint;
  285. begin
  286. for i:=1to length(s) do
  287. if s[i]='\' then
  288. bstoslash[i]:='/'
  289. else
  290. bstoslash[i]:=s[i];
  291. {$ifndef TP}
  292. {$ifopt H+}
  293. setlength(bstoslash,length(s));
  294. {$else}
  295. bstoslash[0]:=s[0];
  296. {$endif}
  297. {$else}
  298. bstoslash[0]:=s[0];
  299. {$endif}
  300. end;
  301. {$ifdef debug}
  302. function assigned(p : pointer) : boolean;
  303. {$ifndef FPC}
  304. {$ifndef DPMI}
  305. type
  306. ptrrec = record
  307. ofs,seg : word;
  308. end;
  309. var
  310. lp : longint;
  311. {$endif DPMI}
  312. {$endif FPC}
  313. begin
  314. {$ifdef FPC}
  315. { Assigned is used for procvar and
  316. stack stored temp records !! PM }
  317. (* if (p<>nil) {and
  318. ((p<heaporg) or
  319. (p>heapptr))} then
  320. do_internalerror(230); *)
  321. {$else}
  322. {$ifdef DPMI}
  323. assigned:=(p<>nil);
  324. exit;
  325. {$else DPMI}
  326. if p=nil then
  327. lp:=0
  328. else
  329. lp:=longint(ptrrec(p).seg)*16+longint(ptrrec(p).ofs);
  330. if (lp<>0) and
  331. ((lp<longint(seg(heaporg^))*16+longint(ofs(heaporg^))) or
  332. (lp>longint(seg(heapptr^))*16+longint(ofs(heapptr^)))) then
  333. do_internalerror(230);
  334. {$endif DPMI}
  335. {$endif FPC}
  336. assigned:=(p<>nil);
  337. end;
  338. {$endif}
  339. function min(a,b : longint) : longint;
  340. {
  341. return the minimal of a and b
  342. }
  343. begin
  344. if a>b then
  345. min:=b
  346. else
  347. min:=a;
  348. end;
  349. function max(a,b : longint) : longint;
  350. {
  351. return the maximum of a and b
  352. }
  353. begin
  354. if a<b then
  355. max:=b
  356. else
  357. max:=a;
  358. end;
  359. function align(i,a:longint):longint;
  360. {
  361. return value <i> aligned <a> boundary
  362. }
  363. begin
  364. align:=(i+a-1) and not(a-1);
  365. end;
  366. procedure Replace(var s:string;s1:string;const s2:string);
  367. var
  368. last,
  369. i : longint;
  370. begin
  371. s1:=upper(s1);
  372. last:=0;
  373. repeat
  374. i:=pos(s1,upper(s));
  375. if i=last then
  376. i:=0;
  377. if (i>0) then
  378. begin
  379. Delete(s,i,length(s1));
  380. Insert(s2,s,i);
  381. last:=i;
  382. end;
  383. until (i=0);
  384. end;
  385. procedure ReplaceCase(var s:string;const s1,s2:string);
  386. var
  387. last,
  388. i : longint;
  389. begin
  390. last:=0;
  391. repeat
  392. i:=pos(s1,s);
  393. if i=last then
  394. i:=0;
  395. if (i>0) then
  396. begin
  397. Delete(s,i,length(s1));
  398. Insert(s2,s,i);
  399. last:=i;
  400. end;
  401. until (i=0);
  402. end;
  403. function upper(const s : string) : string;
  404. {
  405. return uppercased string of s
  406. }
  407. var
  408. i : longint;
  409. begin
  410. for i:=1 to length(s) do
  411. if s[i] in ['a'..'z'] then
  412. upper[i]:=char(byte(s[i])-32)
  413. else
  414. upper[i]:=s[i];
  415. upper[0]:=s[0];
  416. end;
  417. function lower(const s : string) : string;
  418. {
  419. return lowercased string of s
  420. }
  421. var
  422. i : longint;
  423. begin
  424. for i:=1 to length(s) do
  425. if s[i] in ['A'..'Z'] then
  426. lower[i]:=char(byte(s[i])+32)
  427. else
  428. lower[i]:=s[i];
  429. lower[0]:=s[0];
  430. end;
  431. procedure uppervar(var s : string);
  432. {
  433. uppercase string s
  434. }
  435. var
  436. i : longint;
  437. begin
  438. for i:=1 to length(s) do
  439. if s[i] in ['a'..'z'] then
  440. s[i]:=char(byte(s[i])-32);
  441. end;
  442. {$ifdef FPC}
  443. function tostru(i:cardinal):string;
  444. {
  445. return string of value i, but for cardinals
  446. }
  447. var
  448. hs : string;
  449. begin
  450. str(i,hs);
  451. tostru:=hs;
  452. end;
  453. {$else FPC}
  454. function tostru(i:longint):string;
  455. begin
  456. tostru:=tostr(i);
  457. end;
  458. {$endif FPC}
  459. function trimspace(const s:string):string;
  460. {
  461. return s with all leading and ending spaces and tabs removed
  462. }
  463. var
  464. i,j : longint;
  465. begin
  466. i:=length(s);
  467. while (i>0) and (s[i] in [#9,' ']) do
  468. dec(i);
  469. j:=1;
  470. while (j<i) and (s[j] in [#9,' ']) do
  471. inc(j);
  472. trimspace:=Copy(s,j,i-j+1);
  473. end;
  474. function tostr(i : longint) : string;
  475. {
  476. return string of value i
  477. }
  478. var
  479. hs : string;
  480. begin
  481. str(i,hs);
  482. tostr:=hs;
  483. end;
  484. function tostr_with_plus(i : longint) : string;
  485. {
  486. return string of value i, but always include a + when i>=0
  487. }
  488. var
  489. hs : string;
  490. begin
  491. str(i,hs);
  492. if i>=0 then
  493. tostr_with_plus:='+'+hs
  494. else
  495. tostr_with_plus:=hs;
  496. end;
  497. procedure valint(S : string;var V : longint;var code : integer);
  498. {
  499. val() with support for octal, which is not supported under tp7
  500. }
  501. {$ifndef FPC}
  502. var
  503. vs : longint;
  504. c : byte;
  505. begin
  506. if s[1]='%' then
  507. begin
  508. vs:=0;
  509. longint(v):=0;
  510. for c:=2 to length(s) do
  511. begin
  512. if s[c]='0' then
  513. vs:=vs shl 1
  514. else
  515. if s[c]='1' then
  516. vs:=vs shl 1+1
  517. else
  518. begin
  519. code:=c;
  520. exit;
  521. end;
  522. end;
  523. code:=0;
  524. longint(v):=vs;
  525. end
  526. else
  527. system.val(S,V,code);
  528. end;
  529. {$else not FPC}
  530. begin
  531. system.val(S,V,code);
  532. end;
  533. {$endif not FPC}
  534. function is_number(const s : string) : boolean;
  535. {
  536. is string a correct number ?
  537. }
  538. var
  539. w : integer;
  540. l : longint;
  541. begin
  542. valint(s,l,w);
  543. is_number:=(w=0);
  544. end;
  545. function ispowerof2(value : longint;var power : longint) : boolean;
  546. {
  547. return if value is a power of 2. And if correct return the power
  548. }
  549. var
  550. hl : longint;
  551. i : longint;
  552. begin
  553. hl:=1;
  554. ispowerof2:=true;
  555. for i:=0 to 31 do
  556. begin
  557. if hl=value then
  558. begin
  559. power:=i;
  560. exit;
  561. end;
  562. hl:=hl shl 1;
  563. end;
  564. ispowerof2:=false;
  565. end;
  566. { enable ansistring comparison }
  567. { 0 means equal }
  568. { 1 means p1 > p2 }
  569. { -1 means p1 < p2 }
  570. function compareansistrings(p1,p2 : pchar;length1,length2 : longint) : longint;
  571. var
  572. i,j : longint;
  573. begin
  574. compareansistrings:=0;
  575. j:=min(length1,length2);
  576. i:=0;
  577. while (i<j) do
  578. begin
  579. if p1[i]>p2[i] then
  580. begin
  581. compareansistrings:=1;
  582. exit;
  583. end
  584. else
  585. if p1[i]<p2[i] then
  586. begin
  587. compareansistrings:=-1;
  588. exit;
  589. end;
  590. inc(i);
  591. end;
  592. if length1>length2 then
  593. compareansistrings:=1
  594. else
  595. if length1<length2 then
  596. compareansistrings:=-1;
  597. end;
  598. function concatansistrings(p1,p2 : pchar;length1,length2 : longint) : pchar;
  599. var
  600. p : pchar;
  601. begin
  602. getmem(p,length1+length2+1);
  603. move(p1[0],p[0],length1);
  604. move(p2[0],p[length1],length2+1);
  605. concatansistrings:=p;
  606. end;
  607. {****************************************************************************
  608. Time Handling
  609. ****************************************************************************}
  610. Function L0(l:longint):string;
  611. {
  612. return the string of value l, if l<10 then insert a zero, so
  613. the string is always at least 2 chars '01','02',etc
  614. }
  615. var
  616. s : string;
  617. begin
  618. Str(l,s);
  619. if l<10 then
  620. s:='0'+s;
  621. L0:=s;
  622. end;
  623. function gettimestr:string;
  624. {
  625. get the current time in a string HH:MM:SS
  626. }
  627. var
  628. hour,min,sec,hsec : word;
  629. begin
  630. {$ifdef delphi}
  631. dmisc.gettime(hour,min,sec,hsec);
  632. {$else delphi}
  633. dos.gettime(hour,min,sec,hsec);
  634. {$endif delphi}
  635. gettimestr:=L0(Hour)+':'+L0(min)+':'+L0(sec);
  636. end;
  637. function getdatestr:string;
  638. {
  639. get the current date in a string YY/MM/DD
  640. }
  641. var
  642. Year,Month,Day,Wday : Word;
  643. begin
  644. {$ifdef delphi}
  645. dmisc.getdate(year,month,day,wday);
  646. {$else}
  647. dos.getdate(year,month,day,wday);
  648. {$endif}
  649. getdatestr:=L0(Year)+'/'+L0(Month)+'/'+L0(Day);
  650. end;
  651. function filetimestring( t : longint) : string;
  652. {
  653. convert dos datetime t to a string YY/MM/DD HH:MM:SS
  654. }
  655. var
  656. {$ifndef linux}
  657. DT : DateTime;
  658. {$endif}
  659. Year,Month,Day,Hour,Min,Sec : Word;
  660. begin
  661. if t=-1 then
  662. begin
  663. FileTimeString:='Not Found';
  664. exit;
  665. end;
  666. {$ifndef linux}
  667. unpacktime(t,DT);
  668. Year:=dT.year;month:=dt.month;day:=dt.day;
  669. Hour:=dt.hour;min:=dt.min;sec:=dt.sec;
  670. {$else}
  671. EpochToLocal (t,year,month,day,hour,min,sec);
  672. {$endif}
  673. filetimestring:=L0(Year)+'/'+L0(Month)+'/'+L0(Day)+' '+L0(Hour)+':'+L0(min)+':'+L0(sec);
  674. end;
  675. {****************************************************************************
  676. Default Macro Handling
  677. ****************************************************************************}
  678. procedure DefaultReplacements(var s:string);
  679. begin
  680. { Replace some macro's }
  681. Replace(s,'$FPCVER',full_version_string);
  682. Replace(s,'$VERSION',full_version_string);
  683. Replace(s,'$FPCDATE',date_string);
  684. Replace(s,'$FPCTARGET',target_cpu_string);
  685. Replace(s,'$FPCCPU',target_cpu_string);
  686. Replace(s,'$TARGET',target_path);
  687. Replace(s,'$FPCOS',target_path);
  688. end;
  689. {****************************************************************************
  690. File Handling
  691. ****************************************************************************}
  692. function GetCurrentDir:string;
  693. var
  694. CurrentDir : string;
  695. begin
  696. GetDir(0,CurrentDir);
  697. GetCurrentDir:=FixPath(CurrentDir,false);
  698. end;
  699. function path_absolute(const s : string) : boolean;
  700. {
  701. is path s an absolute path?
  702. }
  703. begin
  704. path_absolute:=false;
  705. {$ifdef linux}
  706. if (length(s)>0) and (s[1]='/') then
  707. path_absolute:=true;
  708. {$else linux}
  709. {$ifdef amiga}
  710. if ((length(s)>0) and ((s[1]='\') or (s[1]='/'))) or (Pos(':',s) = length(s)) then
  711. path_absolute:=true;
  712. {$else}
  713. if ((length(s)>0) and ((s[1]='\') or (s[1]='/'))) or
  714. ((length(s)>2) and (s[2]=':') and ((s[3]='\') or (s[3]='/'))) then
  715. path_absolute:=true;
  716. {$endif amiga}
  717. {$endif linux}
  718. end;
  719. {$ifndef FPC}
  720. Procedure FindClose(var Info : SearchRec);
  721. Begin
  722. End;
  723. {$endif not FPC}
  724. Function FileExists ( Const F : String) : Boolean;
  725. {$ifndef delphi}
  726. Var
  727. Info : SearchRec;
  728. {$endif}
  729. begin
  730. {$ifdef delphi}
  731. FileExists:=sysutils.FileExists(f);
  732. {$else}
  733. findfirst(F,readonly+archive+hidden,info);
  734. FileExists:=(doserror=0);
  735. findclose(Info);
  736. {$endif delphi}
  737. end;
  738. Function PathExists ( F : String) : Boolean;
  739. Var
  740. Info : SearchRec;
  741. begin
  742. if F[Length(f)] in ['/','\'] then
  743. Delete(f,length(f),1);
  744. findfirst(F,readonly+archive+hidden+directory,info);
  745. PathExists:=(doserror=0) and ((info.attr and directory)=directory);
  746. findclose(Info);
  747. end;
  748. Function RemoveFile(const f:string):boolean;
  749. var
  750. g : file;
  751. begin
  752. assign(g,f);
  753. {$I-}
  754. erase(g);
  755. {$I+}
  756. RemoveFile:=(ioresult=0);
  757. end;
  758. Function RemoveDir(d:string):boolean;
  759. begin
  760. if d[length(d)]=DirSep then
  761. Delete(d,length(d),1);
  762. {$I-}
  763. rmdir(d);
  764. {$I+}
  765. RemoveDir:=(ioresult=0);
  766. end;
  767. Function SplitPath(const s:string):string;
  768. var
  769. i : longint;
  770. begin
  771. i:=Length(s);
  772. while (i>0) and not(s[i] in ['/','\']) do
  773. dec(i);
  774. SplitPath:=Copy(s,1,i);
  775. end;
  776. Function SplitFileName(const s:string):string;
  777. var
  778. p : dirstr;
  779. n : namestr;
  780. e : extstr;
  781. begin
  782. FSplit(s,p,n,e);
  783. SplitFileName:=n+e;
  784. end;
  785. Function SplitName(const s:string):string;
  786. var
  787. i,j : longint;
  788. begin
  789. i:=Length(s);
  790. j:=Length(s);
  791. while (i>0) and not(s[i] in ['/','\']) do
  792. dec(i);
  793. while (j>0) and (s[j]<>'.') do
  794. dec(j);
  795. if j<=i then
  796. j:=255;
  797. SplitName:=Copy(s,i+1,j-(i+1));
  798. end;
  799. Function SplitExtension(Const HStr:String):String;
  800. var
  801. j : longint;
  802. begin
  803. j:=length(Hstr);
  804. while (j>0) and (Hstr[j]<>'.') do
  805. begin
  806. if hstr[j]=DirSep then
  807. j:=0
  808. else
  809. dec(j);
  810. end;
  811. if j=0 then
  812. j:=254;
  813. SplitExtension:=Copy(Hstr,j,255);
  814. end;
  815. Function AddExtension(Const HStr,ext:String):String;
  816. begin
  817. if (Ext<>'') and (SplitExtension(HStr)='') then
  818. AddExtension:=Hstr+Ext
  819. else
  820. AddExtension:=Hstr;
  821. end;
  822. Function ForceExtension(Const HStr,ext:String):String;
  823. var
  824. j : longint;
  825. begin
  826. j:=length(Hstr);
  827. while (j>0) and (Hstr[j]<>'.') do
  828. dec(j);
  829. if j=0 then
  830. j:=255;
  831. ForceExtension:=Copy(Hstr,1,j-1)+Ext;
  832. end;
  833. Function FixPath(s:string;allowdot:boolean):string;
  834. var
  835. i : longint;
  836. begin
  837. { Fix separator }
  838. for i:=1 to length(s) do
  839. if s[i] in ['/','\'] then
  840. s[i]:=DirSep;
  841. { Fix ending / }
  842. if (length(s)>0) and (s[length(s)]<>DirSep) and
  843. (s[length(s)]<>':') then
  844. s:=s+DirSep;
  845. { Remove ./ }
  846. if (not allowdot) and (s='.'+DirSep) then
  847. s:='';
  848. { return }
  849. FixPath:=s;
  850. end;
  851. function FixFileName(const s:string):string;
  852. var
  853. i : longint;
  854. {$ifdef Linux}
  855. NoPath : boolean;
  856. {$endif Linux}
  857. begin
  858. {$ifdef Linux}
  859. NoPath:=true;
  860. {$endif Linux}
  861. for i:=length(s) downto 1 do
  862. begin
  863. case s[i] of
  864. {$ifdef Linux}
  865. '/','\' : begin
  866. FixFileName[i]:='/';
  867. NoPath:=false; {Skip lowercasing path: 'X11'<>'x11' }
  868. end;
  869. 'A'..'Z' : if NoPath then
  870. FixFileName[i]:=char(byte(s[i])+32)
  871. else
  872. FixFileName[i]:=s[i];
  873. {$else}
  874. '/' : FixFileName[i]:='\';
  875. 'A'..'Z' : FixFileName[i]:=char(byte(s[i])+32);
  876. {$endif}
  877. else
  878. FixFileName[i]:=s[i];
  879. end;
  880. end;
  881. {$ifndef TP}
  882. {$ifopt H+}
  883. SetLength(FixFileName,length(s));
  884. {$else}
  885. FixFileName[0]:=s[0];
  886. {$endif}
  887. {$else}
  888. FixFileName[0]:=s[0];
  889. {$endif}
  890. end;
  891. procedure SplitBinCmd(const s:string;var bstr,cstr:string);
  892. var
  893. i : longint;
  894. begin
  895. i:=pos(' ',s);
  896. if i>0 then
  897. begin
  898. bstr:=Copy(s,1,i-1);
  899. cstr:=Copy(s,i+1,length(s)-i);
  900. end
  901. else
  902. begin
  903. bstr:='';
  904. cstr:='';
  905. end;
  906. end;
  907. procedure TSearchPathList.AddPath(s:string;addfirst:boolean);
  908. var
  909. j : longint;
  910. hs,hsd,
  911. CurrentDir,
  912. CurrPath : string;
  913. dir : searchrec;
  914. {$IFDEF NEWST}
  915. hp : PStringItem;
  916. {$ELSE}
  917. hp : PStringQueueItem;
  918. {$ENDIF}
  919. procedure addcurrpath;
  920. begin
  921. if addfirst then
  922. begin
  923. Delete(currPath);
  924. Insert(currPath);
  925. end
  926. else
  927. begin
  928. { Check if already in path, then we don't add it }
  929. hp:=Find(currPath);
  930. if not assigned(hp) then
  931. Concat(currPath);
  932. end;
  933. end;
  934. begin
  935. if s='' then
  936. exit;
  937. { Support default macro's }
  938. DefaultReplacements(s);
  939. { get current dir }
  940. CurrentDir:=GetCurrentDir;
  941. repeat
  942. { get currpath }
  943. if addfirst then
  944. begin
  945. j:=length(s);
  946. while (j>0) and (s[j]<>';') do
  947. dec(j);
  948. CurrPath:=FixPath(Copy(s,j+1,length(s)-j),false);
  949. if j=0 then
  950. s:=''
  951. else
  952. System.Delete(s,j,length(s)-j+1);
  953. end
  954. else
  955. begin
  956. j:=Pos(';',s);
  957. if j=0 then
  958. j:=255;
  959. CurrPath:=FixPath(Copy(s,1,j-1),false);
  960. System.Delete(s,1,j);
  961. end;
  962. { fix pathname }
  963. if CurrPath='' then
  964. CurrPath:='.'+DirSep
  965. else
  966. begin
  967. CurrPath:=FixPath(FExpand(CurrPath),false);
  968. if (Copy(CurrPath,1,length(CurrentDir))=CurrentDir) then
  969. CurrPath:='.'+DirSep+Copy(CurrPath,length(CurrentDir)+1,255);
  970. end;
  971. { wildcard adding ? }
  972. if pos('*',currpath)>0 then
  973. begin
  974. if currpath[length(currpath)]=dirsep then
  975. hs:=Copy(currpath,1,length(CurrPath)-1)
  976. else
  977. hs:=currpath;
  978. hsd:=SplitPath(hs);
  979. findfirst(hs,directory,dir);
  980. while doserror=0 do
  981. begin
  982. if (dir.name<>'.') and
  983. (dir.name<>'..') and
  984. ((dir.attr and directory)<>0) then
  985. begin
  986. currpath:=hsd+dir.name+dirsep;
  987. hp:=Find(currPath);
  988. if not assigned(hp) then
  989. AddCurrPath;
  990. end;
  991. findnext(dir);
  992. end;
  993. FindClose(dir);
  994. end
  995. else
  996. begin
  997. if PathExists(currpath) then
  998. addcurrpath;
  999. end;
  1000. until (s='');
  1001. end;
  1002. procedure TSearchPathList.AddList(list:TSearchPathList;addfirst:boolean);
  1003. var
  1004. s : string;
  1005. hl : TSearchPathList;
  1006. {$IFDEF NEWST}
  1007. hp,hp2 : PStringItem;
  1008. {$ELSE}
  1009. hp,hp2 : PStringQueueItem;
  1010. {$ENDIF}
  1011. begin
  1012. if list.empty then
  1013. exit;
  1014. { create temp and reverse the list }
  1015. if addfirst then
  1016. begin
  1017. hl.Init;
  1018. hp:=list.first;
  1019. while assigned(hp) do
  1020. begin
  1021. hl.insert(hp^.data^);
  1022. hp:=hp^.next;
  1023. end;
  1024. while not hl.empty do
  1025. begin
  1026. s:=hl.Get;
  1027. Delete(s);
  1028. Insert(s);
  1029. end;
  1030. hl.done;
  1031. end
  1032. else
  1033. begin
  1034. hp:=list.first;
  1035. while assigned(hp) do
  1036. begin
  1037. hp2:=Find(hp^.data^);
  1038. { Check if already in path, then we don't add it }
  1039. if not assigned(hp2) then
  1040. Concat(hp^.data^);
  1041. hp:=hp^.next;
  1042. end;
  1043. end;
  1044. end;
  1045. function TSearchPathList.FindFile(const f : string;var b : boolean) : string;
  1046. Var
  1047. {$IFDEF NEWST}
  1048. p : PStringItem;
  1049. {$ELSE}
  1050. p : PStringQueueItem;
  1051. {$ENDIF}
  1052. begin
  1053. FindFile:='';
  1054. b:=false;
  1055. p:=first;
  1056. while assigned(p) do
  1057. begin
  1058. If FileExists(p^.data^+f) then
  1059. begin
  1060. FindFile:=p^.data^;
  1061. b:=true;
  1062. exit;
  1063. end;
  1064. p:=p^.next;
  1065. end;
  1066. end;
  1067. Function GetFileTime ( Var F : File) : Longint;
  1068. Var
  1069. {$ifdef linux}
  1070. Info : Stat;
  1071. {$endif}
  1072. L : longint;
  1073. begin
  1074. {$ifdef linux}
  1075. FStat (F,Info);
  1076. L:=Info.Mtime;
  1077. {$else}
  1078. GetFTime(f,l);
  1079. {$endif}
  1080. GetFileTime:=L;
  1081. end;
  1082. Function GetNamedFileTime (Const F : String) : Longint;
  1083. var
  1084. L : Longint;
  1085. {$ifndef linux}
  1086. info : SearchRec;
  1087. {$else}
  1088. info : stat;
  1089. {$endif}
  1090. begin
  1091. l:=-1;
  1092. {$ifdef linux}
  1093. if FStat (F,Info) then
  1094. L:=info.mtime;
  1095. {$else}
  1096. {$ifdef delphi}
  1097. dmisc.FindFirst (F,archive+readonly+hidden,info);
  1098. {$else delphi}
  1099. FindFirst (F,archive+readonly+hidden,info);
  1100. {$endif delphi}
  1101. if DosError=0 then
  1102. l:=info.time;
  1103. {$ifdef Linux}
  1104. FindClose(info);
  1105. {$endif}
  1106. {$ifdef Win32}
  1107. FindClose(info);
  1108. {$endif}
  1109. {$endif}
  1110. GetNamedFileTime:=l;
  1111. end;
  1112. {Touch Assembler and object time to ppu time is there is a ppufilename}
  1113. procedure SynchronizeFileTime(const fn1,fn2:string);
  1114. var
  1115. f : file;
  1116. l : longint;
  1117. begin
  1118. Assign(f,fn1);
  1119. {$I-}
  1120. reset(f,1);
  1121. {$I+}
  1122. if ioresult=0 then
  1123. begin
  1124. getftime(f,l);
  1125. close(f);
  1126. assign(f,fn2);
  1127. {$I-}
  1128. reset(f,1);
  1129. {$I+}
  1130. if ioresult=0 then
  1131. begin
  1132. setftime(f,l);
  1133. close(f);
  1134. end;
  1135. end;
  1136. end;
  1137. function FindFile(const f : string;path : string;var b : boolean) : string;
  1138. Var
  1139. singlepathstring : string;
  1140. i : longint;
  1141. begin
  1142. {$ifdef linux}
  1143. for i:=1 to length(path) do
  1144. if path[i]=':' then
  1145. path[i]:=';';
  1146. {$endif}
  1147. b:=false;
  1148. FindFile:='';
  1149. repeat
  1150. i:=pos(';',path);
  1151. if i=0 then
  1152. i:=256;
  1153. singlepathstring:=FixPath(copy(path,1,i-1),false);
  1154. delete(path,1,i);
  1155. If FileExists (singlepathstring+f) then
  1156. begin
  1157. FindFile:=singlepathstring;
  1158. b:=true;
  1159. exit;
  1160. end;
  1161. until path='';
  1162. end;
  1163. function FindExe(bin:string;var found:boolean):string;
  1164. begin
  1165. bin:=FixFileName(bin)+source_os.exeext;
  1166. {$ifdef delphi}
  1167. FindExe:=FindFile(bin,'.;'+exepath+';'+dmisc.getenv('PATH'),found)+bin;
  1168. {$else delphi}
  1169. FindExe:=FindFile(bin,'.;'+exepath+';'+dos.getenv('PATH'),found)+bin;
  1170. {$endif delphi}
  1171. end;
  1172. function GetShortName(const n:string):string;
  1173. {$ifdef win32}
  1174. var
  1175. hs,hs2 : string;
  1176. i : longint;
  1177. {$endif}
  1178. {$ifdef go32v2}
  1179. var
  1180. hs : string;
  1181. {$endif}
  1182. begin
  1183. GetShortName:=n;
  1184. {$ifdef win32}
  1185. hs:=n+#0;
  1186. i:=Windows.GetShortPathName(@hs[1],@hs2[1],high(hs2));
  1187. if (i>0) and (i<=high(hs2)) then
  1188. begin
  1189. hs2[0]:=chr(strlen(@hs2[1]));
  1190. GetShortName:=hs2;
  1191. end;
  1192. {$endif}
  1193. {$ifdef go32v2}
  1194. hs:=n;
  1195. if Dos.GetShortName(hs) then
  1196. GetShortName:=hs;
  1197. {$endif}
  1198. end;
  1199. {****************************************************************************
  1200. OS Dependent things
  1201. ****************************************************************************}
  1202. function GetEnvPChar(const envname:string):pchar;
  1203. {$ifdef win32}
  1204. var
  1205. s : string;
  1206. i,len : longint;
  1207. hp,p,p2 : pchar;
  1208. {$endif}
  1209. begin
  1210. {$ifdef linux}
  1211. GetEnvPchar:=Linux.Getenv(envname);
  1212. {$define GETENVOK}
  1213. {$endif}
  1214. {$ifdef win32}
  1215. GetEnvPchar:=nil;
  1216. p:=GetEnvironmentStrings;
  1217. hp:=p;
  1218. while hp^<>#0 do
  1219. begin
  1220. s:=strpas(hp);
  1221. i:=pos('=',s);
  1222. len:=strlen(hp);
  1223. if upcase(copy(s,1,i-1))=upcase(envname) then
  1224. begin
  1225. GetMem(p2,len-length(envname));
  1226. Move(hp[i],p2^,len-length(envname));
  1227. GetEnvPchar:=p2;
  1228. break;
  1229. end;
  1230. { next string entry}
  1231. hp:=hp+len+1;
  1232. end;
  1233. FreeEnvironmentStrings(p);
  1234. {$define GETENVOK}
  1235. {$endif}
  1236. {$ifdef GETENVOK}
  1237. {$undef GETENVOK}
  1238. {$else}
  1239. GetEnvPchar:=StrPNew(Dos.Getenv(envname));
  1240. {$endif}
  1241. end;
  1242. procedure FreeEnvPChar(p:pchar);
  1243. begin
  1244. {$ifndef linux}
  1245. StrDispose(p);
  1246. {$endif}
  1247. end;
  1248. Procedure Shell(const command:string);
  1249. { This is already defined in the linux.ppu for linux, need for the *
  1250. expansion under linux }
  1251. {$ifdef linux}
  1252. begin
  1253. Linux.Shell(command);
  1254. end;
  1255. {$else}
  1256. var
  1257. comspec : string;
  1258. begin
  1259. comspec:=getenv('COMSPEC');
  1260. Exec(comspec,' /C '+command);
  1261. end;
  1262. {$endif}
  1263. {****************************************************************************
  1264. Init
  1265. ****************************************************************************}
  1266. procedure get_exepath;
  1267. var
  1268. hs1 : namestr;
  1269. hs2 : extstr;
  1270. begin
  1271. {$ifdef delphi}
  1272. exepath:=dmisc.getenv('PPC_EXEC_PATH');
  1273. {$else delphi}
  1274. exepath:=dos.getenv('PPC_EXEC_PATH');
  1275. {$endif delphi}
  1276. if exepath='' then
  1277. fsplit(FixFileName(paramstr(0)),exepath,hs1,hs2);
  1278. {$ifndef VER0_99_15}
  1279. {$ifdef linux}
  1280. if exepath='' then
  1281. fsearch(hs1,dos.getenv('PATH'));
  1282. {$endif}
  1283. {$endif}
  1284. exepath:=FixPath(exepath,false);
  1285. end;
  1286. procedure DoneGlobals;
  1287. begin
  1288. initdefines.done;
  1289. if assigned(DLLImageBase) then
  1290. StringDispose(DLLImageBase);
  1291. RelocSection:=true;
  1292. RelocSectionSetExplicitly:=false;
  1293. DLLsource:=false;
  1294. UseDeffileForExport:=true;
  1295. librarysearchpath.Done;
  1296. unitsearchpath.Done;
  1297. objectsearchpath.Done;
  1298. includesearchpath.Done;
  1299. end;
  1300. procedure InitGlobals;
  1301. begin
  1302. { set global switches }
  1303. do_build:=false;
  1304. do_make:=true;
  1305. {$ifdef tp}
  1306. use_big:=false;
  1307. {$endif tp}
  1308. compile_level:=0;
  1309. { Output }
  1310. OutputFile:='';
  1311. OutputExeDir:='';
  1312. OutputUnitDir:='';
  1313. { Utils directory }
  1314. utilsdirectory:='';
  1315. { Search Paths }
  1316. librarysearchpath.Init;
  1317. unitsearchpath.Init;
  1318. includesearchpath.Init;
  1319. objectsearchpath.Init;
  1320. { Def file }
  1321. usewindowapi:=false;
  1322. description:='Compiled by FPC '+version_string+' - '+target_cpu_string;
  1323. dllversion:='';
  1324. { Init values }
  1325. initmodeswitches:=fpcmodeswitches;
  1326. initlocalswitches:=[cs_check_io];
  1327. initmoduleswitches:=[cs_extsyntax,cs_browser];
  1328. initglobalswitches:=[cs_check_unit_name,cs_link_static];
  1329. {$ifdef i386}
  1330. initoptprocessor:=Class386;
  1331. initspecificoptprocessor:=Class386;
  1332. initpackenum:=4;
  1333. {$IFDEF testvarsets}
  1334. initsetalloc:=0;
  1335. {$ENDIF}
  1336. initpackrecords:=packrecord_2;
  1337. initoutputformat:=target_asm.id;
  1338. initasmmode:=asmmode_i386_att;
  1339. {$else not i386}
  1340. {$ifdef m68k}
  1341. initoptprocessor:=MC68000;
  1342. include(initmoduleswitches,cs_fp_emulation);
  1343. initpackenum:=4;
  1344. {$IFDEF testvarsets}
  1345. initsetalloc:=0;
  1346. {$ENDIF}
  1347. initpackrecords:=packrecord_2;
  1348. initoutputformat:=as_m68k_as;
  1349. initasmmode:=asmmode_m68k_mot;
  1350. {$endif m68k}
  1351. {$endif i386}
  1352. initdefines.init;
  1353. { memory sizes, will be overriden by parameter or default for target
  1354. in options or init_parser }
  1355. stacksize:=0;
  1356. heapsize:=0;
  1357. maxheapsize:=0;
  1358. { compile state }
  1359. in_args:=false;
  1360. { must_be_valid:=true; obsolete PM }
  1361. not_unit_proc:=true;
  1362. apptype:=at_cui;
  1363. end;
  1364. begin
  1365. get_exepath;
  1366. {$ifdef EXTDEBUG}
  1367. {$ifdef FPC}
  1368. EntryMemUsed:=system.HeapSize-MemAvail;
  1369. {$endif FPC}
  1370. {$endif}
  1371. end.
  1372. {
  1373. $Log$
  1374. Revision 1.54 2000-02-28 17:23:57 daniel
  1375. * Current work of symtable integration committed. The symtable can be
  1376. activated by defining 'newst', but doesn't compile yet. Changes in type
  1377. checking and oop are completed. What is left is to write a new
  1378. symtablestack and adapt the parser to use it.
  1379. Revision 1.53 2000/02/14 20:58:44 marco
  1380. * Basic structures for new sethandling implemented.
  1381. Revision 1.52 2000/02/10 11:45:48 peter
  1382. * addpath fixed with list of paths when inserting at the beginning
  1383. * if exepath=currentdir then it's not inserted in path list
  1384. * searchpaths in ppc386.cfg are now added at the beginning of the
  1385. list instead of at the end. (commandline is not changed)
  1386. * check paths before inserting in list
  1387. Revision 1.51 2000/02/09 13:22:53 peter
  1388. * log truncated
  1389. Revision 1.50 2000/01/26 14:31:03 marco
  1390. * $VERSION is now also substituted in -F paths (that have subst active)
  1391. Revision 1.49 2000/01/23 21:29:14 florian
  1392. * CMOV support in optimizer (in define USECMOV)
  1393. + start of support of exceptions in constructors
  1394. Revision 1.48 2000/01/23 16:36:37 peter
  1395. * better auto RTL dir detection
  1396. Revision 1.47 2000/01/20 00:23:03 pierre
  1397. * fix for GetShortName, now checks results from Win32
  1398. Revision 1.46 2000/01/07 01:14:27 peter
  1399. * updated copyright to 2000
  1400. Revision 1.45 2000/01/07 00:08:09 peter
  1401. * tp7 fix
  1402. Revision 1.44 2000/01/06 15:48:59 peter
  1403. * wildcard support for directory adding, this allows the use of units/*
  1404. in ppc386.cfg
  1405. Revision 1.43 2000/01/04 15:15:50 florian
  1406. + added compiler switch $maxfpuregisters
  1407. + fixed a small problem in secondvecn
  1408. Revision 1.42 1999/12/22 01:01:48 peter
  1409. - removed freelabel()
  1410. * added undefined label detection in internal assembler, this prevents
  1411. a lot of ld crashes and wrong .o files
  1412. * .o files aren't written anymore if errors have occured
  1413. * inlining of assembler labels is now correct
  1414. Revision 1.41 1999/12/20 23:23:28 pierre
  1415. + $description $version
  1416. Revision 1.40 1999/12/20 21:42:34 pierre
  1417. + dllversion global variable
  1418. * FPC_USE_CPREFIX code removed, not necessary anymore
  1419. as we use .edata direct writing by default now.
  1420. Revision 1.39 1999/12/08 10:40:00 pierre
  1421. + allow use of unit var in exports of DLL for win32
  1422. by using direct export writing by default instead of use of DEFFILE
  1423. that does not allow assembler labels that do not
  1424. start with an underscore.
  1425. Use -WD to force use of Deffile for Win32 DLL
  1426. Revision 1.38 1999/12/06 18:21:03 peter
  1427. * support !ENVVAR for long commandlines
  1428. * win32/go32v2 write short pathnames to link.res so c:\Program Files\ is
  1429. finally supported as installdir.
  1430. Revision 1.37 1999/12/02 17:34:34 peter
  1431. * preprocessor support. But it fails on the caret in type blocks
  1432. Revision 1.36 1999/11/18 15:34:45 pierre
  1433. * Notes/Hints for local syms changed to
  1434. Set_varstate function
  1435. Revision 1.35 1999/11/17 17:04:59 pierre
  1436. * Notes/hints changes
  1437. Revision 1.34 1999/11/15 17:42:41 pierre
  1438. * -g disables reloc section for win32
  1439. Revision 1.33 1999/11/12 11:03:50 peter
  1440. * searchpaths changed to stringqueue object
  1441. Revision 1.32 1999/11/09 23:34:46 pierre
  1442. + resolving_forward boolean used for references
  1443. Revision 1.31 1999/11/09 13:00:38 peter
  1444. * define FPC_DELPHI,FPC_OBJFPC,FPC_TP,FPC_GPC
  1445. * initial support for ansistring default with modes
  1446. }