globals.pas 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593
  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 Delphi}
  31. sysutils,
  32. dmisc,
  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,m_default_ansistring];
  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_tp7,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. nextaktlocalswitches : tlocalswitches;
  144. localswitcheschanged : boolean;
  145. aktmodeswitches : tmodeswitches;
  146. {$IFDEF testvarsets}
  147. aktsetalloc,
  148. {$ENDIF}
  149. aktpackenum : longint;
  150. aktmaxfpuregisters: longint;
  151. aktpackrecords : tpackrecords;
  152. aktoutputformat : tasm;
  153. aktoptprocessor,
  154. aktspecificoptprocessor : tprocessors;
  155. aktasmmode : tasmmode;
  156. { Memory sizes }
  157. heapsize,
  158. maxheapsize,
  159. stacksize : longint;
  160. {$Ifdef EXTDEBUG}
  161. total_of_firstpass,
  162. firstpass_several : longint;
  163. {$ifdef FPC}
  164. EntryMemUsed : longint;
  165. {$endif FPC}
  166. { parameter switches }
  167. debugstop,
  168. only_one_pass : boolean;
  169. {$EndIf EXTDEBUG}
  170. { windows application type }
  171. apptype : tapptype;
  172. const
  173. RelocSection : boolean = true;
  174. RelocSectionSetExplicitly : boolean = false;
  175. LinkTypeSetExplicitly : boolean = false;
  176. DLLsource : boolean = false;
  177. DLLImageBase : pstring = nil;
  178. UseDeffileForExport : boolean = true;
  179. ForceDeffileForExport : boolean = false;
  180. { used to set all registers used for each global function
  181. this should dramatically decrease the number of
  182. recompilations needed PM }
  183. simplify_ppu : boolean = false;
  184. { should we allow non static members ? }
  185. allow_only_static : boolean = false;
  186. Inside_asm_statement : boolean = false;
  187. { for error info in pp.pas }
  188. const
  189. parser_current_file : string = '';
  190. {$ifdef debug}
  191. { if the pointer don't point to the heap then write an error }
  192. function assigned(p : pointer) : boolean;
  193. {$endif}
  194. function min(a,b : longint) : longint;
  195. function max(a,b : longint) : longint;
  196. function align(i,a:longint):longint;
  197. function align_from_size(datasize:longint;length:longint):longint;
  198. procedure Replace(var s:string;s1:string;const s2:string);
  199. procedure ReplaceCase(var s:string;const s1,s2:string);
  200. function upper(const s : string) : string;
  201. function lower(const s : string) : string;
  202. function trimspace(const s:string):string;
  203. {$ifdef FPC}
  204. function tostru(i:cardinal) : string;
  205. {$else}
  206. function tostru(i:longint) : string;
  207. {$endif}
  208. procedure uppervar(var s : string);
  209. function hexstr(val : longint;cnt : byte) : string;
  210. function tostr(i : longint) : string;
  211. function tostr_with_plus(i : longint) : string;
  212. procedure valint(S : string;var V : longint;var code : integer);
  213. function is_number(const s : string) : boolean;
  214. function ispowerof2(value : longint;var power : longint) : boolean;
  215. { enable ansistring comparison }
  216. function compareansistrings(p1,p2 : pchar;length1,length2 : longint) : longint;
  217. function concatansistrings(p1,p2 : pchar;length1,length2 : longint) : pchar;
  218. function bstoslash(const s : string) : string;
  219. procedure abstract;
  220. function getdatestr:string;
  221. function gettimestr:string;
  222. function filetimestring( t : longint) : string;
  223. procedure DefaultReplacements(var s:string);
  224. function GetCurrentDir:string;
  225. function path_absolute(const s : string) : boolean;
  226. Function PathExists ( F : String) : Boolean;
  227. Function FileExists ( Const F : String) : Boolean;
  228. Function RemoveFile(const f:string):boolean;
  229. Function RemoveDir(d:string):boolean;
  230. Function GetFileTime ( Var F : File) : Longint;
  231. Function GetNamedFileTime ( Const F : String) : Longint;
  232. Function SplitPath(const s:string):string;
  233. Function SplitFileName(const s:string):string;
  234. Function SplitName(const s:string):string;
  235. Function SplitExtension(Const HStr:String):String;
  236. Function AddExtension(Const HStr,ext:String):String;
  237. Function ForceExtension(Const HStr,ext:String):String;
  238. Function FixPath(s:string;allowdot:boolean):string;
  239. function FixFileName(const s:string):string;
  240. procedure SplitBinCmd(const s:string;var bstr,cstr:string);
  241. procedure SynchronizeFileTime(const fn1,fn2:string);
  242. function FindFile(const f : string;path : string;var b : boolean) : string;
  243. function FindExe(bin:string;var found:boolean):string;
  244. function GetShortName(const n:string):string;
  245. Procedure Shell(const command:string);
  246. function GetEnvPChar(const envname:string):pchar;
  247. procedure FreeEnvPChar(p:pchar);
  248. procedure InitGlobals;
  249. procedure DoneGlobals;
  250. implementation
  251. uses
  252. comphook;
  253. procedure abstract;
  254. begin
  255. do_internalerror(255);
  256. end;
  257. function ngraphsearchvalue(const s1,s2 : string) : double;
  258. const
  259. n = 3;
  260. var
  261. equals,i,j : longint;
  262. hs : string;
  263. begin
  264. equals:=0;
  265. { is the string long enough ? }
  266. if min(length(s1),length(s2))-n+1<1 then
  267. begin
  268. ngraphsearchvalue:=0.0;
  269. exit;
  270. end;
  271. for i:=1 to length(s1)-n+1 do
  272. begin
  273. hs:=copy(s1,i,n);
  274. for j:=1 to length(s2)-n+1 do
  275. if hs=copy(s2,j,n) then
  276. inc(equals);
  277. end;
  278. {$ifdef fpc}
  279. ngraphsearchvalue:=equals/double(max(length(s1),length(s2))-n+1);
  280. {$else}
  281. ngraphsearchvalue:=equals/(max(length(s1),length(s2))-n+1);
  282. {$endif}
  283. end;
  284. function bstoslash(const s : string) : string;
  285. {
  286. return string s with all \ changed into /
  287. }
  288. var
  289. i : longint;
  290. begin
  291. for i:=1to length(s) do
  292. if s[i]='\' then
  293. bstoslash[i]:='/'
  294. else
  295. bstoslash[i]:=s[i];
  296. {$ifndef TP}
  297. {$ifopt H+}
  298. setlength(bstoslash,length(s));
  299. {$else}
  300. bstoslash[0]:=s[0];
  301. {$endif}
  302. {$else}
  303. bstoslash[0]:=s[0];
  304. {$endif}
  305. end;
  306. {$ifdef debug}
  307. function assigned(p : pointer) : boolean;
  308. {$ifndef FPC}
  309. {$ifndef DPMI}
  310. type
  311. ptrrec = record
  312. ofs,seg : word;
  313. end;
  314. var
  315. lp : longint;
  316. {$endif DPMI}
  317. {$endif FPC}
  318. begin
  319. {$ifdef FPC}
  320. { Assigned is used for procvar and
  321. stack stored temp records !! PM }
  322. (* if (p<>nil) {and
  323. ((p<heaporg) or
  324. (p>heapptr))} then
  325. do_internalerror(230); *)
  326. {$else}
  327. {$ifdef DPMI}
  328. assigned:=(p<>nil);
  329. exit;
  330. {$else DPMI}
  331. if p=nil then
  332. lp:=0
  333. else
  334. lp:=longint(ptrrec(p).seg)*16+longint(ptrrec(p).ofs);
  335. if (lp<>0) and
  336. ((lp<longint(seg(heaporg^))*16+longint(ofs(heaporg^))) or
  337. (lp>longint(seg(heapptr^))*16+longint(ofs(heapptr^)))) then
  338. do_internalerror(230);
  339. {$endif DPMI}
  340. {$endif FPC}
  341. assigned:=(p<>nil);
  342. end;
  343. {$endif}
  344. function min(a,b : longint) : longint;
  345. {
  346. return the minimal of a and b
  347. }
  348. begin
  349. if a>b then
  350. min:=b
  351. else
  352. min:=a;
  353. end;
  354. function max(a,b : longint) : longint;
  355. {
  356. return the maximum of a and b
  357. }
  358. begin
  359. if a<b then
  360. max:=b
  361. else
  362. max:=a;
  363. end;
  364. function align_from_size(datasize:longint;length:longint):longint;
  365. {Increases the datasize with the required alignment; i.e. on pentium
  366. words should be aligned word; and dwords should be aligned dword.
  367. So for a word (len=2), datasize is increased to the nearest multiple
  368. of 2, and for len=4, datasize is increased to the nearest multiple of
  369. 4.}
  370. var data_align:word;
  371. begin
  372. {$IFDEF I386}
  373. if length>2 then
  374. data_align:=4
  375. else if length>1 then
  376. data_align:=2
  377. else
  378. data_align:=1;
  379. {$ENDIF}
  380. {$IFDEF M68K}
  381. data_align:=2;
  382. {$ENDIF}
  383. align_from_size:=(datasize+data_align-1) and not(data_align-1);
  384. end;
  385. function align(i,a:longint):longint;
  386. {
  387. return value <i> aligned <a> boundary
  388. }
  389. begin
  390. align:=(i+a-1) and not(a-1);
  391. end;
  392. procedure Replace(var s:string;s1:string;const s2:string);
  393. var
  394. last,
  395. i : longint;
  396. begin
  397. s1:=upper(s1);
  398. last:=0;
  399. repeat
  400. i:=pos(s1,upper(s));
  401. if i=last then
  402. i:=0;
  403. if (i>0) then
  404. begin
  405. Delete(s,i,length(s1));
  406. Insert(s2,s,i);
  407. last:=i;
  408. end;
  409. until (i=0);
  410. end;
  411. procedure ReplaceCase(var s:string;const s1,s2:string);
  412. var
  413. last,
  414. i : longint;
  415. begin
  416. last:=0;
  417. repeat
  418. i:=pos(s1,s);
  419. if i=last then
  420. i:=0;
  421. if (i>0) then
  422. begin
  423. Delete(s,i,length(s1));
  424. Insert(s2,s,i);
  425. last:=i;
  426. end;
  427. until (i=0);
  428. end;
  429. function upper(const s : string) : string;
  430. {
  431. return uppercased string of s
  432. }
  433. var
  434. i : longint;
  435. begin
  436. for i:=1 to length(s) do
  437. if s[i] in ['a'..'z'] then
  438. upper[i]:=char(byte(s[i])-32)
  439. else
  440. upper[i]:=s[i];
  441. upper[0]:=s[0];
  442. end;
  443. function lower(const s : string) : string;
  444. {
  445. return lowercased string of s
  446. }
  447. var
  448. i : longint;
  449. begin
  450. for i:=1 to length(s) do
  451. if s[i] in ['A'..'Z'] then
  452. lower[i]:=char(byte(s[i])+32)
  453. else
  454. lower[i]:=s[i];
  455. lower[0]:=s[0];
  456. end;
  457. procedure uppervar(var s : string);
  458. {
  459. uppercase string s
  460. }
  461. var
  462. i : longint;
  463. begin
  464. for i:=1 to length(s) do
  465. if s[i] in ['a'..'z'] then
  466. s[i]:=char(byte(s[i])-32);
  467. end;
  468. function hexstr(val : longint;cnt : byte) : string;
  469. const
  470. HexTbl : array[0..15] of char='0123456789ABCDEF';
  471. var
  472. i : longint;
  473. begin
  474. hexstr[0]:=char(cnt);
  475. for i:=cnt downto 1 do
  476. begin
  477. hexstr[i]:=hextbl[val and $f];
  478. val:=val shr 4;
  479. end;
  480. end;
  481. {$ifdef FPC}
  482. function tostru(i:cardinal):string;
  483. {
  484. return string of value i, but for cardinals
  485. }
  486. var
  487. hs : string;
  488. begin
  489. str(i,hs);
  490. tostru:=hs;
  491. end;
  492. {$else FPC}
  493. function tostru(i:longint):string;
  494. begin
  495. tostru:=tostr(i);
  496. end;
  497. {$endif FPC}
  498. function trimspace(const s:string):string;
  499. {
  500. return s with all leading and ending spaces and tabs removed
  501. }
  502. var
  503. i,j : longint;
  504. begin
  505. i:=length(s);
  506. while (i>0) and (s[i] in [#9,' ']) do
  507. dec(i);
  508. j:=1;
  509. while (j<i) and (s[j] in [#9,' ']) do
  510. inc(j);
  511. trimspace:=Copy(s,j,i-j+1);
  512. end;
  513. function tostr(i : longint) : string;
  514. {
  515. return string of value i
  516. }
  517. var
  518. hs : string;
  519. begin
  520. str(i,hs);
  521. tostr:=hs;
  522. end;
  523. function tostr_with_plus(i : longint) : string;
  524. {
  525. return string of value i, but always include a + when i>=0
  526. }
  527. var
  528. hs : string;
  529. begin
  530. str(i,hs);
  531. if i>=0 then
  532. tostr_with_plus:='+'+hs
  533. else
  534. tostr_with_plus:=hs;
  535. end;
  536. procedure valint(S : string;var V : longint;var code : integer);
  537. {
  538. val() with support for octal, which is not supported under tp7
  539. }
  540. {$ifndef FPC}
  541. var
  542. vs : longint;
  543. c : byte;
  544. begin
  545. if s[1]='%' then
  546. begin
  547. vs:=0;
  548. longint(v):=0;
  549. for c:=2 to length(s) do
  550. begin
  551. if s[c]='0' then
  552. vs:=vs shl 1
  553. else
  554. if s[c]='1' then
  555. vs:=vs shl 1+1
  556. else
  557. begin
  558. code:=c;
  559. exit;
  560. end;
  561. end;
  562. code:=0;
  563. longint(v):=vs;
  564. end
  565. else
  566. system.val(S,V,code);
  567. end;
  568. {$else not FPC}
  569. begin
  570. system.val(S,V,code);
  571. end;
  572. {$endif not FPC}
  573. function is_number(const s : string) : boolean;
  574. {
  575. is string a correct number ?
  576. }
  577. var
  578. w : integer;
  579. l : longint;
  580. begin
  581. valint(s,l,w);
  582. is_number:=(w=0);
  583. end;
  584. function ispowerof2(value : longint;var power : longint) : boolean;
  585. {
  586. return if value is a power of 2. And if correct return the power
  587. }
  588. var
  589. hl : longint;
  590. i : longint;
  591. begin
  592. hl:=1;
  593. ispowerof2:=true;
  594. for i:=0 to 31 do
  595. begin
  596. if hl=value then
  597. begin
  598. power:=i;
  599. exit;
  600. end;
  601. hl:=hl shl 1;
  602. end;
  603. ispowerof2:=false;
  604. end;
  605. { enable ansistring comparison }
  606. { 0 means equal }
  607. { 1 means p1 > p2 }
  608. { -1 means p1 < p2 }
  609. function compareansistrings(p1,p2 : pchar;length1,length2 : longint) : longint;
  610. var
  611. i,j : longint;
  612. begin
  613. compareansistrings:=0;
  614. j:=min(length1,length2);
  615. i:=0;
  616. while (i<j) do
  617. begin
  618. if p1[i]>p2[i] then
  619. begin
  620. compareansistrings:=1;
  621. exit;
  622. end
  623. else
  624. if p1[i]<p2[i] then
  625. begin
  626. compareansistrings:=-1;
  627. exit;
  628. end;
  629. inc(i);
  630. end;
  631. if length1>length2 then
  632. compareansistrings:=1
  633. else
  634. if length1<length2 then
  635. compareansistrings:=-1;
  636. end;
  637. function concatansistrings(p1,p2 : pchar;length1,length2 : longint) : pchar;
  638. var
  639. p : pchar;
  640. begin
  641. getmem(p,length1+length2+1);
  642. move(p1[0],p[0],length1);
  643. move(p2[0],p[length1],length2+1);
  644. concatansistrings:=p;
  645. end;
  646. {****************************************************************************
  647. Time Handling
  648. ****************************************************************************}
  649. Function L0(l:longint):string;
  650. {
  651. return the string of value l, if l<10 then insert a zero, so
  652. the string is always at least 2 chars '01','02',etc
  653. }
  654. var
  655. s : string;
  656. begin
  657. Str(l,s);
  658. if l<10 then
  659. s:='0'+s;
  660. L0:=s;
  661. end;
  662. function gettimestr:string;
  663. {
  664. get the current time in a string HH:MM:SS
  665. }
  666. var
  667. hour,min,sec,hsec : word;
  668. begin
  669. {$ifdef delphi}
  670. dmisc.gettime(hour,min,sec,hsec);
  671. {$else delphi}
  672. dos.gettime(hour,min,sec,hsec);
  673. {$endif delphi}
  674. gettimestr:=L0(Hour)+':'+L0(min)+':'+L0(sec);
  675. end;
  676. function getdatestr:string;
  677. {
  678. get the current date in a string YY/MM/DD
  679. }
  680. var
  681. Year,Month,Day,Wday : Word;
  682. begin
  683. {$ifdef delphi}
  684. dmisc.getdate(year,month,day,wday);
  685. {$else}
  686. dos.getdate(year,month,day,wday);
  687. {$endif}
  688. getdatestr:=L0(Year)+'/'+L0(Month)+'/'+L0(Day);
  689. end;
  690. function filetimestring( t : longint) : string;
  691. {
  692. convert dos datetime t to a string YY/MM/DD HH:MM:SS
  693. }
  694. var
  695. {$ifndef linux}
  696. DT : DateTime;
  697. {$endif}
  698. Year,Month,Day,Hour,Min,Sec : Word;
  699. begin
  700. if t=-1 then
  701. begin
  702. FileTimeString:='Not Found';
  703. exit;
  704. end;
  705. {$ifndef linux}
  706. unpacktime(t,DT);
  707. Year:=dT.year;month:=dt.month;day:=dt.day;
  708. Hour:=dt.hour;min:=dt.min;sec:=dt.sec;
  709. {$else}
  710. EpochToLocal (t,year,month,day,hour,min,sec);
  711. {$endif}
  712. filetimestring:=L0(Year)+'/'+L0(Month)+'/'+L0(Day)+' '+L0(Hour)+':'+L0(min)+':'+L0(sec);
  713. end;
  714. {****************************************************************************
  715. Default Macro Handling
  716. ****************************************************************************}
  717. procedure DefaultReplacements(var s:string);
  718. begin
  719. { Replace some macro's }
  720. Replace(s,'$FPCVER',version_string);
  721. Replace(s,'$VERSION',version_string);
  722. Replace(s,'$FULLVERSION',full_version_string);
  723. Replace(s,'$FPCDATE',date_string);
  724. Replace(s,'$FPCTARGET',target_cpu_string);
  725. Replace(s,'$FPCCPU',target_cpu_string);
  726. Replace(s,'$TARGET',target_path);
  727. Replace(s,'$FPCOS',target_path);
  728. end;
  729. {****************************************************************************
  730. File Handling
  731. ****************************************************************************}
  732. function GetCurrentDir:string;
  733. var
  734. CurrentDir : string;
  735. begin
  736. GetDir(0,CurrentDir);
  737. GetCurrentDir:=FixPath(CurrentDir,false);
  738. end;
  739. function path_absolute(const s : string) : boolean;
  740. {
  741. is path s an absolute path?
  742. }
  743. begin
  744. path_absolute:=false;
  745. {$ifdef linux}
  746. if (length(s)>0) and (s[1]='/') then
  747. path_absolute:=true;
  748. {$else linux}
  749. {$ifdef amiga}
  750. if ((length(s)>0) and ((s[1]='\') or (s[1]='/'))) or (Pos(':',s) = length(s)) then
  751. path_absolute:=true;
  752. {$else}
  753. if ((length(s)>0) and ((s[1]='\') or (s[1]='/'))) or
  754. ((length(s)>2) and (s[2]=':') and ((s[3]='\') or (s[3]='/'))) then
  755. path_absolute:=true;
  756. {$endif amiga}
  757. {$endif linux}
  758. end;
  759. {$ifndef FPC}
  760. Procedure FindClose(var Info : SearchRec);
  761. Begin
  762. End;
  763. {$endif not FPC}
  764. Function FileExists ( Const F : String) : Boolean;
  765. {$ifndef delphi}
  766. Var
  767. Info : SearchRec;
  768. {$endif}
  769. begin
  770. {$ifdef delphi}
  771. FileExists:=sysutils.FileExists(f);
  772. {$else}
  773. findfirst(F,readonly+archive+hidden,info);
  774. FileExists:=(doserror=0);
  775. findclose(Info);
  776. {$endif delphi}
  777. end;
  778. Function PathExists ( F : String) : Boolean;
  779. Var
  780. Info : SearchRec;
  781. begin
  782. if F[Length(f)] in ['/','\'] then
  783. Delete(f,length(f),1);
  784. findfirst(F,readonly+archive+hidden+directory,info);
  785. PathExists:=(doserror=0) and ((info.attr and directory)=directory);
  786. findclose(Info);
  787. end;
  788. Function RemoveFile(const f:string):boolean;
  789. var
  790. g : file;
  791. begin
  792. assign(g,f);
  793. {$I-}
  794. erase(g);
  795. {$I+}
  796. RemoveFile:=(ioresult=0);
  797. end;
  798. Function RemoveDir(d:string):boolean;
  799. begin
  800. if d[length(d)]=DirSep then
  801. Delete(d,length(d),1);
  802. {$I-}
  803. rmdir(d);
  804. {$I+}
  805. RemoveDir:=(ioresult=0);
  806. end;
  807. Function SplitPath(const s:string):string;
  808. var
  809. i : longint;
  810. begin
  811. i:=Length(s);
  812. while (i>0) and not(s[i] in ['/','\']) do
  813. dec(i);
  814. SplitPath:=Copy(s,1,i);
  815. end;
  816. Function SplitFileName(const s:string):string;
  817. var
  818. p : dirstr;
  819. n : namestr;
  820. e : extstr;
  821. begin
  822. FSplit(s,p,n,e);
  823. SplitFileName:=n+e;
  824. end;
  825. Function SplitName(const s:string):string;
  826. var
  827. i,j : longint;
  828. begin
  829. i:=Length(s);
  830. j:=Length(s);
  831. while (i>0) and not(s[i] in ['/','\']) do
  832. dec(i);
  833. while (j>0) and (s[j]<>'.') do
  834. dec(j);
  835. if j<=i then
  836. j:=255;
  837. SplitName:=Copy(s,i+1,j-(i+1));
  838. end;
  839. Function SplitExtension(Const HStr:String):String;
  840. var
  841. j : longint;
  842. begin
  843. j:=length(Hstr);
  844. while (j>0) and (Hstr[j]<>'.') do
  845. begin
  846. if hstr[j]=DirSep then
  847. j:=0
  848. else
  849. dec(j);
  850. end;
  851. if j=0 then
  852. j:=254;
  853. SplitExtension:=Copy(Hstr,j,255);
  854. end;
  855. Function AddExtension(Const HStr,ext:String):String;
  856. begin
  857. if (Ext<>'') and (SplitExtension(HStr)='') then
  858. AddExtension:=Hstr+Ext
  859. else
  860. AddExtension:=Hstr;
  861. end;
  862. Function ForceExtension(Const HStr,ext:String):String;
  863. var
  864. j : longint;
  865. begin
  866. j:=length(Hstr);
  867. while (j>0) and (Hstr[j]<>'.') do
  868. dec(j);
  869. if j=0 then
  870. j:=255;
  871. ForceExtension:=Copy(Hstr,1,j-1)+Ext;
  872. end;
  873. Function FixPath(s:string;allowdot:boolean):string;
  874. var
  875. i : longint;
  876. begin
  877. { Fix separator }
  878. for i:=1 to length(s) do
  879. if s[i] in ['/','\'] then
  880. s[i]:=DirSep;
  881. { Fix ending / }
  882. if (length(s)>0) and (s[length(s)]<>DirSep) and
  883. (s[length(s)]<>':') then
  884. s:=s+DirSep;
  885. { Remove ./ }
  886. if (not allowdot) and (s='.'+DirSep) then
  887. s:='';
  888. { return }
  889. {$ifdef linux}
  890. FixPath:=s;
  891. {$else}
  892. FixPath:=Lower(s);
  893. {$endif}
  894. end;
  895. function FixFileName(const s:string):string;
  896. var
  897. i : longint;
  898. {$ifdef Linux}
  899. NoPath : boolean;
  900. {$endif Linux}
  901. begin
  902. {$ifdef Linux}
  903. NoPath:=true;
  904. {$endif Linux}
  905. for i:=length(s) downto 1 do
  906. begin
  907. case s[i] of
  908. {$ifdef Linux}
  909. '/','\' : begin
  910. FixFileName[i]:='/';
  911. NoPath:=false; {Skip lowercasing path: 'X11'<>'x11' }
  912. end;
  913. 'A'..'Z' : if NoPath then
  914. FixFileName[i]:=char(byte(s[i])+32)
  915. else
  916. FixFileName[i]:=s[i];
  917. {$else}
  918. '/' : FixFileName[i]:='\';
  919. 'A'..'Z' : FixFileName[i]:=char(byte(s[i])+32);
  920. {$endif}
  921. else
  922. FixFileName[i]:=s[i];
  923. end;
  924. end;
  925. {$ifndef TP}
  926. {$ifopt H+}
  927. SetLength(FixFileName,length(s));
  928. {$else}
  929. FixFileName[0]:=s[0];
  930. {$endif}
  931. {$else}
  932. FixFileName[0]:=s[0];
  933. {$endif}
  934. end;
  935. procedure SplitBinCmd(const s:string;var bstr,cstr:string);
  936. var
  937. i : longint;
  938. begin
  939. i:=pos(' ',s);
  940. if i>0 then
  941. begin
  942. bstr:=Copy(s,1,i-1);
  943. cstr:=Copy(s,i+1,length(s)-i);
  944. end
  945. else
  946. begin
  947. bstr:='';
  948. cstr:='';
  949. end;
  950. end;
  951. procedure TSearchPathList.AddPath(s:string;addfirst:boolean);
  952. var
  953. j : longint;
  954. hs,hsd,
  955. CurrentDir,
  956. CurrPath : string;
  957. dir : searchrec;
  958. {$IFDEF NEWST}
  959. hp : PStringItem;
  960. {$ELSE}
  961. hp : PStringQueueItem;
  962. {$ENDIF}
  963. procedure addcurrpath;
  964. begin
  965. if addfirst then
  966. begin
  967. Delete(currPath);
  968. Insert(currPath);
  969. end
  970. else
  971. begin
  972. { Check if already in path, then we don't add it }
  973. hp:=Find(currPath);
  974. if not assigned(hp) then
  975. Concat(currPath);
  976. end;
  977. end;
  978. begin
  979. if s='' then
  980. exit;
  981. { Support default macro's }
  982. DefaultReplacements(s);
  983. { get current dir }
  984. CurrentDir:=GetCurrentDir;
  985. repeat
  986. { get currpath }
  987. if addfirst then
  988. begin
  989. j:=length(s);
  990. while (j>0) and (s[j]<>';') do
  991. dec(j);
  992. CurrPath:=FixPath(Copy(s,j+1,length(s)-j),false);
  993. if j=0 then
  994. s:=''
  995. else
  996. System.Delete(s,j,length(s)-j+1);
  997. end
  998. else
  999. begin
  1000. j:=Pos(';',s);
  1001. if j=0 then
  1002. j:=255;
  1003. CurrPath:=FixPath(Copy(s,1,j-1),false);
  1004. System.Delete(s,1,j);
  1005. end;
  1006. { fix pathname }
  1007. if CurrPath='' then
  1008. CurrPath:='.'+DirSep
  1009. else
  1010. begin
  1011. CurrPath:=FixPath(FExpand(CurrPath),false);
  1012. if (CurrentDir<>'') and (Copy(CurrPath,1,length(CurrentDir))=CurrentDir) then
  1013. CurrPath:='.'+DirSep+Copy(CurrPath,length(CurrentDir)+1,255);
  1014. end;
  1015. { wildcard adding ? }
  1016. if pos('*',currpath)>0 then
  1017. begin
  1018. if currpath[length(currpath)]=dirsep then
  1019. hs:=Copy(currpath,1,length(CurrPath)-1)
  1020. else
  1021. hs:=currpath;
  1022. hsd:=SplitPath(hs);
  1023. findfirst(hs,directory,dir);
  1024. while doserror=0 do
  1025. begin
  1026. if (dir.name<>'.') and
  1027. (dir.name<>'..') and
  1028. ((dir.attr and directory)<>0) then
  1029. begin
  1030. currpath:=hsd+dir.name+dirsep;
  1031. hp:=Find(currPath);
  1032. if not assigned(hp) then
  1033. AddCurrPath;
  1034. end;
  1035. findnext(dir);
  1036. end;
  1037. FindClose(dir);
  1038. end
  1039. else
  1040. begin
  1041. if PathExists(currpath) then
  1042. addcurrpath;
  1043. end;
  1044. until (s='');
  1045. end;
  1046. procedure TSearchPathList.AddList(list:TSearchPathList;addfirst:boolean);
  1047. var
  1048. s : string;
  1049. hl : TSearchPathList;
  1050. {$IFDEF NEWST}
  1051. hp,hp2 : PStringItem;
  1052. {$ELSE}
  1053. hp,hp2 : PStringQueueItem;
  1054. {$ENDIF}
  1055. begin
  1056. if list.empty then
  1057. exit;
  1058. { create temp and reverse the list }
  1059. if addfirst then
  1060. begin
  1061. hl.Init;
  1062. hp:=list.first;
  1063. while assigned(hp) do
  1064. begin
  1065. hl.insert(hp^.data^);
  1066. hp:=hp^.next;
  1067. end;
  1068. while not hl.empty do
  1069. begin
  1070. s:=hl.Get;
  1071. Delete(s);
  1072. Insert(s);
  1073. end;
  1074. hl.done;
  1075. end
  1076. else
  1077. begin
  1078. hp:=list.first;
  1079. while assigned(hp) do
  1080. begin
  1081. hp2:=Find(hp^.data^);
  1082. { Check if already in path, then we don't add it }
  1083. if not assigned(hp2) then
  1084. Concat(hp^.data^);
  1085. hp:=hp^.next;
  1086. end;
  1087. end;
  1088. end;
  1089. function TSearchPathList.FindFile(const f : string;var b : boolean) : string;
  1090. Var
  1091. {$IFDEF NEWST}
  1092. p : PStringItem;
  1093. {$ELSE}
  1094. p : PStringQueueItem;
  1095. {$ENDIF}
  1096. begin
  1097. FindFile:='';
  1098. b:=false;
  1099. p:=first;
  1100. while assigned(p) do
  1101. begin
  1102. If FileExists(p^.data^+f) then
  1103. begin
  1104. FindFile:=p^.data^;
  1105. b:=true;
  1106. exit;
  1107. end;
  1108. p:=p^.next;
  1109. end;
  1110. end;
  1111. Function GetFileTime ( Var F : File) : Longint;
  1112. Var
  1113. {$ifdef linux}
  1114. Info : Stat;
  1115. {$endif}
  1116. L : longint;
  1117. begin
  1118. {$ifdef linux}
  1119. FStat (F,Info);
  1120. L:=Info.Mtime;
  1121. {$else}
  1122. GetFTime(f,l);
  1123. {$endif}
  1124. GetFileTime:=L;
  1125. end;
  1126. Function GetNamedFileTime (Const F : String) : Longint;
  1127. var
  1128. L : Longint;
  1129. {$ifndef linux}
  1130. info : SearchRec;
  1131. {$else}
  1132. info : stat;
  1133. {$endif}
  1134. begin
  1135. l:=-1;
  1136. {$ifdef linux}
  1137. if FStat (F,Info) then
  1138. L:=info.mtime;
  1139. {$else}
  1140. {$ifdef delphi}
  1141. dmisc.FindFirst (F,archive+readonly+hidden,info);
  1142. {$else delphi}
  1143. FindFirst (F,archive+readonly+hidden,info);
  1144. {$endif delphi}
  1145. if DosError=0 then
  1146. l:=info.time;
  1147. {$ifdef Linux}
  1148. FindClose(info);
  1149. {$endif}
  1150. {$ifdef Win32}
  1151. FindClose(info);
  1152. {$endif}
  1153. {$endif}
  1154. GetNamedFileTime:=l;
  1155. end;
  1156. {Touch Assembler and object time to ppu time is there is a ppufilename}
  1157. procedure SynchronizeFileTime(const fn1,fn2:string);
  1158. var
  1159. f : file;
  1160. l : longint;
  1161. begin
  1162. Assign(f,fn1);
  1163. {$I-}
  1164. reset(f,1);
  1165. {$I+}
  1166. if ioresult=0 then
  1167. begin
  1168. getftime(f,l);
  1169. { just to be sure in case there are rounding errors }
  1170. setftime(f,l);
  1171. close(f);
  1172. assign(f,fn2);
  1173. {$I-}
  1174. reset(f,1);
  1175. {$I+}
  1176. if ioresult=0 then
  1177. begin
  1178. setftime(f,l);
  1179. close(f);
  1180. end;
  1181. end;
  1182. end;
  1183. function FindFile(const f : string;path : string;var b : boolean) : string;
  1184. Var
  1185. singlepathstring : string;
  1186. i : longint;
  1187. begin
  1188. {$ifdef linux}
  1189. for i:=1 to length(path) do
  1190. if path[i]=':' then
  1191. path[i]:=';';
  1192. {$endif}
  1193. b:=false;
  1194. FindFile:='';
  1195. repeat
  1196. i:=pos(';',path);
  1197. if i=0 then
  1198. i:=256;
  1199. singlepathstring:=FixPath(copy(path,1,i-1),false);
  1200. delete(path,1,i);
  1201. If FileExists (singlepathstring+f) then
  1202. begin
  1203. FindFile:=singlepathstring;
  1204. b:=true;
  1205. exit;
  1206. end;
  1207. until path='';
  1208. end;
  1209. function FindExe(bin:string;var found:boolean):string;
  1210. begin
  1211. bin:=FixFileName(bin)+source_os.exeext;
  1212. {$ifdef delphi}
  1213. FindExe:=FindFile(bin,'.;'+exepath+';'+dmisc.getenv('PATH'),found)+bin;
  1214. {$else delphi}
  1215. FindExe:=FindFile(bin,'.;'+exepath+';'+dos.getenv('PATH'),found)+bin;
  1216. {$endif delphi}
  1217. end;
  1218. function GetShortName(const n:string):string;
  1219. {$ifdef win32}
  1220. var
  1221. hs,hs2 : string;
  1222. i : longint;
  1223. {$endif}
  1224. {$ifdef go32v2}
  1225. var
  1226. hs : string;
  1227. {$endif}
  1228. begin
  1229. GetShortName:=n;
  1230. {$ifdef win32}
  1231. hs:=n+#0;
  1232. i:=Windows.GetShortPathName(@hs[1],@hs2[1],high(hs2));
  1233. if (i>0) and (i<=high(hs2)) then
  1234. begin
  1235. hs2[0]:=chr(strlen(@hs2[1]));
  1236. GetShortName:=hs2;
  1237. end;
  1238. {$endif}
  1239. {$ifdef go32v2}
  1240. hs:=n;
  1241. if Dos.GetShortName(hs) then
  1242. GetShortName:=hs;
  1243. {$endif}
  1244. end;
  1245. {****************************************************************************
  1246. OS Dependent things
  1247. ****************************************************************************}
  1248. function GetEnvPChar(const envname:string):pchar;
  1249. {$ifdef win32}
  1250. var
  1251. s : string;
  1252. i,len : longint;
  1253. hp,p,p2 : pchar;
  1254. {$endif}
  1255. begin
  1256. {$ifdef linux}
  1257. GetEnvPchar:=Linux.Getenv(envname);
  1258. {$define GETENVOK}
  1259. {$endif}
  1260. {$ifdef win32}
  1261. GetEnvPchar:=nil;
  1262. p:=GetEnvironmentStrings;
  1263. hp:=p;
  1264. while hp^<>#0 do
  1265. begin
  1266. s:=strpas(hp);
  1267. i:=pos('=',s);
  1268. len:=strlen(hp);
  1269. if upper(copy(s,1,i-1))=upper(envname) then
  1270. begin
  1271. GetMem(p2,len-length(envname));
  1272. Move(hp[i],p2^,len-length(envname));
  1273. GetEnvPchar:=p2;
  1274. break;
  1275. end;
  1276. { next string entry}
  1277. hp:=hp+len+1;
  1278. end;
  1279. FreeEnvironmentStrings(p);
  1280. {$define GETENVOK}
  1281. {$endif}
  1282. {$ifdef GETENVOK}
  1283. {$undef GETENVOK}
  1284. {$else}
  1285. GetEnvPchar:=StrPNew(Dos.Getenv(envname));
  1286. {$endif}
  1287. end;
  1288. procedure FreeEnvPChar(p:pchar);
  1289. begin
  1290. {$ifndef linux}
  1291. StrDispose(p);
  1292. {$endif}
  1293. end;
  1294. Procedure Shell(const command:string);
  1295. { This is already defined in the linux.ppu for linux, need for the *
  1296. expansion under linux }
  1297. {$ifdef linux}
  1298. begin
  1299. Linux.Shell(command);
  1300. end;
  1301. {$else}
  1302. var
  1303. comspec : string;
  1304. begin
  1305. comspec:=getenv('COMSPEC');
  1306. Exec(comspec,' /C '+command);
  1307. end;
  1308. {$endif}
  1309. {****************************************************************************
  1310. Init
  1311. ****************************************************************************}
  1312. procedure get_exepath;
  1313. var
  1314. hs1 : namestr;
  1315. hs2 : extstr;
  1316. begin
  1317. {$ifdef delphi}
  1318. exepath:=dmisc.getenv('PPC_EXEC_PATH');
  1319. {$else delphi}
  1320. exepath:=dos.getenv('PPC_EXEC_PATH');
  1321. {$endif delphi}
  1322. if exepath='' then
  1323. fsplit(FixFileName(paramstr(0)),exepath,hs1,hs2);
  1324. {$ifndef VER0_99_15}
  1325. {$ifdef linux}
  1326. if exepath='' then
  1327. fsearch(hs1,dos.getenv('PATH'));
  1328. {$endif}
  1329. {$endif}
  1330. exepath:=FixPath(exepath,false);
  1331. end;
  1332. procedure DoneGlobals;
  1333. begin
  1334. initdefines.done;
  1335. if assigned(DLLImageBase) then
  1336. StringDispose(DLLImageBase);
  1337. RelocSection:=true;
  1338. RelocSectionSetExplicitly:=false;
  1339. DLLsource:=false;
  1340. UseDeffileForExport:=true;
  1341. librarysearchpath.Done;
  1342. unitsearchpath.Done;
  1343. objectsearchpath.Done;
  1344. includesearchpath.Done;
  1345. end;
  1346. procedure InitGlobals;
  1347. begin
  1348. { set global switches }
  1349. do_build:=false;
  1350. do_make:=true;
  1351. {$ifdef tp}
  1352. use_big:=false;
  1353. {$endif tp}
  1354. compile_level:=0;
  1355. { Output }
  1356. OutputFile:='';
  1357. OutputExeDir:='';
  1358. OutputUnitDir:='';
  1359. { Utils directory }
  1360. utilsdirectory:='';
  1361. { Search Paths }
  1362. librarysearchpath.Init;
  1363. unitsearchpath.Init;
  1364. includesearchpath.Init;
  1365. objectsearchpath.Init;
  1366. { Def file }
  1367. usewindowapi:=false;
  1368. description:='Compiled by FPC '+version_string+' - '+target_cpu_string;
  1369. dllversion:='';
  1370. { Init values }
  1371. initmodeswitches:=fpcmodeswitches;
  1372. initlocalswitches:=[cs_check_io];
  1373. initmoduleswitches:=[cs_extsyntax,cs_browser];
  1374. initglobalswitches:=[cs_check_unit_name,cs_link_static];
  1375. {$ifdef i386}
  1376. initoptprocessor:=Class386;
  1377. initspecificoptprocessor:=Class386;
  1378. initpackenum:=4;
  1379. {$IFDEF testvarsets}
  1380. initsetalloc:=0;
  1381. {$ENDIF}
  1382. initpackrecords:=packrecord_2;
  1383. initoutputformat:=target_asm.id;
  1384. initasmmode:=asmmode_i386_att;
  1385. {$else not i386}
  1386. {$ifdef m68k}
  1387. initoptprocessor:=MC68000;
  1388. include(initmoduleswitches,cs_fp_emulation);
  1389. initpackenum:=4;
  1390. {$IFDEF testvarsets}
  1391. initsetalloc:=0;
  1392. {$ENDIF}
  1393. initpackrecords:=packrecord_2;
  1394. initoutputformat:=as_m68k_as;
  1395. initasmmode:=asmmode_m68k_mot;
  1396. {$endif m68k}
  1397. {$endif i386}
  1398. initdefines.init;
  1399. { memory sizes, will be overriden by parameter or default for target
  1400. in options or init_parser }
  1401. stacksize:=0;
  1402. heapsize:=0;
  1403. maxheapsize:=0;
  1404. { compile state }
  1405. in_args:=false;
  1406. { must_be_valid:=true; obsolete PM }
  1407. not_unit_proc:=true;
  1408. apptype:=at_cui;
  1409. end;
  1410. begin
  1411. get_exepath;
  1412. {$ifdef EXTDEBUG}
  1413. {$ifdef FPC}
  1414. EntryMemUsed:=system.HeapSize-MemAvail;
  1415. {$endif FPC}
  1416. {$endif}
  1417. end.
  1418. {
  1419. $Log$
  1420. Revision 1.2 2000-07-13 11:32:41 michael
  1421. + removed logs
  1422. }