globals.pas 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789
  1. {
  2. $Id$
  3. Copyright (C) 1993-98 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 Delphi4}
  25. dmisc,
  26. sysutils,
  27. {$else}
  28. strings,dos,
  29. {$endif}
  30. {$ifdef linux}
  31. {$ifdef TP}
  32. objects,
  33. {$endif}
  34. linux,
  35. {$endif}
  36. globtype,version,tokens,systems,cobjects;
  37. const
  38. {$ifdef linux}
  39. DirSep = '/';
  40. {$else}
  41. {$ifdef amiga}
  42. DirSep = '/';
  43. {$else}
  44. DirSep = '\';
  45. {$endif}
  46. {$endif}
  47. {$ifdef Splitheap}
  48. testsplit : boolean = false;
  49. {$endif Splitheap}
  50. delphimodeswitches : tmodeswitches=
  51. [m_delphi,m_tp,m_all,m_class,m_objpas,m_result,m_string_pchar,
  52. m_pointer_2_procedure,m_autoderef,m_tp_procvar,m_initfinal];
  53. fpcmodeswitches : tmodeswitches=
  54. [m_fpc,m_all,m_string_pchar,m_nested_comment,m_repeat_forward,
  55. m_cvar_support,m_initfinal];
  56. objfpcmodeswitches : tmodeswitches=
  57. [m_fpc,m_all,m_class,m_objpas,m_result,m_string_pchar,m_nested_comment,
  58. m_repeat_forward,m_cvar_support,m_initfinal];
  59. tpmodeswitches : tmodeswitches=
  60. [m_tp,m_all,m_tp_procvar];
  61. gpcmodeswitches : tmodeswitches=
  62. [m_gpc,m_all];
  63. var
  64. { specified inputfile }
  65. inputdir : dirstr;
  66. inputfile : namestr;
  67. inputextension : extstr;
  68. { specified outputfile with -o parameter }
  69. outputfile : namestr;
  70. { specified with -FE or -FU }
  71. outputexedir : dirstr;
  72. outputunitdir : dirstr;
  73. { things specified with parameters }
  74. paralinkoptions,
  75. paradynamiclinker : string;
  76. { directory where the utils can be found (options -FD) }
  77. utilsdirectory : dirstr;
  78. { some flags for global compiler switches }
  79. do_build,
  80. do_make : boolean;
  81. not_unit_proc : boolean;
  82. { path for searching units, different paths can be seperated by ; }
  83. exepath : dirstr; { Path to ppc }
  84. librarysearchpath,
  85. unitsearchpath,
  86. objectsearchpath,
  87. includesearchpath : string;
  88. { deffile }
  89. usewindowapi : boolean;
  90. description : string;
  91. { current position }
  92. token, { current token being parsed }
  93. idtoken : ttoken; { holds the token if the pattern is a known word }
  94. tokenpos, { last postion of the read token }
  95. aktfilepos : tfileposinfo; { current position }
  96. { type of currently parsed block }
  97. { isn't full implemented (FK) }
  98. block_type : tblock_type;
  99. in_args : boolean; { arguments must be checked especially }
  100. parsing_para_level : longint; { parameter level, used to convert
  101. proc calls to proc loads in firstcalln }
  102. Must_be_valid : boolean; { should the variable already have a value }
  103. compile_level : word;
  104. make_ref : boolean;
  105. use_esp_stackframe : boolean; { to test for call with ESP as stack frame }
  106. {$ifdef TP}
  107. use_big : boolean;
  108. {$endif}
  109. { commandline values }
  110. initdefines : tlinkedlist;
  111. initglobalswitches : tglobalswitches;
  112. initmoduleswitches : tmoduleswitches;
  113. initlocalswitches : tlocalswitches;
  114. initmodeswitches : tmodeswitches;
  115. initpackenum : longint;
  116. initpackrecords : tpackrecords;
  117. initoutputformat : tasm;
  118. initoptprocessor : tprocessors;
  119. initasmmode : tasmmode;
  120. { current state values }
  121. aktglobalswitches : tglobalswitches;
  122. aktmoduleswitches : tmoduleswitches;
  123. aktlocalswitches : tlocalswitches;
  124. aktmodeswitches : tmodeswitches;
  125. aktpackenum : longint;
  126. aktpackrecords : tpackrecords;
  127. aktoutputformat : tasm;
  128. aktoptprocessor : tprocessors;
  129. aktasmmode : tasmmode;
  130. { Memory sizes }
  131. heapsize,
  132. maxheapsize,
  133. stacksize : longint;
  134. {$Ifdef EXTDEBUG}
  135. total_of_firstpass,
  136. firstpass_several : longint;
  137. {$ifdef FPC}
  138. EntryMemUsed : longint;
  139. {$endif FPC}
  140. { parameter switches }
  141. debugstop,
  142. only_one_pass : boolean;
  143. {$EndIf EXTDEBUG}
  144. { windows application type }
  145. apptype : tapptype;
  146. const
  147. RelocSection : boolean = true;
  148. DLLsource : boolean = false;
  149. DLLImageBase : pstring = nil;
  150. { should we allow non static members ? }
  151. allow_only_static : boolean = false;
  152. Inside_asm_statement : boolean = false;
  153. { for error info in pp.pas }
  154. const
  155. parser_current_file : string = '';
  156. {$ifdef debug}
  157. { if the pointer don't point to the heap then write an error }
  158. function assigned(p : pointer) : boolean;
  159. {$endif}
  160. function min(a,b : longint) : longint;
  161. function max(a,b : longint) : longint;
  162. function align(i,a:longint):longint;
  163. procedure Replace(var s:string;s1:string;const s2:string);
  164. procedure ReplaceCase(var s:string;const s1,s2:string);
  165. function upper(const s : string) : string;
  166. function lower(const s : string) : string;
  167. function trimspace(const s:string):string;
  168. {$ifdef FPC}
  169. function tostru(i:cardinal) : string;
  170. {$else}
  171. function tostru(i:longint) : string;
  172. {$endif}
  173. procedure uppervar(var s : string);
  174. function tostr(i : longint) : string;
  175. function tostr_with_plus(i : longint) : string;
  176. procedure valint(S : string;var V : longint;var code : integer);
  177. function is_number(const s : string) : boolean;
  178. function ispowerof2(value : longint;var power : longint) : boolean;
  179. { enable ansistring comparison }
  180. function compareansistrings(p1,p2 : pchar;length1,length2 : longint) : longint;
  181. function concatansistrings(p1,p2 : pchar;length1,length2 : longint) : pchar;
  182. function bstoslash(const s : string) : string;
  183. procedure abstract;
  184. function getdatestr:string;
  185. function gettimestr:string;
  186. function filetimestring( t : longint) : string;
  187. procedure DefaultReplacements(var s:string);
  188. function path_absolute(const s : string) : boolean;
  189. Function FileExists ( Const F : String) : Boolean;
  190. Function RemoveFile(const f:string):boolean;
  191. Function RemoveDir(d:string):boolean;
  192. Function GetFileTime ( Var F : File) : Longint;
  193. Function GetNamedFileTime ( Const F : String) : Longint;
  194. Function SplitFileName(const s:string):string;
  195. Function SplitName(const s:string):string;
  196. Function SplitExtension(Const HStr:String):String;
  197. Function AddExtension(Const HStr,ext:String):String;
  198. Function ForceExtension(Const HStr,ext:String):String;
  199. Function FixPath(s:string;allowdot:boolean):string;
  200. function FixFileName(const s:string):string;
  201. procedure AddPathToList(var list:string;s:string;first:boolean);
  202. function search(const f : string;path : string;var b : boolean) : string;
  203. procedure SynchronizeFileTime(const fn1,fn2:string);
  204. function FindExe(bin:string;var found:boolean):string;
  205. procedure InitGlobals;
  206. procedure DoneGlobals;
  207. procedure strdispose(var p : pchar);
  208. implementation
  209. procedure strdispose(var p : pchar);
  210. begin
  211. if assigned(p) then
  212. begin
  213. freemem(p,strlen(p)+1);
  214. p:=nil;
  215. end;
  216. end;
  217. function ngraphsearchvalue(const s1,s2 : string) : double;
  218. const
  219. n = 3;
  220. var
  221. equals,i,j : longint;
  222. hs : string;
  223. begin
  224. equals:=0;
  225. { is the string long enough ? }
  226. if min(length(s1),length(s2))-n+1<1 then
  227. begin
  228. ngraphsearchvalue:=0.0;
  229. exit;
  230. end;
  231. for i:=1 to length(s1)-n+1 do
  232. begin
  233. hs:=copy(s1,i,n);
  234. for j:=1 to length(s2)-n+1 do
  235. if hs=copy(s2,j,n) then
  236. inc(equals);
  237. end;
  238. {$ifdef fpc}
  239. ngraphsearchvalue:=equals/double(max(length(s1),length(s2))-n+1);
  240. {$else}
  241. ngraphsearchvalue:=equals/(max(length(s1),length(s2))-n+1);
  242. {$endif}
  243. end;
  244. function bstoslash(const s : string) : string;
  245. {
  246. return string s with all \ changed into /
  247. }
  248. var
  249. i : longint;
  250. begin
  251. for i:=1to length(s) do
  252. if s[i]='\' then
  253. bstoslash[i]:='/'
  254. else
  255. bstoslash[i]:=s[i];
  256. {$ifndef TP}
  257. {$ifopt H+}
  258. setlength(bstoslash,length(s));
  259. {$else}
  260. bstoslash[0]:=s[0];
  261. {$endif}
  262. {$else}
  263. bstoslash[0]:=s[0];
  264. {$endif}
  265. end;
  266. {$ifdef debug}
  267. function assigned(p : pointer) : boolean;
  268. {$ifndef FPC}
  269. {$ifndef DPMI}
  270. var
  271. lp : longint;
  272. {$endif DPMI}
  273. {$endif FPC}
  274. begin
  275. {$ifdef FPC}
  276. { Assigned is used for procvar and
  277. stack stored temp records !! PM }
  278. (* if (p<>nil) {and
  279. ((p<heaporg) or
  280. (p>heapptr))} then
  281. runerror(230); *)
  282. {$else}
  283. {$ifdef DPMI}
  284. assigned:=(p<>nil);
  285. exit;
  286. {$else DPMI}
  287. if p=nil then
  288. lp:=0
  289. else
  290. lp:=longint(ptrrec(p).seg)*16+longint(ptrrec(p).ofs);
  291. if (lp<>0) and
  292. ((lp<longint(seg(heaporg^))*16+longint(ofs(heaporg^))) or
  293. (lp>longint(seg(heapptr^))*16+longint(ofs(heapptr^)))) then
  294. runerror(230);
  295. {$endif DPMI}
  296. {$endif FPC}
  297. assigned:=(p<>nil);
  298. end;
  299. {$endif}
  300. function min(a,b : longint) : longint;
  301. {
  302. return the minimal of a and b
  303. }
  304. begin
  305. if a>b then
  306. min:=b
  307. else
  308. min:=a;
  309. end;
  310. function max(a,b : longint) : longint;
  311. {
  312. return the maximum of a and b
  313. }
  314. begin
  315. if a<b then
  316. max:=b
  317. else
  318. max:=a;
  319. end;
  320. function align(i,a:longint):longint;
  321. {
  322. return value <i> aligned <a> boundary
  323. }
  324. begin
  325. align:=(i+a-1) and not(a-1);
  326. end;
  327. procedure Replace(var s:string;s1:string;const s2:string);
  328. var
  329. last,
  330. i : longint;
  331. begin
  332. s1:=upper(s1);
  333. last:=0;
  334. repeat
  335. i:=pos(s1,upper(s));
  336. if i=last then
  337. i:=0;
  338. if (i>0) then
  339. begin
  340. Delete(s,i,length(s1));
  341. Insert(s2,s,i);
  342. last:=i;
  343. end;
  344. until (i=0);
  345. end;
  346. procedure ReplaceCase(var s:string;const s1,s2:string);
  347. var
  348. last,
  349. i : longint;
  350. begin
  351. last:=0;
  352. repeat
  353. i:=pos(s1,s);
  354. if i=last then
  355. i:=0;
  356. if (i>0) then
  357. begin
  358. Delete(s,i,length(s1));
  359. Insert(s2,s,i);
  360. last:=i;
  361. end;
  362. until (i=0);
  363. end;
  364. function upper(const s : string) : string;
  365. {
  366. return uppercased string of s
  367. }
  368. var
  369. i : longint;
  370. begin
  371. for i:=1 to length(s) do
  372. if s[i] in ['a'..'z'] then
  373. upper[i]:=char(byte(s[i])-32)
  374. else
  375. upper[i]:=s[i];
  376. {$ifdef FPC}
  377. {$ifopt H+}
  378. setlength(upper,length(s));
  379. {$else}
  380. upper[0]:=s[0];
  381. {$endif}
  382. {$else}
  383. upper[0]:=s[0];
  384. {$endif}
  385. end;
  386. function lower(const s : string) : string;
  387. {
  388. return lowercased string of s
  389. }
  390. var
  391. i : longint;
  392. begin
  393. for i:=1 to length(s) do
  394. if s[i] in ['A'..'Z'] then
  395. lower[i]:=char(byte(s[i])+32)
  396. else
  397. lower[i]:=s[i];
  398. {$ifndef TP}
  399. {$ifopt H+}
  400. setlength(lower,length(s));
  401. {$else}
  402. lower[0]:=s[0];
  403. {$endif}
  404. {$else}
  405. lower[0]:=s[0];
  406. {$endif}
  407. end;
  408. procedure uppervar(var s : string);
  409. {
  410. uppercase string s
  411. }
  412. var
  413. i : longint;
  414. begin
  415. for i:=1 to length(s) do
  416. if s[i] in ['a'..'z'] then
  417. s[i]:=char(byte(s[i])-32);
  418. end;
  419. {$ifdef FPC}
  420. function tostru(i:cardinal):string;
  421. {
  422. return string of value i, but for cardinals
  423. }
  424. var hs:string;
  425. begin
  426. str(i,hs);
  427. tostru:=hs;
  428. end;
  429. {$else FPC}
  430. function tostru(i:longint):string;
  431. begin
  432. tostru:=tostr(i);
  433. end;
  434. {$endif FPC}
  435. function trimspace(const s:string):string;
  436. {
  437. return s with all leading and ending spaces and tabs removed
  438. }
  439. var
  440. i,j : longint;
  441. begin
  442. i:=length(s);
  443. while (i>0) and (s[i] in [#9,' ']) do
  444. dec(i);
  445. j:=1;
  446. while (j<i) and (s[j] in [#9,' ']) do
  447. inc(j);
  448. trimspace:=Copy(s,j,i-j+1);
  449. end;
  450. function tostr(i : longint) : string;
  451. {
  452. return string of value i
  453. }
  454. var
  455. hs : string;
  456. begin
  457. str(i,hs);
  458. tostr:=hs;
  459. end;
  460. function tostr_with_plus(i : longint) : string;
  461. {
  462. return string of value i, but always include a + when i>=0
  463. }
  464. var
  465. hs : string;
  466. begin
  467. str(i,hs);
  468. if i>=0 then
  469. tostr_with_plus:='+'+hs
  470. else
  471. tostr_with_plus:=hs;
  472. end;
  473. procedure valint(S : string;var V : longint;var code : integer);
  474. {
  475. val() with support for octal, which is not supported under tp7
  476. }
  477. {$ifndef FPC}
  478. var
  479. vs : longint;
  480. c : byte;
  481. begin
  482. if s[1]='%' then
  483. begin
  484. vs:=0;
  485. longint(v):=0;
  486. for c:=2 to length(s) do
  487. begin
  488. if s[c]='0' then
  489. vs:=vs shl 1
  490. else
  491. if s[c]='1' then
  492. vs:=vs shl 1+1
  493. else
  494. begin
  495. code:=c;
  496. exit;
  497. end;
  498. end;
  499. code:=0;
  500. longint(v):=vs;
  501. end
  502. else
  503. system.val(S,V,code);
  504. end;
  505. {$else not FPC}
  506. begin
  507. system.val(S,V,code);
  508. end;
  509. {$endif not FPC}
  510. function is_number(const s : string) : boolean;
  511. {
  512. is string a correct number ?
  513. }
  514. var
  515. w : integer;
  516. l : longint;
  517. begin
  518. valint(s,l,w);
  519. is_number:=(w=0);
  520. end;
  521. function ispowerof2(value : longint;var power : longint) : boolean;
  522. {
  523. return if value is a power of 2. And if correct return the power
  524. }
  525. var
  526. hl : longint;
  527. i : longint;
  528. begin
  529. hl:=1;
  530. ispowerof2:=true;
  531. for i:=0 to 31 do
  532. begin
  533. if hl=value then
  534. begin
  535. power:=i;
  536. exit;
  537. end;
  538. hl:=hl shl 1;
  539. end;
  540. ispowerof2:=false;
  541. end;
  542. { enable ansistring comparison }
  543. { 0 means equal }
  544. { 1 means p1 > p2 }
  545. { -1 means p1 < p2 }
  546. function compareansistrings(p1,p2 : pchar;length1,length2 : longint) : longint;
  547. var
  548. i,j : longint;
  549. begin
  550. compareansistrings:=0;
  551. j:=min(length1,length2);
  552. for i:=1 to j do
  553. begin
  554. if p1[i]>p2[i] then
  555. begin
  556. compareansistrings:=1;
  557. exit;
  558. end
  559. else if p1[i]<p2[i] then
  560. begin
  561. compareansistrings:=-1;
  562. exit;
  563. end;
  564. end;
  565. if length1>length2 then
  566. compareansistrings:=1
  567. else
  568. if length1<length2 then
  569. compareansistrings:=-1;
  570. end;
  571. function concatansistrings(p1,p2 : pchar;length1,length2 : longint) : pchar;
  572. var
  573. p : pchar;
  574. begin
  575. getmem(p,length1+length2+1);
  576. move(p1[0],p[0],length1);
  577. move(p2[0],p[length1],length2+1);
  578. concatansistrings:=p;
  579. end;
  580. {****************************************************************************
  581. Time Handling
  582. ****************************************************************************}
  583. Function L0(l:longint):string;
  584. {
  585. return the string of value l, if l<10 then insert a zero, so
  586. the string is always at least 2 chars '01','02',etc
  587. }
  588. var
  589. s : string;
  590. begin
  591. Str(l,s);
  592. if l<10 then
  593. s:='0'+s;
  594. L0:=s;
  595. end;
  596. function gettimestr:string;
  597. {
  598. get the current time in a string HH:MM:SS
  599. }
  600. var
  601. hour,min,sec,hsec : word;
  602. begin
  603. {$ifdef delphi}
  604. dmisc.gettime(hour,min,sec,hsec);
  605. {$else delphi}
  606. dos.gettime(hour,min,sec,hsec);
  607. {$endif delphi}
  608. gettimestr:=L0(Hour)+':'+L0(min)+':'+L0(sec);
  609. end;
  610. function getdatestr:string;
  611. {
  612. get the current date in a string YY/MM/DD
  613. }
  614. var
  615. Year,Month,Day,Wday : Word;
  616. begin
  617. {$ifdef delphi}
  618. dmisc.getdate(year,month,day,wday);
  619. {$else}
  620. dos.getdate(year,month,day,wday);
  621. {$endif}
  622. getdatestr:=L0(Year)+'/'+L0(Month)+'/'+L0(Day);
  623. end;
  624. function filetimestring( t : longint) : string;
  625. {
  626. convert dos datetime t to a string YY/MM/DD HH:MM:SS
  627. }
  628. var
  629. {$ifndef linux}
  630. DT : DateTime;
  631. {$endif}
  632. Year,Month,Day,Hour,Min,Sec : Word;
  633. begin
  634. if t=-1 then
  635. begin
  636. FileTimeString:='Not Found';
  637. exit;
  638. end;
  639. {$ifndef linux}
  640. unpacktime(t,DT);
  641. Year:=dT.year;month:=dt.month;day:=dt.day;
  642. Hour:=dt.hour;min:=dt.min;sec:=dt.sec;
  643. {$else}
  644. EpochToLocal (t,year,month,day,hour,min,sec);
  645. {$endif}
  646. filetimestring:=L0(Year)+'/'+L0(Month)+'/'+L0(Day)+' '+L0(Hour)+':'+L0(min)+':'+L0(sec);
  647. end;
  648. {****************************************************************************
  649. Default Macro Handling
  650. ****************************************************************************}
  651. procedure DefaultReplacements(var s:string);
  652. begin
  653. { Replace some macro's }
  654. Replace(s,'$FPCVER',full_version_string);
  655. Replace(s,'$FPCDATE',date_string);
  656. Replace(s,'$FPCTARGET',target_cpu_string);
  657. Replace(s,'$FPCCPU',target_cpu_string);
  658. Replace(s,'$TARGET',target_path);
  659. Replace(s,'$FPCOS',target_path);
  660. end;
  661. {****************************************************************************
  662. File Handling
  663. ****************************************************************************}
  664. function path_absolute(const s : string) : boolean;
  665. {
  666. is path s an absolute path?
  667. }
  668. begin
  669. path_absolute:=false;
  670. {$ifdef linux}
  671. if (length(s)>0) and (s[1]='/') then
  672. path_absolute:=true;
  673. {$else linux}
  674. {$ifdef amiga}
  675. if ((length(s)>0) and ((s[1]='\') or (s[1]='/'))) or (Pos(':',s) = length(s)) then
  676. path_absolute:=true;
  677. {$else}
  678. if ((length(s)>0) and ((s[1]='\') or (s[1]='/'))) or
  679. ((length(s)>2) and (s[2]=':') and ((s[3]='\') or (s[3]='/'))) then
  680. path_absolute:=true;
  681. {$endif amiga}
  682. {$endif linux}
  683. end;
  684. {$ifndef FPC}
  685. Procedure FindClose(var Info : SearchRec);
  686. Begin
  687. End;
  688. {$endif not FPC}
  689. {$ifdef delphi}
  690. Function FileExists ( Const F : String) : Boolean;
  691. begin
  692. FileExists:=sysutils.FileExists(f);
  693. end;
  694. {$else}
  695. Function FileExists ( Const F : String) : Boolean;
  696. Var
  697. {$ifdef linux}
  698. Info : Stat;
  699. {$else}
  700. Info : SearchRec;
  701. {$endif}
  702. begin
  703. {$ifdef linux}
  704. FileExists:=FStat(F,info);
  705. {$else}
  706. findfirst(F,readonly+archive+hidden,info);
  707. FileExists:=(doserror=0);
  708. findclose(Info);
  709. {$endif}
  710. end;
  711. {$endif}
  712. Function RemoveFile(const f:string):boolean;
  713. var
  714. g : file;
  715. begin
  716. assign(g,f);
  717. {$I-}
  718. erase(g);
  719. {$I+}
  720. RemoveFile:=(ioresult=0);
  721. end;
  722. Function RemoveDir(d:string):boolean;
  723. begin
  724. if d[length(d)]=DirSep then
  725. Delete(d,length(d),1);
  726. {$I-}
  727. rmdir(d);
  728. {$I+}
  729. RemoveDir:=(ioresult=0);
  730. end;
  731. Function SplitFileName(const s:string):string;
  732. var
  733. p : dirstr;
  734. n : namestr;
  735. e : extstr;
  736. begin
  737. FSplit(s,p,n,e);
  738. SplitFileName:=n+e;
  739. end;
  740. Function SplitName(const s:string):string;
  741. var
  742. i,j : longint;
  743. begin
  744. i:=Length(s);
  745. j:=Length(s);
  746. while (i>0) and not(s[i] in ['/','\']) do
  747. dec(i);
  748. while (j>0) and (s[j]<>'.') do
  749. dec(j);
  750. if j<=i then
  751. j:=255;
  752. SplitName:=Copy(s,i+1,j-(i+1));
  753. end;
  754. Function SplitExtension(Const HStr:String):String;
  755. var
  756. j : longint;
  757. begin
  758. j:=length(Hstr);
  759. while (j>0) and (Hstr[j]<>'.') do
  760. begin
  761. if hstr[j]=DirSep then
  762. j:=0
  763. else
  764. dec(j);
  765. end;
  766. if j=0 then
  767. j:=254;
  768. SplitExtension:=Copy(Hstr,j,255);
  769. end;
  770. Function AddExtension(Const HStr,ext:String):String;
  771. begin
  772. if (Ext<>'') and (SplitExtension(HStr)='') then
  773. AddExtension:=Hstr+Ext
  774. else
  775. AddExtension:=Hstr;
  776. end;
  777. Function ForceExtension(Const HStr,ext:String):String;
  778. var
  779. j : longint;
  780. begin
  781. j:=length(Hstr);
  782. while (j>0) and (Hstr[j]<>'.') do
  783. dec(j);
  784. if j=0 then
  785. j:=255;
  786. ForceExtension:=Copy(Hstr,1,j-1)+Ext;
  787. end;
  788. Function FixPath(s:string;allowdot:boolean):string;
  789. var
  790. i : longint;
  791. begin
  792. { Fix separator }
  793. for i:=1 to length(s) do
  794. if s[i] in ['/','\'] then
  795. s[i]:=DirSep;
  796. { Fix ending / }
  797. if (length(s)>0) and (s[length(s)]<>DirSep) and
  798. (s[length(s)]<>':') then
  799. s:=s+DirSep;
  800. { Remove ./ }
  801. if (not allowdot) and (s='.'+DirSep) then
  802. s:='';
  803. { return }
  804. FixPath:=s;
  805. end;
  806. function FixFileName(const s:string):string;
  807. var
  808. i : longint;
  809. NoPath : boolean;
  810. begin
  811. NoPath:=true;
  812. for i:=length(s) downto 1 do
  813. begin
  814. case s[i] of
  815. {$ifdef Linux}
  816. '/','\' : begin
  817. FixFileName[i]:='/';
  818. NoPath:=false; {Skip lowercasing path: 'X11'<>'x11' }
  819. end;
  820. 'A'..'Z' : if NoPath then
  821. FixFileName[i]:=char(byte(s[i])+32)
  822. else
  823. FixFileName[i]:=s[i];
  824. {$else}
  825. '/' : FixFileName[i]:='\';
  826. 'A'..'Z' : FixFileName[i]:=char(byte(s[i])+32);
  827. {$endif}
  828. else
  829. FixFileName[i]:=s[i];
  830. end;
  831. end;
  832. {$ifndef TP}
  833. {$ifopt H+}
  834. SetLength(FixFileName,length(s));
  835. {$else}
  836. FixFileName[0]:=s[0];
  837. {$endif}
  838. {$else}
  839. FixFileName[0]:=s[0];
  840. {$endif}
  841. end;
  842. procedure AddPathToList(var list:string;s:string;first:boolean);
  843. var
  844. LastAdd,
  845. starti,i,j : longint;
  846. Found : boolean;
  847. CurrentDir,
  848. CurrPath,
  849. AddList : string;
  850. begin
  851. if s='' then
  852. exit;
  853. { Support default macro's }
  854. DefaultReplacements(s);
  855. { Fix List }
  856. if (length(list)>0) and (list[length(list)]<>';') then
  857. list:=list+';';
  858. GetDir(0,CurrentDir);
  859. CurrentDir:=FixPath(CurrentDir,false);
  860. AddList:='';
  861. LastAdd:=1;
  862. repeat
  863. j:=Pos(';',s);
  864. if j=0 then
  865. j:=255;
  866. {Get Pathname}
  867. CurrPath:=FixPath(Copy(s,1,j-1),false);
  868. if CurrPath='' then
  869. CurrPath:='.'+DirSep+';'
  870. else
  871. begin
  872. CurrPath:=FixPath(FExpand(CurrPath),false)+';';
  873. if (Copy(CurrPath,1,length(CurrentDir))=CurrentDir) then
  874. CurrPath:='.'+DirSep+Copy(CurrPath,length(CurrentDir)+1,255);
  875. end;
  876. Delete(s,1,j);
  877. {Check if already in path}
  878. found:=false;
  879. i:=0;
  880. starti:=1;
  881. while (not found) and (i<length(list)) do
  882. begin
  883. inc(i);
  884. if (list[i]=';') then
  885. begin
  886. found:=(CurrPath=Copy(List,starti,i-starti+1));
  887. if Found then
  888. begin
  889. if First then
  890. Delete(List,Starti,i-starti+1); {The new entry is placed first}
  891. end
  892. else
  893. starti:=i+1;
  894. end;
  895. end;
  896. if First then
  897. begin
  898. Insert(CurrPath,List,LastAdd);
  899. inc(LastAdd,Length(CurrPath));
  900. end
  901. else
  902. if not Found then
  903. List:=List+CurrPath
  904. until (s='');
  905. end;
  906. function search(const f : string;path : string;var b : boolean) : string;
  907. Var
  908. singlepathstring : string;
  909. i : longint;
  910. begin
  911. {$ifdef linux}
  912. for i:=1 to length(path) do
  913. if path[i]=':' then
  914. path[i]:=';';
  915. {$endif}
  916. b:=false;
  917. search:='';
  918. repeat
  919. i:=pos(';',path);
  920. if i=0 then
  921. i:=255;
  922. singlepathstring:=FixPath(copy(path,1,i-1),false);
  923. delete(path,1,i);
  924. If FileExists (singlepathstring+f) then
  925. begin
  926. Search:=singlepathstring;
  927. b:=true;
  928. exit;
  929. end;
  930. until path='';
  931. end;
  932. Function GetFileTime ( Var F : File) : Longint;
  933. Var
  934. {$ifdef linux}
  935. Info : Stat;
  936. {$endif}
  937. L : longint;
  938. begin
  939. {$ifdef linux}
  940. FStat (F,Info);
  941. L:=Info.Mtime;
  942. {$else}
  943. GetFTime(f,l);
  944. {$endif}
  945. GetFileTime:=L;
  946. end;
  947. Function GetNamedFileTime (Const F : String) : Longint;
  948. var
  949. L : Longint;
  950. {$ifndef linux}
  951. info : SearchRec;
  952. {$else}
  953. info : stat;
  954. {$endif}
  955. begin
  956. l:=-1;
  957. {$ifdef linux}
  958. if FStat (F,Info) then
  959. L:=info.mtime;
  960. {$else}
  961. {$ifdef delphi}
  962. dmisc.FindFirst (F,archive+readonly+hidden,info);
  963. {$else delphi}
  964. FindFirst (F,archive+readonly+hidden,info);
  965. {$endif delphi}
  966. if DosError=0 then
  967. l:=info.time;
  968. {$ifdef Linux}
  969. FindClose(info);
  970. {$endif}
  971. {$ifdef Win32}
  972. FindClose(info);
  973. {$endif}
  974. {$endif}
  975. GetNamedFileTime:=l;
  976. end;
  977. {Touch Assembler and object time to ppu time is there is a ppufilename}
  978. procedure SynchronizeFileTime(const fn1,fn2:string);
  979. var
  980. f : file;
  981. l : longint;
  982. begin
  983. Assign(f,fn1);
  984. {$I-}
  985. reset(f,1);
  986. {$I+}
  987. if ioresult=0 then
  988. begin
  989. getftime(f,l);
  990. close(f);
  991. assign(f,fn2);
  992. {$I-}
  993. reset(f,1);
  994. {$I+}
  995. if ioresult=0 then
  996. begin
  997. setftime(f,l);
  998. close(f);
  999. end;
  1000. end;
  1001. end;
  1002. function FindExe(bin:string;var found:boolean):string;
  1003. begin
  1004. bin:=FixFileName(bin)+source_os.exeext;
  1005. {$ifdef delphi}
  1006. FindExe:=Search(bin,'.;'+exepath+';'+dmisc.getenv('PATH'),found)+bin;
  1007. {$else delphi}
  1008. FindExe:=Search(bin,'.;'+exepath+';'+dos.getenv('PATH'),found)+bin;
  1009. {$endif delphi}
  1010. end;
  1011. procedure abstract;
  1012. begin
  1013. runerror(255);
  1014. end;
  1015. {****************************************************************************
  1016. Init
  1017. ****************************************************************************}
  1018. procedure get_exepath;
  1019. var
  1020. hs1 : namestr;
  1021. hs2 : extstr;
  1022. begin
  1023. {$ifdef delphi}
  1024. exepath:=dmisc.getenv('PPC_EXEC_PATH');
  1025. {$else delphi}
  1026. exepath:=dos.getenv('PPC_EXEC_PATH');
  1027. {$endif delphi}
  1028. if exepath='' then
  1029. fsplit(FixFileName(paramstr(0)),exepath,hs1,hs2);
  1030. {$ifdef linux}
  1031. if exepath='' then
  1032. fsearch(hs1,dos.getenv('PATH'));
  1033. {$endif}
  1034. exepath:=FixPath(exepath,false);
  1035. end;
  1036. procedure DoneGlobals;
  1037. begin
  1038. initdefines.done;
  1039. if assigned(DLLImageBase) then
  1040. StringDispose(DLLImageBase);
  1041. end;
  1042. procedure InitGlobals;
  1043. begin
  1044. { set global switches }
  1045. do_build:=false;
  1046. do_make:=true;
  1047. {$ifdef tp}
  1048. use_big:=false;
  1049. {$endif tp}
  1050. { Output }
  1051. OutputFile:='';
  1052. OutputExeDir:='';
  1053. OutputUnitDir:='';
  1054. { Utils directory }
  1055. utilsdirectory:='';
  1056. { Def file }
  1057. usewindowapi:=false;
  1058. description:='Compiled by FPC '+version_string+' - '+target_cpu_string;
  1059. { Init values }
  1060. initmodeswitches:=fpcmodeswitches;
  1061. initlocalswitches:=[];
  1062. initmoduleswitches:=[cs_extsyntax,cs_browser];
  1063. initglobalswitches:=[cs_check_unit_name,cs_link_static];
  1064. {$ifdef i386}
  1065. initoptprocessor:=Class386;
  1066. initpackenum:=4;
  1067. initpackrecords:=packrecord_2;
  1068. initoutputformat:=target_asm.id;
  1069. initasmmode:=asmmode_i386_att;
  1070. {$else not i386}
  1071. {$ifdef m68k}
  1072. initoptprocessor:=MC68000;
  1073. include(initmoduleswitches,cs_fp_emulation);
  1074. initpackenum:=4;
  1075. initpackrecords:=packrecord_2;
  1076. initoutputformat:=as_m68k_as;
  1077. initasmmode:=asmmode_m68k_mot;
  1078. {$endif m68k}
  1079. {$endif i386}
  1080. initdefines.init;
  1081. { memory sizes, will be overriden by parameter or default for target
  1082. in options or init_parser }
  1083. stacksize:=0;
  1084. heapsize:=0;
  1085. maxheapsize:=0;
  1086. { compile state }
  1087. in_args:=false;
  1088. must_be_valid:=true;
  1089. not_unit_proc:=true;
  1090. apptype:=at_cui;
  1091. end;
  1092. begin
  1093. get_exepath;
  1094. {$ifdef EXTDEBUG}
  1095. {$ifdef FPC}
  1096. EntryMemUsed:=system.HeapSize-MemAvail;
  1097. {$endif FPC}
  1098. {$endif}
  1099. end.
  1100. {
  1101. $Log$
  1102. Revision 1.20 1999-08-19 13:02:12 pierre
  1103. + label faillabel added for _FAIL support
  1104. Revision 1.19 1999/08/16 15:35:21 pierre
  1105. * fix for DLL relocation problems
  1106. * external bss vars had wrong stabs for pecoff
  1107. + -WB11000000 to specify default image base, allows to
  1108. load several DLLs with debugging info included
  1109. (relocatable DLL are stripped because the relocation
  1110. of the .Stab section is misplaced by ldw)
  1111. Revision 1.18 1999/08/11 17:26:32 peter
  1112. * tlinker object is now inherited for win32 and dos
  1113. * postprocessexecutable is now a method of tlinker
  1114. Revision 1.17 1999/08/10 12:51:14 pierre
  1115. * bind_win32_dll removed (Relocsection used instead)
  1116. * now relocsection is true by default ! (needs dlltool
  1117. for DLL generation)
  1118. Revision 1.16 1999/08/05 20:54:19 daniel
  1119. * Changes for new symtable.
  1120. Revision 1.15 1999/08/03 17:09:35 florian
  1121. * the alpha compiler can be compiled now
  1122. Revision 1.14 1999/07/23 16:05:19 peter
  1123. * alignment is now saved in the symtable
  1124. * C alignment added for records
  1125. * PPU version increased to solve .12 <-> .13 probs
  1126. Revision 1.13 1999/07/18 10:19:52 florian
  1127. * made it compilable with Dlephi 4 again
  1128. + fixed problem with large stack allocations on win32
  1129. Revision 1.12 1999/07/13 19:14:44 michael
  1130. + Defaultreplacemens now more logical
  1131. Revision 1.11 1999/07/10 10:26:18 peter
  1132. * merged
  1133. Revision 1.8.2.2 1999/07/10 10:03:04 peter
  1134. * fixed initialization/finalization in fpc mode
  1135. * allow $TARGET also in search paths
  1136. Revision 1.8.2.1 1999/07/07 07:53:21 michael
  1137. + Merged patches from florian
  1138. Revision 1.10 1999/07/06 21:48:16 florian
  1139. * a lot bug fixes:
  1140. - po_external isn't any longer necessary for procedure compatibility
  1141. - m_tp_procvar is in -Sd now available
  1142. - error messages of procedure variables improved
  1143. - return values with init./finalization fixed
  1144. - data types with init./finalization aren't any longer allowed in variant
  1145. record
  1146. Revision 1.9 1999/07/03 00:29:48 peter
  1147. * new link writing to the ppu, one .ppu is needed for all link types,
  1148. static (.o) is now always created also when smartlinking is used
  1149. Revision 1.8 1999/05/27 19:44:29 peter
  1150. * removed oldasm
  1151. * plabel -> pasmlabel
  1152. * -a switches to source writing automaticly
  1153. * assembler readers OOPed
  1154. * asmsymbol automaticly external
  1155. * jumptables and other label fixes for asm readers
  1156. Revision 1.7 1999/05/13 21:59:26 peter
  1157. * removed oldppu code
  1158. * warning if objpas is loaded from uses
  1159. * first things for new deref writing
  1160. Revision 1.6 1999/05/05 10:05:50 florian
  1161. * a delphi compiled compiler recompiles ppc
  1162. Revision 1.5 1999/05/04 21:44:43 florian
  1163. * changes to compile it with Delphi 4.0
  1164. Revision 1.4 1999/04/26 13:31:32 peter
  1165. * release storenumber,double_checksum
  1166. Revision 1.3 1999/04/21 14:12:55 peter
  1167. * default asm changed to att
  1168. Revision 1.2 1999/04/16 09:56:05 pierre
  1169. * unused local var commented
  1170. Revision 1.1 1999/04/08 09:14:46 michael
  1171. + Re-added;
  1172. Revision 1.119 1999/04/07 14:15:53 pierre
  1173. * assigned test for FPC removed, problems with stack variables
  1174. Revision 1.118 1999/03/17 22:23:17 florian
  1175. * a FPC compiled compiler checks now also in debug mode in assigned
  1176. if a pointer points to the heap
  1177. * when a symtable is loaded, there is no need to check for duplicate
  1178. symbols. This leads to crashes because defowner isn't assigned
  1179. in this case
  1180. Revision 1.117 1999/03/04 13:55:42 pierre
  1181. * some m68k fixes (still not compilable !)
  1182. * new(tobj) does not give warning if tobj has no VMT !
  1183. Revision 1.116 1999/03/02 18:20:09 peter
  1184. * fixed compareansistring which gave always -1 or 1 and never 0 :)
  1185. Revision 1.115 1999/03/01 15:43:47 peter
  1186. * synchronize also the objfile for ag386bin
  1187. Revision 1.114 1999/02/25 21:02:36 peter
  1188. * ag386bin updates
  1189. + coff writer
  1190. Revision 1.113 1999/02/22 13:06:50 pierre
  1191. + -b and -bl options work !
  1192. + cs_local_browser ($L+) is disabled if cs_browser ($Y+)
  1193. is not enabled when quitting global section
  1194. * local vars and procedures are not yet stored into PPU
  1195. Revision 1.111 1999/02/11 09:46:22 pierre
  1196. * fix for normal method calls inside static methods :
  1197. WARNING there were both parser and codegen errors !!
  1198. added static_call boolean to calln tree
  1199. Revision 1.110 1999/01/27 13:05:42 pierre
  1200. * give include file name on error
  1201. Revision 1.109 1999/01/22 16:56:50 pierre
  1202. * findclose problem fixed
  1203. Revision 1.108 1999/01/22 10:08:19 daniel
  1204. * Findclose is removed for go32v1 and go32v2 platforms, because this is
  1205. TP incompatible. It is now only called for Linux and Win32.
  1206. Revision 1.107 1999/01/12 14:25:27 peter
  1207. + BrowserLog for browser.log generation
  1208. + BrowserCol for browser info in TCollections
  1209. * released all other UseBrowser
  1210. Revision 1.106 1999/01/05 08:19:57 florian
  1211. * mainly problem with invalid case ranges fixed (reported by Jonas)
  1212. Revision 1.105 1998/12/28 23:26:16 peter
  1213. + resource file handling ($R directive) for Win32
  1214. Revision 1.104 1998/12/23 22:49:42 peter
  1215. * forgot one conflict :(
  1216. Revision 1.103 1998/12/23 22:48:41 peter
  1217. * fixed findclose problem
  1218. Revision 1.102 1998/12/23 14:26:30 jonas
  1219. * patch from Peter: remove FindClose call in FileExists (caused error under Dos
  1220. when opening the ppc386.cfg file)
  1221. Revision 1.101 1998/12/23 14:02:00 peter
  1222. * daniels patches against the latest versions
  1223. Revision 1.99 1998/12/19 00:23:47 florian
  1224. * ansistring memory leaks fixed
  1225. Revision 1.98 1998/12/15 10:23:24 peter
  1226. + -iSO, -iSP, -iTO, -iTP
  1227. Revision 1.97 1998/12/11 00:03:17 peter
  1228. + globtype,tokens,version unit splitted from globals
  1229. Revision 1.96 1998/12/08 10:18:06 peter
  1230. + -gh for heaptrc unit
  1231. Revision 1.95 1998/12/03 10:17:30 peter
  1232. * target_os.use_bound_instruction boolean
  1233. Revision 1.94 1998/11/30 13:26:22 pierre
  1234. * the code for ordering the exported procs/vars was buggy
  1235. + added -WB to force binding (Ozerski way of creating DLL)
  1236. this is off by default as direct writing of .edata section seems
  1237. OK
  1238. Revision 1.93 1998/11/30 09:43:10 pierre
  1239. * some range check bugs fixed (still not working !)
  1240. + added DLL writing support for win32 (also accepts variables)
  1241. + TempAnsi for code that could be used for Temporary ansi strings
  1242. handling
  1243. Revision 1.92 1998/11/27 14:50:37 peter
  1244. + open strings, $P switch support
  1245. Revision 1.91 1998/11/26 21:33:08 peter
  1246. * rangecheck updates
  1247. Revision 1.90 1998/11/24 17:03:23 peter
  1248. * removed obsolete version.inc
  1249. Revision 1.89 1998/11/16 15:41:41 peter
  1250. * tp7 didn't like my ifopt H+ :(
  1251. Revision 1.88 1998/11/16 10:17:07 peter
  1252. * fixed for H+ compilation
  1253. Revision 1.87 1998/11/15 16:32:36 florian
  1254. * some stuff of Pavel implement (win32 dll creation)
  1255. * bug with ansistring function results fixed
  1256. Revision 1.86 1998/11/05 12:02:43 peter
  1257. * released useansistring
  1258. * removed -Sv, its now available in fpc modes
  1259. Revision 1.85 1998/10/26 22:23:30 peter
  1260. + fixpath() has an extra option to allow a ./ as path
  1261. Revision 1.84 1998/10/25 23:30:15 peter
  1262. * valint fix for tp7 to overcome overflow
  1263. Revision 1.83 1998/10/22 17:54:02 florian
  1264. + switch $APPTYPE for win32 added
  1265. Revision 1.82 1998/10/22 11:56:44 pierre
  1266. * FixPath handling of c: corrected
  1267. Revision 1.81 1998/10/19 15:41:00 peter
  1268. * better splitname to support glib-1.1.dll alike names
  1269. Revision 1.80 1998/10/16 13:37:17 florian
  1270. + switch -FD added to specify the path for utilities
  1271. Revision 1.79 1998/10/16 08:51:46 peter
  1272. + target_os.stackalignment
  1273. + stack can be aligned at 2 or 4 byte boundaries
  1274. Revision 1.78 1998/10/14 13:38:21 peter
  1275. * fixed path with staticlib/objects in ppufiles
  1276. Revision 1.77 1998/10/13 14:01:09 peter
  1277. * fixed -al
  1278. Revision 1.76 1998/10/13 13:10:15 peter
  1279. * new style for m68k/i386 infos and enums
  1280. Revision 1.75 1998/10/13 08:19:32 pierre
  1281. + source_os is now set correctly for cross-processor compilers
  1282. (tos contains all target_infos and
  1283. we use CPU86 and CPU68 conditionnals to
  1284. get the source operating system
  1285. this only works if you do not undefine
  1286. the source target !!)
  1287. * several cg68k memory leaks fixed
  1288. + started to change the code so that it should be possible to have
  1289. a complete compiler (both for m68k and i386 !!)
  1290. Revision 1.74 1998/10/12 10:28:29 florian
  1291. + auto dereferencing of pointers to structured types in delphi mode
  1292. Revision 1.73 1998/10/12 09:49:56 florian
  1293. + support of <procedure var type>:=<pointer> in delphi mode added
  1294. Revision 1.72 1998/10/06 17:16:48 pierre
  1295. * some memory leaks fixed (thanks to Peter for heaptrc !)
  1296. Revision 1.71 1998/09/30 19:53:54 michael
  1297. + Upgraded to version 0.99.9
  1298. Revision 1.70 1998/09/29 15:23:03 peter
  1299. * remove also the end files for smartlinking
  1300. Revision 1.69 1998/09/26 17:45:28 peter
  1301. + idtoken and only one token table
  1302. Revision 1.68 1998/09/24 23:49:04 peter
  1303. + aktmodeswitches
  1304. Revision 1.67 1998/09/22 17:13:46 pierre
  1305. + browsing updated and developed
  1306. records and objects fields are also stored
  1307. Revision 1.66 1998/09/22 15:40:54 peter
  1308. * some extra ifdef GDB
  1309. Revision 1.65 1998/09/18 16:03:38 florian
  1310. * some changes to compile with Delphi
  1311. Revision 1.64 1998/09/10 15:25:29 daniel
  1312. + Added maxheapsize.
  1313. * Corrected semi-bug in calling the assembler and the linker
  1314. Revision 1.63 1998/09/09 18:17:13 florian
  1315. * version number changed to 0.99.8
  1316. Revision 1.62 1998/09/07 17:36:59 florian
  1317. * first fixes for published properties
  1318. Revision 1.61 1998/09/03 11:21:52 peter
  1319. * -al sets cs_asm_source
  1320. Revision 1.60 1998/09/01 12:53:20 peter
  1321. + aktpackenum
  1322. Revision 1.59 1998/09/01 07:54:18 pierre
  1323. * UseBrowser a little updated (might still be buggy !!)
  1324. * bug in psub.pas in function specifier removed
  1325. * stdcall allowed in interface and in implementation
  1326. (FPC will not yet complain if it is missing in either part
  1327. because stdcall is only a dummy !!)
  1328. Revision 1.58 1998/08/31 12:26:25 peter
  1329. * m68k and palmos updates from surebugfixes
  1330. Revision 1.57 1998/08/29 13:51:09 peter
  1331. * moved get_exepath to globals
  1332. + date_string const with the current date for 0.99.7+
  1333. Revision 1.56 1998/08/26 15:35:31 peter
  1334. * fixed scannerfiles for macros
  1335. + $I %<environment>%
  1336. Revision 1.55 1998/08/25 12:42:35 pierre
  1337. * CDECL changed to CVAR for variables
  1338. specifications are read in structures also
  1339. + started adding GPC compatibility mode ( option -Sp)
  1340. * names changed to lowercase
  1341. Revision 1.54 1998/08/19 18:04:53 peter
  1342. * fixed current_module^.in_implementation flag
  1343. Revision 1.53 1998/08/19 16:07:45 jonas
  1344. * changed optimizer switches + cleanup of DestroyRefs in daopt386.pas
  1345. Revision 1.52 1998/08/19 10:06:13 peter
  1346. * fixed filenames and removedir which supports slash at the end
  1347. Revision 1.51 1998/08/17 09:17:46 peter
  1348. * static/shared linking updates
  1349. Revision 1.50 1998/08/14 21:56:33 peter
  1350. * setting the outputfile using -o works now to create static libs
  1351. Revision 1.49 1998/08/13 10:57:31 peter
  1352. * constant sets are now written correctly to the ppufile
  1353. Revision 1.48 1998/08/11 15:31:37 peter
  1354. * write extended to ppu file
  1355. * new version 0.99.7
  1356. Revision 1.47 1998/08/10 14:49:59 peter
  1357. + localswitches, moduleswitches, globalswitches splitting
  1358. Revision 1.46 1998/08/10 10:18:25 peter
  1359. + Compiler,Comphook unit which are the new interface units to the
  1360. compiler
  1361. Revision 1.45 1998/07/24 22:16:56 florian
  1362. * internal error 10 together with array access fixed. I hope
  1363. that's the final fix.
  1364. Revision 1.44 1998/07/18 17:11:08 florian
  1365. + ansi string constants fixed
  1366. + switch $H partial implemented
  1367. Revision 1.43 1998/07/14 21:46:42 peter
  1368. * updated messages file
  1369. Revision 1.42 1998/07/08 14:28:35 daniel
  1370. * Fixed small TP incompatibility: Fsplit requires use of dirstr, namestr and
  1371. extstr
  1372. Revision 1.41 1998/07/07 11:19:56 peter
  1373. + NEWINPUT for a better inputfile and scanner object
  1374. Revision 1.40 1998/06/25 08:48:13 florian
  1375. * first version of rtti support
  1376. Revision 1.39 1998/06/17 14:10:12 peter
  1377. * small os2 fixes
  1378. * fixed interdependent units with newppu (remake3 under linux works now)
  1379. Revision 1.38 1998/06/16 08:56:21 peter
  1380. + targetcpu
  1381. * cleaner pmodules for newppu
  1382. Revision 1.37 1998/06/13 00:10:06 peter
  1383. * working browser and newppu
  1384. * some small fixes against crashes which occured in bp7 (but not in
  1385. fpc?!)
  1386. Revision 1.36 1998/06/12 16:15:31 pierre
  1387. * external name 'C_var';
  1388. export name 'intern_C_var';
  1389. cdecl;
  1390. cdecl;external;
  1391. are now supported only with -Sv switch
  1392. Revision 1.34 1998/06/04 23:51:39 peter
  1393. * m68k compiles
  1394. + .def file creation moved to gendef.pas so it could also be used
  1395. for win32
  1396. Revision 1.33 1998/06/03 22:48:54 peter
  1397. + wordbool,longbool
  1398. * rename bis,von -> high,low
  1399. * moved some systemunit loading/creating to psystem.pas
  1400. Revision 1.32 1998/05/30 14:31:04 peter
  1401. + $ASMMODE
  1402. Revision 1.31 1998/05/28 14:40:24 peter
  1403. * fixes for newppu, remake3 works now with it
  1404. Revision 1.30 1998/05/27 19:45:03 peter
  1405. * symtable.pas splitted into includefiles
  1406. * symtable adapted for $ifdef NEWPPU
  1407. Revision 1.29 1998/05/25 17:11:39 pierre
  1408. * firstpasscount bug fixed
  1409. now all is already set correctly the first time
  1410. under EXTDEBUG try -gp to skip all other firstpasses
  1411. it works !!
  1412. * small bug fixes
  1413. - for smallsets with -dTESTSMALLSET
  1414. - some warnings removed (by correcting code !)
  1415. Revision 1.28 1998/05/23 01:21:07 peter
  1416. + aktasmmode, aktoptprocessor, aktoutputformat
  1417. + smartlink per module $SMARTLINK-/+ (like MMX) and moved to aktswitches
  1418. + $LIBNAME to set the library name where the unit will be put in
  1419. * splitted cgi386 a bit (codeseg to large for bp7)
  1420. * nasm, tasm works again. nasm moved to ag386nsm.pas
  1421. Revision 1.27 1998/05/20 09:42:33 pierre
  1422. + UseTokenInfo now default
  1423. * unit in interface uses and implementation uses gives error now
  1424. * only one error for unknown symbol (uses lastsymknown boolean)
  1425. the problem came from the label code !
  1426. + first inlined procedures and function work
  1427. (warning there might be allowed cases were the result is still wrong !!)
  1428. * UseBrower updated gives a global list of all position of all used symbols
  1429. with switch -gb
  1430. Revision 1.26 1998/05/12 10:46:59 peter
  1431. * moved printstatus to verb_def
  1432. + V_Normal which is between V_Error and V_Warning and doesn't have a
  1433. prefix like error: warning: and is included in V_Default
  1434. * fixed some messages
  1435. * first time parameter scan is only for -v and -T
  1436. - removed old style messages
  1437. Revision 1.25 1998/05/11 13:07:54 peter
  1438. + $ifdef NEWPPU for the new ppuformat
  1439. + $define GDB not longer required
  1440. * removed all warnings and stripped some log comments
  1441. * no findfirst/findnext anymore to remove smartlink *.o files
  1442. Revision 1.24 1998/05/08 09:21:20 michael
  1443. * Added missing -Fl message to messages file.
  1444. * Corrected mangling of file names when doing Linklib
  1445. * -Fl now actually WORKS.
  1446. * Librarysearchpath is now a field in linker object.
  1447. Revision 1.23 1998/05/06 15:04:20 pierre
  1448. + when trying to find source files of a ppufile
  1449. check the includepathlist for included files
  1450. the main file must still be in the same directory
  1451. Revision 1.22 1998/05/06 08:38:39 pierre
  1452. * better position info with UseTokenInfo
  1453. UseTokenInfo greatly simplified
  1454. + added check for changed tree after first time firstpass
  1455. (if we could remove all the cases were it happen
  1456. we could skip all firstpass if firstpasscount > 1)
  1457. Only with ExtDebug
  1458. Revision 1.21 1998/05/04 17:54:25 peter
  1459. + smartlinking works (only case jumptable left todo)
  1460. * redesign of systems.pas to support assemblers and linkers
  1461. + Unitname is now also in the PPU-file, increased version to 14
  1462. Revision 1.20 1998/05/01 07:43:53 florian
  1463. + basics for rtti implemented
  1464. + switch $m (generate rtti for published sections)
  1465. Revision 1.19 1998/04/30 15:59:40 pierre
  1466. * GDB works again better :
  1467. correct type info in one pass
  1468. + UseTokenInfo for better source position
  1469. * fixed one remaining bug in scanner for line counts
  1470. * several little fixes
  1471. Revision 1.18 1998/04/29 10:33:52 pierre
  1472. + added some code for ansistring (not complete nor working yet)
  1473. * corrected operator overloading
  1474. * corrected nasm output
  1475. + started inline procedures
  1476. + added starstarn : use ** for exponentiation (^ gave problems)
  1477. + started UseTokenInfo cond to get accurate positions
  1478. Revision 1.17 1998/04/27 23:10:28 peter
  1479. + new scanner
  1480. * $makelib -> if smartlink
  1481. * small filename fixes pmodule.setfilename
  1482. * moved import from files.pas -> import.pas
  1483. Revision 1.16 1998/04/27 15:45:20 peter
  1484. + -Xl for smartlink
  1485. + target_info.arext = .a
  1486. Revision 1.15 1998/04/22 21:06:50 florian
  1487. * last fixes before the release:
  1488. - veryyyy slow firstcall fixed
  1489. Revision 1.14 1998/04/21 13:48:09 michael
  1490. + Updated patch number
  1491. Revision 1.13 1998/04/21 10:16:47 peter
  1492. * patches from strasbourg
  1493. * objects is not used anymore in the fpc compiled version
  1494. Revision 1.12 1998/04/09 14:28:06 jonas
  1495. + basic k6 and 6x86 optimizing support (-O7 and -O8)
  1496. Revision 1.11 1998/04/08 16:58:02 pierre
  1497. * several bugfixes
  1498. ADD ADC and AND are also sign extended
  1499. nasm output OK (program still crashes at end
  1500. and creates wrong assembler files !!)
  1501. procsym types sym in tdef removed !!
  1502. Revision 1.10 1998/04/08 11:34:22 peter
  1503. * nasm works (linux only tested)
  1504. Revision 1.9 1998/04/07 21:37:30 peter
  1505. * fixed fixpath to also change / and \ slashes and better addpathtolist
  1506. Revision 1.8 1998/04/07 13:19:44 pierre
  1507. * bugfixes for reset_gdb_info
  1508. in MEM parsing for go32v2
  1509. better external symbol creation
  1510. support for rhgdb.exe (lowercase file names)
  1511. Revision 1.7 1998/04/06 16:19:46 peter
  1512. * fixed the -Up.. bug
  1513. }