globals.pas 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433
  1. {
  2. $Id$
  3. Copyright (C) 1998-2000 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. unit globals;
  19. {$i defines.inc}
  20. interface
  21. uses
  22. {$ifdef win32}
  23. windows,
  24. {$endif}
  25. {$ifdef unix}
  26. {$ifdef ver1_0}
  27. linux,
  28. {$else}
  29. unix,
  30. {$endif}
  31. {$endif}
  32. {$ifdef os2}
  33. doscalls,
  34. {$endif}
  35. {$ifdef Delphi}
  36. sysutils,
  37. dmisc,
  38. {$else}
  39. strings,
  40. dos,
  41. {$endif}
  42. cutils,cobjects,cclasses,
  43. globtype,version,systems;
  44. const
  45. {$ifdef unix}
  46. DirSep = '/';
  47. {$else}
  48. {$ifdef amiga}
  49. DirSep = '/';
  50. {$else}
  51. DirSep = '\';
  52. {$endif}
  53. {$endif}
  54. {$ifdef Splitheap}
  55. testsplit : boolean = false;
  56. {$endif Splitheap}
  57. delphimodeswitches : tmodeswitches=
  58. [m_delphi,m_tp,m_all,m_class,m_objpas,m_result,m_string_pchar,
  59. m_pointer_2_procedure,m_autoderef,m_tp_procvar,m_initfinal,m_default_ansistring,
  60. m_out,m_default_para];
  61. fpcmodeswitches : tmodeswitches=
  62. [m_fpc,m_all,m_string_pchar,m_nested_comment,m_repeat_forward,
  63. m_cvar_support,m_initfinal,m_add_pointer];
  64. objfpcmodeswitches : tmodeswitches=
  65. [m_objfpc,m_fpc,m_all,m_class,m_objpas,m_result,m_string_pchar,m_nested_comment,
  66. m_repeat_forward,m_cvar_support,m_initfinal,m_add_pointer,m_out,m_default_para];
  67. tpmodeswitches : tmodeswitches=
  68. [m_tp7,m_tp,m_all,m_tp_procvar];
  69. gpcmodeswitches : tmodeswitches=
  70. [m_gpc,m_all];
  71. type
  72. pfileposinfo = ^tfileposinfo;
  73. tfileposinfo = record
  74. line : longint;
  75. column : word;
  76. fileindex : word;
  77. end;
  78. TSearchPathList = class(TStringList)
  79. procedure AddPath(s:string;addfirst:boolean);
  80. procedure AddList(list:TSearchPathList;addfirst:boolean);
  81. function FindFile(const f : string;var foundfile:string):boolean;
  82. end;
  83. var
  84. { specified inputfile }
  85. inputdir : dirstr;
  86. inputfile : namestr;
  87. inputextension : extstr;
  88. { specified outputfile with -o parameter }
  89. outputfile : namestr;
  90. { specified with -FE or -FU }
  91. outputexedir : dirstr;
  92. outputunitdir : dirstr;
  93. { things specified with parameters }
  94. paralinkoptions,
  95. paradynamiclinker : string;
  96. parapreprocess : boolean;
  97. { directory where the utils can be found (options -FD) }
  98. utilsdirectory : dirstr;
  99. { some flags for global compiler switches }
  100. do_build,
  101. do_make : boolean;
  102. not_unit_proc : boolean;
  103. { path for searching units, different paths can be seperated by ; }
  104. exepath : dirstr; { Path to ppc }
  105. librarysearchpath,
  106. unitsearchpath,
  107. objectsearchpath,
  108. includesearchpath : TSearchPathList;
  109. { deffile }
  110. usewindowapi : boolean;
  111. description : string;
  112. dllversion : string;
  113. dllmajor,dllminor,dllrevision : word; { revision only for netware }
  114. akttokenpos, { position of the last token }
  115. aktfilepos : tfileposinfo; { current position }
  116. { type of currently parsed block }
  117. { isn't full implemented (FK) }
  118. block_type : tblock_type;
  119. in_args : boolean; { arguments must be checked especially }
  120. parsing_para_level : longint; { parameter level, used to convert
  121. proc calls to proc loads in firstcalln }
  122. { Must_be_valid : boolean; should the variable already have a value
  123. obsolete replace by set_varstate function }
  124. compile_level : word;
  125. make_ref : boolean;
  126. resolving_forward : boolean; { used to add forward reference as second ref }
  127. use_esp_stackframe : boolean; { to test for call with ESP as stack frame }
  128. inlining_procedure : boolean; { are we inlining a procedure }
  129. { commandline values }
  130. initdefines : tstringlist;
  131. initglobalswitches : tglobalswitches;
  132. initmoduleswitches : tmoduleswitches;
  133. initlocalswitches : tlocalswitches;
  134. initmodeswitches : tmodeswitches;
  135. {$IFDEF testvarsets}
  136. Initsetalloc, {0=fixed, 1 =var}
  137. {$ENDIF}
  138. initpackenum : longint;
  139. initpackrecords : tpackrecords;
  140. initoutputformat : tasm;
  141. initoptprocessor,
  142. initspecificoptprocessor : tprocessors;
  143. initasmmode : tasmmode;
  144. initinterfacetype : tinterfacetypes;
  145. { current state values }
  146. aktglobalswitches : tglobalswitches;
  147. aktmoduleswitches : tmoduleswitches;
  148. aktlocalswitches : tlocalswitches;
  149. nextaktlocalswitches : tlocalswitches;
  150. localswitcheschanged : boolean;
  151. aktmodeswitches : tmodeswitches;
  152. {$IFDEF testvarsets}
  153. aktsetalloc,
  154. {$ENDIF}
  155. aktpackenum : longint;
  156. aktmaxfpuregisters: longint;
  157. aktpackrecords : tpackrecords;
  158. aktoutputformat : tasm;
  159. aktoptprocessor,
  160. aktspecificoptprocessor : tprocessors;
  161. aktasmmode : tasmmode;
  162. aktinterfacetype : tinterfacetypes;
  163. { Memory sizes }
  164. heapsize,
  165. maxheapsize,
  166. stacksize : longint;
  167. {$Ifdef EXTDEBUG}
  168. total_of_firstpass,
  169. firstpass_several : longint;
  170. {$ifdef FPC}
  171. EntryMemUsed : longint;
  172. {$endif FPC}
  173. { parameter switches }
  174. debugstop,
  175. only_one_pass : boolean;
  176. {$EndIf EXTDEBUG}
  177. { windows / OS/2 application type }
  178. apptype : tapptype;
  179. const
  180. RelocSection : boolean = true;
  181. RelocSectionSetExplicitly : boolean = false;
  182. LinkTypeSetExplicitly : boolean = false;
  183. IsExe : boolean = false;
  184. DLLsource : boolean = false;
  185. DLLImageBase : pstring = nil;
  186. UseDeffileForExport : boolean = true;
  187. ForceDeffileForExport : boolean = false;
  188. { used to set all registers used for each global function
  189. this should dramatically decrease the number of
  190. recompilations needed PM }
  191. simplify_ppu : boolean = false;
  192. { should we allow non static members ? }
  193. allow_only_static : boolean = false;
  194. Inside_asm_statement : boolean = false;
  195. global_unit_count : word = 0;
  196. { for error info in pp.pas }
  197. parser_current_file : string = '';
  198. procedure abstract;
  199. function bstoslash(const s : string) : string;
  200. function getdatestr:string;
  201. function gettimestr:string;
  202. function filetimestring( t : longint) : string;
  203. procedure DefaultReplacements(var s:string);
  204. function GetCurrentDir:string;
  205. function path_absolute(const s : string) : boolean;
  206. Function PathExists ( F : String) : Boolean;
  207. Function FileExists ( Const F : String) : Boolean;
  208. Function RemoveFile(const f:string):boolean;
  209. Function RemoveDir(d:string):boolean;
  210. Function GetFileTime ( Var F : File) : Longint;
  211. Function GetNamedFileTime ( Const F : String) : Longint;
  212. Function SplitPath(const s:string):string;
  213. Function SplitFileName(const s:string):string;
  214. Function SplitName(const s:string):string;
  215. Function SplitExtension(Const HStr:String):String;
  216. Function AddExtension(Const HStr,ext:String):String;
  217. Function ForceExtension(Const HStr,ext:String):String;
  218. Function FixPath(s:string;allowdot:boolean):string;
  219. function FixFileName(const s:string):string;
  220. procedure SplitBinCmd(const s:string;var bstr,cstr:string);
  221. procedure SynchronizeFileTime(const fn1,fn2:string);
  222. function FindFile(const f : string;path : string;var foundfile:string):boolean;
  223. function FindExe(const bin:string;var foundfile:string):boolean;
  224. function GetShortName(const n:string):string;
  225. Procedure Shell(const command:string);
  226. function GetEnvPChar(const envname:string):pchar;
  227. procedure FreeEnvPChar(p:pchar);
  228. Function SetCompileMode(const s:string; changeInit: boolean):boolean;
  229. procedure InitGlobals;
  230. procedure DoneGlobals;
  231. function string2guid(const s: string; var GUID: TGUID): boolean;
  232. function guid2string(const GUID: TGUID): string;
  233. implementation
  234. uses
  235. comphook;
  236. procedure abstract;
  237. begin
  238. do_internalerror(255);
  239. end;
  240. function ngraphsearchvalue(const s1,s2 : string) : double;
  241. const
  242. n = 3;
  243. var
  244. equals,i,j : longint;
  245. hs : string;
  246. begin
  247. equals:=0;
  248. { is the string long enough ? }
  249. if min(length(s1),length(s2))-n+1<1 then
  250. begin
  251. ngraphsearchvalue:=0.0;
  252. exit;
  253. end;
  254. for i:=1 to length(s1)-n+1 do
  255. begin
  256. hs:=copy(s1,i,n);
  257. for j:=1 to length(s2)-n+1 do
  258. if hs=copy(s2,j,n) then
  259. inc(equals);
  260. end;
  261. {$ifdef fpc}
  262. ngraphsearchvalue:=equals/double(max(length(s1),length(s2))-n+1);
  263. {$else}
  264. ngraphsearchvalue:=equals/(max(length(s1),length(s2))-n+1);
  265. {$endif}
  266. end;
  267. function bstoslash(const s : string) : string;
  268. {
  269. return string s with all \ changed into /
  270. }
  271. var
  272. i : longint;
  273. begin
  274. for i:=1to length(s) do
  275. if s[i]='\' then
  276. bstoslash[i]:='/'
  277. else
  278. bstoslash[i]:=s[i];
  279. bstoslash[0]:=s[0];
  280. end;
  281. {****************************************************************************
  282. Time Handling
  283. ****************************************************************************}
  284. Function L0(l:longint):string;
  285. {
  286. return the string of value l, if l<10 then insert a zero, so
  287. the string is always at least 2 chars '01','02',etc
  288. }
  289. var
  290. s : string;
  291. begin
  292. Str(l,s);
  293. if l<10 then
  294. s:='0'+s;
  295. L0:=s;
  296. end;
  297. function gettimestr:string;
  298. {
  299. get the current time in a string HH:MM:SS
  300. }
  301. var
  302. hour,min,sec,hsec : word;
  303. begin
  304. {$ifdef delphi}
  305. dmisc.gettime(hour,min,sec,hsec);
  306. {$else delphi}
  307. dos.gettime(hour,min,sec,hsec);
  308. {$endif delphi}
  309. gettimestr:=L0(Hour)+':'+L0(min)+':'+L0(sec);
  310. end;
  311. function getdatestr:string;
  312. {
  313. get the current date in a string YY/MM/DD
  314. }
  315. var
  316. Year,Month,Day,Wday : Word;
  317. begin
  318. {$ifdef delphi}
  319. dmisc.getdate(year,month,day,wday);
  320. {$else}
  321. dos.getdate(year,month,day,wday);
  322. {$endif}
  323. getdatestr:=L0(Year)+'/'+L0(Month)+'/'+L0(Day);
  324. end;
  325. function filetimestring( t : longint) : string;
  326. {
  327. convert dos datetime t to a string YY/MM/DD HH:MM:SS
  328. }
  329. var
  330. {$ifndef unix}
  331. DT : DateTime;
  332. {$endif}
  333. Year,Month,Day,Hour,Min,Sec : Word;
  334. begin
  335. if t=-1 then
  336. begin
  337. FileTimeString:='Not Found';
  338. exit;
  339. end;
  340. {$ifndef unix}
  341. unpacktime(t,DT);
  342. Year:=dT.year;month:=dt.month;day:=dt.day;
  343. Hour:=dt.hour;min:=dt.min;sec:=dt.sec;
  344. {$else}
  345. EpochToLocal (t,year,month,day,hour,min,sec);
  346. {$endif}
  347. filetimestring:=L0(Year)+'/'+L0(Month)+'/'+L0(Day)+' '+L0(Hour)+':'+L0(min)+':'+L0(sec);
  348. end;
  349. {****************************************************************************
  350. Default Macro Handling
  351. ****************************************************************************}
  352. procedure DefaultReplacements(var s:string);
  353. begin
  354. { Replace some macro's }
  355. Replace(s,'$FPCVER',version_string);
  356. Replace(s,'$VERSION',version_string);
  357. Replace(s,'$FULLVERSION',full_version_string);
  358. Replace(s,'$FPCDATE',date_string);
  359. Replace(s,'$FPCTARGET',target_cpu_string);
  360. Replace(s,'$FPCCPU',target_cpu_string);
  361. Replace(s,'$TARGET',target_path);
  362. Replace(s,'$FPCOS',target_path);
  363. end;
  364. {****************************************************************************
  365. File Handling
  366. ****************************************************************************}
  367. function GetCurrentDir:string;
  368. var
  369. CurrentDir : string;
  370. begin
  371. GetDir(0,CurrentDir);
  372. GetCurrentDir:=FixPath(CurrentDir,false);
  373. end;
  374. function path_absolute(const s : string) : boolean;
  375. {
  376. is path s an absolute path?
  377. }
  378. begin
  379. path_absolute:=false;
  380. {$ifdef unix}
  381. if (length(s)>0) and (s[1]='/') then
  382. path_absolute:=true;
  383. {$else unix}
  384. {$ifdef amiga}
  385. if ((length(s)>0) and ((s[1]='\') or (s[1]='/'))) or (Pos(':',s) = length(s)) then
  386. path_absolute:=true;
  387. {$else}
  388. if ((length(s)>0) and ((s[1]='\') or (s[1]='/'))) or
  389. ((length(s)>2) and (s[2]=':') and ((s[3]='\') or (s[3]='/'))) then
  390. path_absolute:=true;
  391. {$endif amiga}
  392. {$endif unix}
  393. end;
  394. {$ifndef FPC}
  395. Procedure FindClose(var Info : SearchRec);
  396. Begin
  397. End;
  398. {$endif not FPC}
  399. Function FileExists ( Const F : String) : Boolean;
  400. {$ifndef delphi}
  401. Var
  402. Info : SearchRec;
  403. {$endif}
  404. begin
  405. {$ifdef delphi}
  406. FileExists:=sysutils.FileExists(f);
  407. {$else}
  408. findfirst(F,readonly+archive+hidden,info);
  409. FileExists:=(doserror=0);
  410. findclose(Info);
  411. {$endif delphi}
  412. end;
  413. Function PathExists ( F : String) : Boolean;
  414. Var
  415. Info : SearchRec;
  416. begin
  417. if F[Length(f)] in ['/','\'] then
  418. Delete(f,length(f),1);
  419. findfirst(F,readonly+archive+hidden+directory,info);
  420. PathExists:=(doserror=0) and ((info.attr and directory)=directory);
  421. findclose(Info);
  422. end;
  423. Function RemoveFile(const f:string):boolean;
  424. var
  425. g : file;
  426. begin
  427. assign(g,f);
  428. {$I-}
  429. erase(g);
  430. {$I+}
  431. RemoveFile:=(ioresult=0);
  432. end;
  433. Function RemoveDir(d:string):boolean;
  434. begin
  435. if d[length(d)]=DirSep then
  436. Delete(d,length(d),1);
  437. {$I-}
  438. rmdir(d);
  439. {$I+}
  440. RemoveDir:=(ioresult=0);
  441. end;
  442. Function SplitPath(const s:string):string;
  443. var
  444. i : longint;
  445. begin
  446. i:=Length(s);
  447. while (i>0) and not(s[i] in ['/','\']) do
  448. dec(i);
  449. SplitPath:=Copy(s,1,i);
  450. end;
  451. Function SplitFileName(const s:string):string;
  452. var
  453. p : dirstr;
  454. n : namestr;
  455. e : extstr;
  456. begin
  457. FSplit(s,p,n,e);
  458. SplitFileName:=n+e;
  459. end;
  460. Function SplitName(const s:string):string;
  461. var
  462. i,j : longint;
  463. begin
  464. i:=Length(s);
  465. j:=Length(s);
  466. while (i>0) and not(s[i] in ['/','\']) do
  467. dec(i);
  468. while (j>0) and (s[j]<>'.') do
  469. dec(j);
  470. if j<=i then
  471. j:=255;
  472. SplitName:=Copy(s,i+1,j-(i+1));
  473. end;
  474. Function SplitExtension(Const HStr:String):String;
  475. var
  476. j : longint;
  477. begin
  478. j:=length(Hstr);
  479. while (j>0) and (Hstr[j]<>'.') do
  480. begin
  481. if hstr[j]=DirSep then
  482. j:=0
  483. else
  484. dec(j);
  485. end;
  486. if j=0 then
  487. j:=254;
  488. SplitExtension:=Copy(Hstr,j,255);
  489. end;
  490. Function AddExtension(Const HStr,ext:String):String;
  491. begin
  492. if (Ext<>'') and (SplitExtension(HStr)='') then
  493. AddExtension:=Hstr+Ext
  494. else
  495. AddExtension:=Hstr;
  496. end;
  497. Function ForceExtension(Const HStr,ext:String):String;
  498. var
  499. j : longint;
  500. begin
  501. j:=length(Hstr);
  502. while (j>0) and (Hstr[j]<>'.') do
  503. dec(j);
  504. if j=0 then
  505. j:=255;
  506. ForceExtension:=Copy(Hstr,1,j-1)+Ext;
  507. end;
  508. Function FixPath(s:string;allowdot:boolean):string;
  509. var
  510. i : longint;
  511. begin
  512. { Fix separator }
  513. for i:=1 to length(s) do
  514. if s[i] in ['/','\'] then
  515. s[i]:=DirSep;
  516. { Fix ending / }
  517. if (length(s)>0) and (s[length(s)]<>DirSep) and
  518. (s[length(s)]<>':') then
  519. s:=s+DirSep;
  520. { Remove ./ }
  521. if (not allowdot) and (s='.'+DirSep) then
  522. s:='';
  523. { return }
  524. {$ifdef unix}
  525. FixPath:=s;
  526. {$else}
  527. FixPath:=Lower(s);
  528. {$endif}
  529. end;
  530. function FixFileName(const s:string):string;
  531. var
  532. i : longint;
  533. begin
  534. for i:=length(s) downto 1 do
  535. begin
  536. case s[i] of
  537. {$ifdef Unix}
  538. '/','\' :
  539. FixFileName[i]:='/';
  540. {$else Unix}
  541. '/' :
  542. FixFileName[i]:='\';
  543. 'A'..'Z' :
  544. FixFileName[i]:=char(byte(s[i])+32);
  545. {$endif Unix}
  546. else
  547. FixFileName[i]:=s[i];
  548. end;
  549. end;
  550. FixFileName[0]:=s[0];
  551. end;
  552. procedure SplitBinCmd(const s:string;var bstr,cstr:string);
  553. var
  554. i : longint;
  555. begin
  556. i:=pos(' ',s);
  557. if i>0 then
  558. begin
  559. bstr:=Copy(s,1,i-1);
  560. cstr:=Copy(s,i+1,length(s)-i);
  561. end
  562. else
  563. begin
  564. bstr:='';
  565. cstr:='';
  566. end;
  567. end;
  568. procedure TSearchPathList.AddPath(s:string;addfirst:boolean);
  569. var
  570. j : longint;
  571. hs,hsd,
  572. CurrentDir,
  573. CurrPath : string;
  574. dir : searchrec;
  575. hp : TStringListItem;
  576. procedure addcurrpath;
  577. begin
  578. if addfirst then
  579. begin
  580. Remove(currPath);
  581. Insert(currPath);
  582. end
  583. else
  584. begin
  585. { Check if already in path, then we don't add it }
  586. hp:=Find(currPath);
  587. if not assigned(hp) then
  588. Concat(currPath);
  589. end;
  590. end;
  591. begin
  592. if s='' then
  593. exit;
  594. { Support default macro's }
  595. DefaultReplacements(s);
  596. { get current dir }
  597. CurrentDir:=GetCurrentDir;
  598. repeat
  599. { get currpath }
  600. if addfirst then
  601. begin
  602. j:=length(s);
  603. while (j>0) and (s[j]<>';') do
  604. dec(j);
  605. CurrPath:=FixPath(Copy(s,j+1,length(s)-j),false);
  606. if j=0 then
  607. s:=''
  608. else
  609. System.Delete(s,j,length(s)-j+1);
  610. end
  611. else
  612. begin
  613. j:=Pos(';',s);
  614. if j=0 then
  615. j:=255;
  616. CurrPath:=FixPath(Copy(s,1,j-1),false);
  617. System.Delete(s,1,j);
  618. end;
  619. { fix pathname }
  620. if CurrPath='' then
  621. CurrPath:='.'+DirSep
  622. else
  623. begin
  624. CurrPath:=FixPath(FExpand(CurrPath),false);
  625. if (CurrentDir<>'') and (Copy(CurrPath,1,length(CurrentDir))=CurrentDir) then
  626. CurrPath:='.'+DirSep+Copy(CurrPath,length(CurrentDir)+1,255);
  627. end;
  628. { wildcard adding ? }
  629. if pos('*',currpath)>0 then
  630. begin
  631. if currpath[length(currpath)]=dirsep then
  632. hs:=Copy(currpath,1,length(CurrPath)-1)
  633. else
  634. hs:=currpath;
  635. hsd:=SplitPath(hs);
  636. findfirst(hs,directory,dir);
  637. while doserror=0 do
  638. begin
  639. if (dir.name<>'.') and
  640. (dir.name<>'..') and
  641. ((dir.attr and directory)<>0) then
  642. begin
  643. currpath:=hsd+dir.name+dirsep;
  644. hp:=Find(currPath);
  645. if not assigned(hp) then
  646. AddCurrPath;
  647. end;
  648. findnext(dir);
  649. end;
  650. FindClose(dir);
  651. end
  652. else
  653. begin
  654. if PathExists(currpath) then
  655. addcurrpath;
  656. end;
  657. until (s='');
  658. end;
  659. procedure TSearchPathList.AddList(list:TSearchPathList;addfirst:boolean);
  660. var
  661. s : string;
  662. hl : TSearchPathList;
  663. hp,hp2 : TStringListItem;
  664. begin
  665. if list.empty then
  666. exit;
  667. { create temp and reverse the list }
  668. if addfirst then
  669. begin
  670. hl:=TSearchPathList.Create;
  671. hp:=TStringListItem(list.first);
  672. while assigned(hp) do
  673. begin
  674. hl.insert(hp.Str);
  675. hp:=TStringListItem(hp.next);
  676. end;
  677. while not hl.empty do
  678. begin
  679. s:=hl.GetFirst;
  680. Remove(s);
  681. Insert(s);
  682. end;
  683. hl.Free;
  684. end
  685. else
  686. begin
  687. hp:=TStringListItem(list.first);
  688. while assigned(hp) do
  689. begin
  690. hp2:=Find(hp.Str);
  691. { Check if already in path, then we don't add it }
  692. if not assigned(hp2) then
  693. Concat(hp.Str);
  694. hp:=TStringListItem(hp.next);
  695. end;
  696. end;
  697. end;
  698. function TSearchPathList.FindFile(const f : string;var foundfile:string):boolean;
  699. Var
  700. p : TStringListItem;
  701. begin
  702. FindFile:=false;
  703. p:=TStringListItem(first);
  704. while assigned(p) do
  705. begin
  706. {
  707. Search order for case sensitive systems:
  708. 1. lowercase
  709. 2. NormalCase
  710. 3. UPPERCASE
  711. None case sensitive only lowercase
  712. }
  713. FoundFile:=p.Str+Lower(f);
  714. If FileExists(FoundFile) then
  715. begin
  716. FindFile:=true;
  717. exit;
  718. end;
  719. {$ifdef UNIX}
  720. FoundFile:=p.Str+f;
  721. If FileExists(FoundFile) then
  722. begin
  723. FindFile:=true;
  724. exit;
  725. end;
  726. FoundFile:=p.Str+Upper(f);
  727. If FileExists(FoundFile) then
  728. begin
  729. FindFile:=true;
  730. exit;
  731. end;
  732. {$endif UNIX}
  733. p:=TStringListItem(p.next);
  734. end;
  735. { Return original filename if not found }
  736. FoundFile:=f;
  737. end;
  738. Function GetFileTime ( Var F : File) : Longint;
  739. Var
  740. {$ifdef unix}
  741. Info : Stat;
  742. {$endif}
  743. L : longint;
  744. begin
  745. {$ifdef unix}
  746. FStat (F,Info);
  747. L:=Info.Mtime;
  748. {$else}
  749. GetFTime(f,l);
  750. {$endif}
  751. GetFileTime:=L;
  752. end;
  753. Function GetNamedFileTime (Const F : String) : Longint;
  754. begin
  755. GetNamedFileTime:=do_getnamedfiletime(F);
  756. end;
  757. {Touch Assembler and object time to ppu time is there is a ppufilename}
  758. procedure SynchronizeFileTime(const fn1,fn2:string);
  759. var
  760. f : file;
  761. l : longint;
  762. begin
  763. Assign(f,fn1);
  764. {$I-}
  765. reset(f,1);
  766. {$I+}
  767. if ioresult=0 then
  768. begin
  769. getftime(f,l);
  770. { just to be sure in case there are rounding errors }
  771. setftime(f,l);
  772. close(f);
  773. assign(f,fn2);
  774. {$I-}
  775. reset(f,1);
  776. {$I+}
  777. if ioresult=0 then
  778. begin
  779. setftime(f,l);
  780. close(f);
  781. end;
  782. end;
  783. end;
  784. function FindFile(const f : string;path : string;var foundfile:string):boolean;
  785. Var
  786. singlepathstring : string;
  787. i : longint;
  788. begin
  789. {$ifdef Unix}
  790. for i:=1 to length(path) do
  791. if path[i]=':' then
  792. path[i]:=';';
  793. {$endif Unix}
  794. FindFile:=false;
  795. repeat
  796. i:=pos(';',path);
  797. if i=0 then
  798. i:=256;
  799. singlepathstring:=FixPath(copy(path,1,i-1),false);
  800. delete(path,1,i);
  801. {
  802. Search order for case sensitive systems:
  803. 1. lowercase
  804. 2. NormalCase
  805. 3. UPPERCASE
  806. None case sensitive only lowercase
  807. }
  808. FoundFile:=singlepathstring+Lower(f);
  809. If FileExists(FoundFile) then
  810. begin
  811. FindFile:=true;
  812. exit;
  813. end;
  814. {$ifdef UNIX}
  815. FoundFile:=singlepathstring+f;
  816. If FileExists(FoundFile) then
  817. begin
  818. FindFile:=true;
  819. exit;
  820. end;
  821. FoundFile:=singlepathstring+Upper(f);
  822. If FileExists(FoundFile) then
  823. begin
  824. FindFile:=true;
  825. exit;
  826. end;
  827. {$endif UNIX}
  828. until path='';
  829. FoundFile:=f;
  830. end;
  831. function FindExe(const bin:string;var foundfile:string):boolean;
  832. begin
  833. {$ifdef delphi}
  834. FindExe:=FindFile(FixFileName(AddExtension(bin,source_os.exeext)),'.;'+exepath+';'+dmisc.getenv('PATH'),foundfile);
  835. {$else delphi}
  836. FindExe:=FindFile(FixFileName(AddExtension(bin,source_os.exeext)),'.;'+exepath+';'+dos.getenv('PATH'),foundfile);
  837. {$endif delphi}
  838. end;
  839. function GetShortName(const n:string):string;
  840. {$ifdef win32}
  841. var
  842. hs,hs2 : string;
  843. i : longint;
  844. {$endif}
  845. {$ifdef go32v2}
  846. var
  847. hs : string;
  848. {$endif}
  849. begin
  850. GetShortName:=n;
  851. {$ifdef win32}
  852. hs:=n+#0;
  853. i:=Windows.GetShortPathName(@hs[1],@hs2[1],high(hs2));
  854. if (i>0) and (i<=high(hs2)) then
  855. begin
  856. hs2[0]:=chr(strlen(@hs2[1]));
  857. GetShortName:=hs2;
  858. end;
  859. {$endif}
  860. {$ifdef go32v2}
  861. hs:=n;
  862. if Dos.GetShortName(hs) then
  863. GetShortName:=hs;
  864. {$endif}
  865. end;
  866. {****************************************************************************
  867. OS Dependent things
  868. ****************************************************************************}
  869. function GetEnvPChar(const envname:string):pchar;
  870. {$ifdef win32}
  871. var
  872. s : string;
  873. i,len : longint;
  874. hp,p,p2 : pchar;
  875. {$endif}
  876. {$ifdef os2}
  877. var
  878. P1, P2: PChar;
  879. {$endif}
  880. begin
  881. {$ifdef unix}
  882. GetEnvPchar:={$ifdef ver1_0}Linux{$else}Unix{$endif}.Getenv(envname);
  883. {$define GETENVOK}
  884. {$endif}
  885. {$ifdef win32}
  886. GetEnvPchar:=nil;
  887. p:=GetEnvironmentStrings;
  888. hp:=p;
  889. while hp^<>#0 do
  890. begin
  891. s:=strpas(hp);
  892. i:=pos('=',s);
  893. len:=strlen(hp);
  894. if upper(copy(s,1,i-1))=upper(envname) then
  895. begin
  896. GetMem(p2,len-length(envname));
  897. Move(hp[i],p2^,len-length(envname));
  898. GetEnvPchar:=p2;
  899. break;
  900. end;
  901. { next string entry}
  902. hp:=hp+len+1;
  903. end;
  904. FreeEnvironmentStrings(p);
  905. {$define GETENVOK}
  906. {$endif}
  907. {$ifdef os2}
  908. P1 := StrPNew (EnvName);
  909. if Assigned (P1) then
  910. begin
  911. if DosCalls.DosScanEnv (P1, P2) = 0 then
  912. GetEnvPChar := P2
  913. else
  914. GetEnvPChar := nil;
  915. StrDispose (P1);
  916. end else GetEnvPChar := nil;
  917. {$define GETENVOK}
  918. {$endif}
  919. {$ifdef GETENVOK}
  920. {$undef GETENVOK}
  921. {$else}
  922. GetEnvPchar:=StrPNew(Dos.Getenv(envname));
  923. {$endif}
  924. end;
  925. procedure FreeEnvPChar(p:pchar);
  926. begin
  927. {$ifndef unix}
  928. {$ifndef os2}
  929. StrDispose(p);
  930. {$endif}
  931. {$endif}
  932. end;
  933. Procedure Shell(const command:string);
  934. { This is already defined in the linux.ppu for linux, need for the *
  935. expansion under linux }
  936. {$ifdef unix}
  937. begin
  938. {$ifdef ver1_0}Linux{$else}Unix{$endif}.Shell(command);
  939. end;
  940. {$else}
  941. var
  942. comspec : string;
  943. begin
  944. comspec:=getenv('COMSPEC');
  945. Exec(comspec,' /C '+command);
  946. end;
  947. {$endif}
  948. Function SetCompileMode(const s:string; changeInit: boolean):boolean;
  949. var
  950. b : boolean;
  951. begin
  952. b:=true;
  953. if s='DEFAULT' then
  954. aktmodeswitches:=initmodeswitches
  955. else
  956. if s='DELPHI' then
  957. aktmodeswitches:=delphimodeswitches
  958. else
  959. if s='TP' then
  960. aktmodeswitches:=tpmodeswitches
  961. else
  962. if s='FPC' then
  963. aktmodeswitches:=fpcmodeswitches
  964. else
  965. if s='OBJFPC' then
  966. aktmodeswitches:=objfpcmodeswitches
  967. else
  968. if s='GPC' then
  969. aktmodeswitches:=gpcmodeswitches
  970. else
  971. b:=false;
  972. if b and changeInit then
  973. initmodeswitches := aktmodeswitches;
  974. if b then
  975. begin
  976. { turn ansistrings on by default ? }
  977. if (m_delphi in aktmodeswitches) then
  978. begin
  979. include(aktlocalswitches,cs_ansistrings);
  980. if changeinit then
  981. include(initlocalswitches,cs_ansistrings);
  982. end
  983. else
  984. begin
  985. exclude(aktlocalswitches,cs_ansistrings);
  986. if changeinit then
  987. exclude(initlocalswitches,cs_ansistrings);
  988. end;
  989. { enum packing }
  990. if (m_tp7 in aktmodeswitches) then
  991. aktpackenum:=1
  992. else
  993. aktpackenum:=4;
  994. if changeinit then
  995. initpackenum:=aktpackenum;
  996. end;
  997. SetCompileMode:=b;
  998. end;
  999. { '('D1:'00000000-'D2:'0000-'D3:'0000-'D4:'0000-000000000000)' }
  1000. function string2guid(const s: string; var GUID: TGUID): boolean;
  1001. function ishexstr(const hs: string): boolean;
  1002. var
  1003. i: integer;
  1004. begin
  1005. ishexstr:=false;
  1006. for i:=1 to Length(hs) do begin
  1007. if not (hs[i] in ['0'..'9','A'..'F','a'..'f']) then
  1008. exit;
  1009. end;
  1010. ishexstr:=true;
  1011. end;
  1012. function hexstr2longint(const hexs: string): longint;
  1013. var
  1014. i: integer;
  1015. rl: longint;
  1016. begin
  1017. rl:=0;
  1018. for i:=1 to length(hexs) do begin
  1019. rl:=rl shl 4;
  1020. case hexs[i] of
  1021. '0'..'9' : inc(rl,ord(hexs[i])-ord('0'));
  1022. 'A'..'F' : inc(rl,ord(hexs[i])-ord('A')+10);
  1023. 'a'..'f' : inc(rl,ord(hexs[i])-ord('a')+10);
  1024. end
  1025. end;
  1026. hexstr2longint:=rl;
  1027. end;
  1028. var
  1029. i: integer;
  1030. begin
  1031. if (Length(s)=38) and (s[1]='{') and (s[38]='}') and
  1032. (s[10]='-') and (s[15]='-') and (s[20]='-') and (s[25]='-') and
  1033. ishexstr(copy(s,2,8)) and ishexstr(copy(s,11,4)) and
  1034. ishexstr(copy(s,16,4)) and ishexstr(copy(s,21,4)) and
  1035. ishexstr(copy(s,26,12)) then begin
  1036. GUID.D1:=hexstr2longint(copy(s,2,8));
  1037. GUID.D2:=hexstr2longint(copy(s,11,4));
  1038. GUID.D3:=hexstr2longint(copy(s,16,4));
  1039. for i:=0 to 1 do
  1040. GUID.D4[i]:=hexstr2longint(copy(s,21+i*2,2));
  1041. for i:=2 to 7 do
  1042. GUID.D4[i]:=hexstr2longint(copy(s,22+i*2,2));
  1043. string2guid:=true;
  1044. end
  1045. else
  1046. string2guid:=false;
  1047. end;
  1048. function guid2string(const GUID: TGUID): string;
  1049. function long2hex(l, len: longint): string;
  1050. const
  1051. hextbl: array[0..15] of char = '0123456789ABCDEF';
  1052. var
  1053. rs: string;
  1054. i: integer;
  1055. begin
  1056. rs[0]:=chr(len);
  1057. for i:=len downto 1 do begin
  1058. rs[i]:=hextbl[l and $F];
  1059. l:=l shr 4;
  1060. end;
  1061. long2hex:=rs;
  1062. end;
  1063. begin
  1064. guid2string:=
  1065. '{'+long2hex(GUID.D1,8)+
  1066. '-'+long2hex(GUID.D2,4)+
  1067. '-'+long2hex(GUID.D3,4)+
  1068. '-'+long2hex(GUID.D4[0],2)+long2hex(GUID.D4[1],2)+
  1069. '-'+long2hex(GUID.D4[2],2)+long2hex(GUID.D4[3],2)+
  1070. long2hex(GUID.D4[4],2)+long2hex(GUID.D4[5],2)+
  1071. long2hex(GUID.D4[6],2)+long2hex(GUID.D4[7],2)+
  1072. '}';
  1073. end;
  1074. {****************************************************************************
  1075. Init
  1076. ****************************************************************************}
  1077. {$ifdef unix}
  1078. {$define need_path_search}
  1079. {$endif unix}
  1080. {$ifdef os2}
  1081. {$define need_path_search}
  1082. {$endif os2}
  1083. procedure get_exepath;
  1084. var
  1085. hs1 : namestr;
  1086. hs2 : extstr;
  1087. begin
  1088. {$ifdef delphi}
  1089. exepath:=dmisc.getenv('PPC_EXEC_PATH');
  1090. {$else delphi}
  1091. exepath:=dos.getenv('PPC_EXEC_PATH');
  1092. {$endif delphi}
  1093. if exepath='' then
  1094. fsplit(FixFileName(system.paramstr(0)),exepath,hs1,hs2);
  1095. {$ifdef need_path_search}
  1096. if exepath='' then
  1097. begin
  1098. if pos(source_os.exeext,hs1) <>
  1099. (length(hs1) - length(source_os.exeext)+1) then
  1100. hs1 := hs1 + source_os.exeext;
  1101. {$ifdef delphi}
  1102. findfile(hs1,dmisc.getenv('PATH'),exepath);
  1103. {$else delphi}
  1104. findfile(hs1,dos.getenv('PATH'),exepath);
  1105. {$endif delphi}
  1106. exepath:=SplitPath(exepath);
  1107. end;
  1108. {$endif need_path_search}
  1109. exepath:=FixPath(exepath,false);
  1110. end;
  1111. procedure DoneGlobals;
  1112. begin
  1113. initdefines.free;
  1114. if assigned(DLLImageBase) then
  1115. StringDispose(DLLImageBase);
  1116. RelocSection:=true;
  1117. RelocSectionSetExplicitly:=false;
  1118. UseDeffileForExport:=true;
  1119. librarysearchpath.Free;
  1120. unitsearchpath.Free;
  1121. objectsearchpath.Free;
  1122. includesearchpath.Free;
  1123. end;
  1124. procedure InitGlobals;
  1125. begin
  1126. { set global switches }
  1127. do_build:=false;
  1128. do_make:=true;
  1129. compile_level:=0;
  1130. { these two should not be cleared in
  1131. DoneGlobals as the IDE might need their value }
  1132. IsExe:=false;
  1133. DLLsource:=false;
  1134. { Output }
  1135. OutputFile:='';
  1136. OutputExeDir:='';
  1137. OutputUnitDir:='';
  1138. { Utils directory }
  1139. utilsdirectory:='';
  1140. { Search Paths }
  1141. librarysearchpath:=TSearchPathList.Create;
  1142. unitsearchpath:=TSearchPathList.Create;
  1143. includesearchpath:=TSearchPathList.Create;
  1144. objectsearchpath:=TSearchPathList.Create;
  1145. { Def file }
  1146. usewindowapi:=false;
  1147. description:='Compiled by FPC '+version_string+' - '+target_cpu_string;
  1148. dllversion:='';
  1149. { Init values }
  1150. initmodeswitches:=fpcmodeswitches;
  1151. initlocalswitches:=[cs_check_io];
  1152. initmoduleswitches:=[cs_extsyntax,cs_browser];
  1153. initglobalswitches:=[cs_check_unit_name,cs_link_static];
  1154. {$ifdef i386}
  1155. initoptprocessor:=Class386;
  1156. initspecificoptprocessor:=Class386;
  1157. initpackenum:=4;
  1158. {$IFDEF testvarsets}
  1159. initsetalloc:=0;
  1160. {$ENDIF}
  1161. initpackrecords:=packrecord_2;
  1162. initoutputformat:=target_asm.id;
  1163. initasmmode:=asmmode_i386_att;
  1164. {$else not i386}
  1165. {$ifdef m68k}
  1166. initoptprocessor:=MC68000;
  1167. include(initmoduleswitches,cs_fp_emulation);
  1168. initpackenum:=4;
  1169. {$IFDEF testvarsets}
  1170. initsetalloc:=0;
  1171. {$ENDIF}
  1172. initpackrecords:=packrecord_2;
  1173. initoutputformat:=as_m68k_as;
  1174. initasmmode:=asmmode_m68k_mot;
  1175. {$endif m68k}
  1176. {$endif i386}
  1177. initinterfacetype:=it_interfacecom;
  1178. initdefines:=TStringList.Create;
  1179. { memory sizes, will be overriden by parameter or default for target
  1180. in options or init_parser }
  1181. stacksize:=0;
  1182. heapsize:=0;
  1183. maxheapsize:=0;
  1184. { compile state }
  1185. in_args:=false;
  1186. { must_be_valid:=true; obsolete PM }
  1187. not_unit_proc:=true;
  1188. apptype:=app_cui;
  1189. end;
  1190. begin
  1191. get_exepath;
  1192. {$ifdef EXTDEBUG}
  1193. {$ifdef FPC}
  1194. EntryMemUsed:=system.HeapSize-MemAvail;
  1195. {$endif FPC}
  1196. {$endif}
  1197. end.
  1198. {
  1199. $Log$
  1200. Revision 1.28 2001-02-20 21:41:16 peter
  1201. * new fixfilename, findfile for unix. Look first for lowercase, then
  1202. NormalCase and last for UPPERCASE names.
  1203. Revision 1.27 2001/02/09 23:05:45 peter
  1204. * default packenum=1 for tp7 mode
  1205. Revision 1.26 2001/02/05 20:47:00 peter
  1206. * support linux unit for ver1_0 compilers
  1207. Revision 1.25 2001/01/21 20:32:45 marco
  1208. * Renamefest. Compiler part. Not that hard.
  1209. Revision 1.24 2001/01/20 18:32:52 hajny
  1210. + APPTYPE support under OS/2, app_fs, GetEnvPChar for OS/2
  1211. Revision 1.23 2001/01/13 00:03:41 peter
  1212. * fixed findexe to also support already extension in name
  1213. Revision 1.22 2000/12/26 15:57:25 peter
  1214. * use system.paramstr()
  1215. Revision 1.21 2000/12/25 00:07:26 peter
  1216. + new tlinkedlist class (merge of old tstringqueue,tcontainer and
  1217. tlinkedlist objects)
  1218. Revision 1.20 2000/11/13 15:26:12 marco
  1219. * Renamefest
  1220. Revision 1.19 2000/11/12 22:20:37 peter
  1221. * create generic toutputsection for binary writers
  1222. Revision 1.18 2000/11/04 14:25:19 florian
  1223. + merged Attila's changes for interfaces, not tested yet
  1224. Revision 1.17 2000/10/31 22:02:46 peter
  1225. * symtable splitted, no real code changes
  1226. Revision 1.16 2000/10/04 14:51:08 pierre
  1227. * IsExe restored
  1228. Revision 1.15 2000/09/27 21:20:56 peter
  1229. * also set initlocalswitches in setcompilemode (merged)
  1230. Revision 1.14 2000/09/26 10:50:41 jonas
  1231. * initmodeswitches is changed is you change the compiler mode from the
  1232. command line (the -S<x> switches didn't work anymore for changing the
  1233. compiler mode) (merged from fixes branch)
  1234. Revision 1.13 2000/09/24 21:33:46 peter
  1235. * message updates merges
  1236. Revision 1.12 2000/09/24 21:19:50 peter
  1237. * delphi compile fixes
  1238. Revision 1.11 2000/09/24 15:12:40 peter
  1239. * fixed typo
  1240. Revision 1.10 2000/09/24 15:06:16 peter
  1241. * use defines.inc
  1242. Revision 1.9 2000/09/24 10:33:07 peter
  1243. * searching of exe in path also for OS/2
  1244. * fixed searching of exe in path.
  1245. Revision 1.8 2000/09/11 17:00:22 florian
  1246. + first implementation of Netware Module support, thanks to
  1247. Armin Diehl ([email protected]) for providing the patches
  1248. Revision 1.7 2000/08/27 16:11:51 peter
  1249. * moved some util functions from globals,cobjects to cutils
  1250. * splitted files into finput,fmodule
  1251. Revision 1.6 2000/08/12 19:14:58 peter
  1252. * ELF writer works now also with -g
  1253. * ELF writer is default again for linux
  1254. Revision 1.5 2000/08/12 15:30:44 peter
  1255. * IDE patch for stream reading (merged)
  1256. Revision 1.4 2000/08/02 19:49:59 peter
  1257. * first things for default parameters
  1258. Revision 1.3 2000/07/13 12:08:25 michael
  1259. + patched to 1.1.0 with former 1.09patch from peter
  1260. Revision 1.2 2000/07/13 11:32:41 michael
  1261. + removed logs
  1262. }