globals.pas 43 KB

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