globals.pas 48 KB

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