globals.pas 47 KB

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