globals.pas 49 KB

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