globals.pas 39 KB

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