globals.pas 46 KB

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