verbose.pas 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873
  1. {
  2. Copyright (c) 1998-2002 by Peter Vreman
  3. This unit handles the verbose management
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. unit verbose;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. {$IFNDEF MACOS_USE_FAKE_SYSUTILS}
  22. sysutils,
  23. {$ENDIF}
  24. cutils,
  25. globals,finput,
  26. cmsgs;
  27. {$ifndef EXTERN_MSG}
  28. {$i msgtxt.inc}
  29. {$endif}
  30. {$i msgidx.inc}
  31. Const
  32. { Levels }
  33. V_None = $0;
  34. V_Fatal = $1;
  35. V_Error = $2;
  36. V_Normal = $4; { doesn't show a text like Error: }
  37. V_Warning = $8;
  38. V_Note = $10;
  39. V_Hint = $20;
  40. V_LineInfoMask = $fff;
  41. { From here by default no line info }
  42. V_Info = $1000;
  43. V_Status = $2000;
  44. V_Used = $4000;
  45. V_Tried = $8000;
  46. V_Conditional = $10000;
  47. V_Debug = $20000;
  48. V_Executable = $40000;
  49. V_LevelMask = $fffffff;
  50. V_All = V_LevelMask;
  51. V_Default = V_Fatal + V_Error + V_Normal;
  52. { Flags }
  53. V_LineInfo = $10000000;
  54. var
  55. msg : pmessage;
  56. const
  57. msgfilename : string = '';
  58. procedure SetRedirectFile(const fn:string);
  59. function SetVerbosity(const s:string):boolean;
  60. procedure PrepareReport;
  61. function CheckVerbosity(v:longint):boolean;
  62. procedure SetCompileModule(p:tmodulebase);
  63. procedure ShowStatus;
  64. function ErrorCount:longint;
  65. procedure SetErrorFlags(const s:string);
  66. procedure GenerateError;
  67. procedure Internalerror(i:longint);
  68. procedure Comment(l:longint;s:string);
  69. function MessagePchar(w:longint):pchar;
  70. procedure Message(w:longint);
  71. procedure Message1(w:longint;const s1:string);
  72. procedure Message2(w:longint;const s1,s2:string);
  73. procedure Message3(w:longint;const s1,s2,s3:string);
  74. procedure Message4(w:longint;const s1,s2,s3,s4:string);
  75. procedure MessagePos(const pos:tfileposinfo;w:longint);
  76. procedure MessagePos1(const pos:tfileposinfo;w:longint;const s1:string);
  77. procedure MessagePos2(const pos:tfileposinfo;w:longint;const s1,s2:string);
  78. procedure MessagePos3(const pos:tfileposinfo;w:longint;const s1,s2,s3:string);
  79. procedure MessagePos4(const pos:tfileposinfo;w:longint;const s1,s2,s3,s4:string);
  80. { message calls with codegenerror support }
  81. procedure cgmessage(t : longint);
  82. procedure cgmessage1(t : longint;const s : string);
  83. procedure cgmessage2(t : longint;const s1,s2 : string);
  84. procedure cgmessage3(t : longint;const s1,s2,s3 : string);
  85. procedure CGMessagePos(const pos:tfileposinfo;t:longint);
  86. procedure CGMessagePos1(const pos:tfileposinfo;t:longint;const s1:string);
  87. procedure CGMessagePos2(const pos:tfileposinfo;t:longint;const s1,s2:string);
  88. procedure CGMessagePos3(const pos:tfileposinfo;t:longint;const s1,s2,s3:string);
  89. procedure InitVerbose;
  90. procedure DoneVerbose;
  91. implementation
  92. uses
  93. comphook;
  94. var
  95. compiling_module : tmodulebase;
  96. {****************************************************************************
  97. Extra Handlers for default compiler
  98. ****************************************************************************}
  99. procedure DoneRedirectFile;
  100. begin
  101. if status.use_redir then
  102. begin
  103. close(status.redirfile);
  104. status.use_redir:=false;
  105. end;
  106. if status.use_bugreport then
  107. begin
  108. close(status.reportbugfile);
  109. status.use_bugreport:=false;
  110. end;
  111. end;
  112. procedure SetRedirectFile(const fn:string);
  113. begin
  114. assign(status.redirfile,fn);
  115. {$I-}
  116. append(status.redirfile);
  117. if ioresult <> 0 then
  118. rewrite(status.redirfile);
  119. {$I+}
  120. status.use_redir:=(ioresult=0);
  121. end;
  122. procedure PrepareReport;
  123. var
  124. fn : string;
  125. begin
  126. if status.use_bugreport then
  127. exit;
  128. fn:='fpcdebug.txt';
  129. assign(status.reportbugfile,fn);
  130. {$I-}
  131. append(status.reportbugfile);
  132. if ioresult <> 0 then
  133. rewrite(status.reportbugfile);
  134. {$I+}
  135. status.use_bugreport:=(ioresult=0);
  136. if status.use_bugreport then
  137. writeln(status.reportbugfile,'FPC bug report file');
  138. end;
  139. function CheckVerbosity(v:longint):boolean;
  140. begin
  141. CheckVerbosity:=status.use_bugreport or
  142. ((status.verbosity and (v and V_LevelMask))=(v and V_LevelMask));
  143. end;
  144. function SetVerbosity(const s:string):boolean;
  145. var
  146. m : Longint;
  147. i : Integer;
  148. inverse : boolean;
  149. c : char;
  150. begin
  151. Setverbosity:=false;
  152. val(s,m,i);
  153. if (i=0) and (s<>'') then
  154. status.verbosity:=m
  155. else
  156. begin
  157. i:=1;
  158. while i<=length(s) do
  159. begin
  160. c:=upcase(s[i]);
  161. inverse:=false;
  162. { on/off ? }
  163. if (i<length(s)) then
  164. case s[i+1] of
  165. '-' : begin
  166. inc(i);
  167. inverse:=true;
  168. end;
  169. '+' : inc(i);
  170. end;
  171. { handle switch }
  172. case c of
  173. { Special cases }
  174. 'A' : status.verbosity:=V_All;
  175. '0' : status.verbosity:=V_Default;
  176. 'P' : begin
  177. if inverse then
  178. paraprintnodetree:=0
  179. else
  180. paraprintnodetree:=1;
  181. end;
  182. 'R' : begin
  183. if inverse then
  184. begin
  185. status.use_gccoutput:=false;
  186. status.use_stderr:=false;
  187. end
  188. else
  189. begin
  190. status.use_gccoutput:=true;
  191. status.use_stderr:=true;
  192. end;
  193. end;
  194. 'Z' : begin
  195. if inverse then
  196. status.use_stderr:=false
  197. else
  198. status.use_stderr:=true;
  199. end;
  200. { Normal cases - do an or }
  201. 'E' : if inverse then
  202. status.verbosity:=status.verbosity and (not V_Error)
  203. else
  204. status.verbosity:=status.verbosity or V_Error;
  205. 'I' : if inverse then
  206. status.verbosity:=status.verbosity and (not V_Info)
  207. else
  208. status.verbosity:=status.verbosity or V_Info;
  209. 'W' : if inverse then
  210. status.verbosity:=status.verbosity and (not V_Warning)
  211. else
  212. status.verbosity:=status.verbosity or V_Warning;
  213. 'N' : if inverse then
  214. status.verbosity:=status.verbosity and (not V_Note)
  215. else
  216. status.verbosity:=status.verbosity or V_Note;
  217. 'H' : if inverse then
  218. status.verbosity:=status.verbosity and (not V_Hint)
  219. else
  220. status.verbosity:=status.verbosity or V_Hint;
  221. 'L' : if inverse then
  222. status.verbosity:=status.verbosity and (not V_Status)
  223. else
  224. status.verbosity:=status.verbosity or V_Status;
  225. 'U' : if inverse then
  226. status.verbosity:=status.verbosity and (not V_Used)
  227. else
  228. status.verbosity:=status.verbosity or V_Used;
  229. 'T' : if inverse then
  230. status.verbosity:=status.verbosity and (not V_Tried)
  231. else
  232. status.verbosity:=status.verbosity or V_Tried;
  233. 'C' : if inverse then
  234. status.verbosity:=status.verbosity and (not V_Conditional)
  235. else
  236. status.verbosity:=status.verbosity or V_Conditional;
  237. 'D' : if inverse then
  238. status.verbosity:=status.verbosity and (not V_Debug)
  239. else
  240. status.verbosity:=status.verbosity or V_Debug;
  241. 'X' : if inverse then
  242. status.verbosity:=status.verbosity and (not V_Executable)
  243. else
  244. status.verbosity:=status.verbosity or V_Executable;
  245. 'V' : PrepareReport;
  246. end;
  247. inc(i);
  248. end;
  249. end;
  250. if status.verbosity=0 then
  251. status.verbosity:=V_Default;
  252. setverbosity:=true;
  253. end;
  254. procedure Loadprefixes;
  255. function loadprefix(w:longint):string;
  256. var
  257. s : string;
  258. idx : longint;
  259. begin
  260. s:=msg^.get(w,[]);
  261. idx:=pos('_',s);
  262. if idx>0 then
  263. Loadprefix:=Copy(s,idx+1,255)
  264. else
  265. Loadprefix:=s;
  266. end;
  267. begin
  268. { Load the prefixes }
  269. fatalstr:=Loadprefix(general_i_fatal);
  270. errorstr:=Loadprefix(general_i_error);
  271. warningstr:=Loadprefix(general_i_warning);
  272. notestr:=Loadprefix(general_i_note);
  273. hintstr:=Loadprefix(general_i_hint);
  274. end;
  275. procedure LoadMsgFile(const fn:string);
  276. begin
  277. { reload the internal messages if not already loaded }
  278. {$ifndef EXTERN_MSG}
  279. if not msg^.msgintern then
  280. msg^.LoadIntern(@msgtxt,msgtxtsize);
  281. {$endif}
  282. if not msg^.LoadExtern(fn) then
  283. begin
  284. {$ifdef EXTERN_MSG}
  285. writeln('Fatal: Cannot find error message file.');
  286. halt(3);
  287. {$else}
  288. msg^.LoadIntern(@msgtxt,msgtxtsize);
  289. {$endif}
  290. end;
  291. { reload the prefixes using the new messages }
  292. Loadprefixes;
  293. end;
  294. procedure MaybeLoadMessageFile;
  295. begin
  296. { Load new message file }
  297. if (msgfilename<>'') then
  298. begin
  299. LoadMsgFile(msgfilename);
  300. msgfilename:='';
  301. end;
  302. end;
  303. procedure SetCompileModule(p:tmodulebase);
  304. begin
  305. compiling_module:=p;
  306. end;
  307. var
  308. lastfileidx,
  309. lastmoduleidx : longint;
  310. Procedure UpdateStatus;
  311. begin
  312. { fix status }
  313. status.currentline:=aktfilepos.line;
  314. status.currentcolumn:=aktfilepos.column;
  315. if assigned(compiling_module) and
  316. assigned(compiling_module.sourcefiles) and
  317. ((compiling_module.unit_index<>lastmoduleidx) or
  318. (aktfilepos.fileindex<>lastfileidx)) then
  319. begin
  320. { update status record }
  321. status.currentmodule:=compiling_module.modulename^;
  322. status.currentsource:=compiling_module.sourcefiles.get_file_name(aktfilepos.fileindex);
  323. status.currentsourcepath:=compiling_module.sourcefiles.get_file_path(aktfilepos.fileindex);
  324. { update lastfileidx only if name known PM }
  325. if status.currentsource<>'' then
  326. lastfileidx:=aktfilepos.fileindex
  327. else
  328. lastfileidx:=0;
  329. lastmoduleidx:=compiling_module.unit_index;
  330. end;
  331. if assigned(compiling_module) then
  332. status.compiling_current:=(compiling_module.state in [ms_compile,ms_second_compile]);
  333. end;
  334. procedure ShowStatus;
  335. begin
  336. UpdateStatus;
  337. if do_status() then
  338. raise ECompilerAbort.Create;
  339. end;
  340. function ErrorCount:longint;
  341. begin
  342. ErrorCount:=status.errorcount;
  343. end;
  344. procedure SetErrorFlags(const s:string);
  345. var
  346. code : integer;
  347. i,j,l : longint;
  348. begin
  349. { empty string means error count = 1 for backward compatibility (PFV) }
  350. if s='' then
  351. begin
  352. status.maxerrorcount:=1;
  353. exit;
  354. end;
  355. i:=0;
  356. while (i<length(s)) do
  357. begin
  358. inc(i);
  359. case s[i] of
  360. '0'..'9' :
  361. begin
  362. j:=i;
  363. while (j<=length(s)) and (s[j] in ['0'..'9']) do
  364. inc(j);
  365. val(copy(s,i,j-i),l,code);
  366. if code<>0 then
  367. l:=1;
  368. status.maxerrorcount:=l;
  369. i:=j;
  370. end;
  371. 'w','W' :
  372. status.errorwarning:=true;
  373. 'n','N' :
  374. status.errornote:=true;
  375. 'h','H' :
  376. status.errorhint:=true;
  377. end;
  378. end;
  379. end;
  380. procedure GenerateError;
  381. begin
  382. inc(status.errorcount);
  383. end;
  384. procedure internalerror(i : longint);
  385. begin
  386. UpdateStatus;
  387. do_internalerror(i);
  388. inc(status.errorcount);
  389. raise ECompilerAbort.Create;
  390. end;
  391. procedure Comment(l:longint;s:string);
  392. var
  393. dostop : boolean;
  394. begin
  395. dostop:=((l and V_Fatal)<>0);
  396. if ((l and V_Error)<>0) or
  397. (status.errorwarning and ((l and V_Warning)<>0)) or
  398. (status.errornote and ((l and V_Note)<>0)) or
  399. (status.errorhint and ((l and V_Hint)<>0)) then
  400. inc(status.errorcount);
  401. { check verbosity level }
  402. if not CheckVerbosity(l) then
  403. exit;
  404. if (l and V_LineInfoMask)<>0 then
  405. l:=l or V_LineInfo;
  406. { Create status info }
  407. UpdateStatus;
  408. { Fix replacements }
  409. DefaultReplacements(s);
  410. { show comment }
  411. if do_comment(l,s) or dostop then
  412. raise ECompilerAbort.Create;
  413. if (status.errorcount>=status.maxerrorcount) and not status.skip_error then
  414. begin
  415. Message1(unit_f_errors_in_unit,tostr(status.errorcount));
  416. status.skip_error:=true;
  417. raise ECompilerAbort.Create;
  418. end;
  419. end;
  420. Procedure Msg2Comment(s:string);
  421. var
  422. idx,i,v : longint;
  423. dostop : boolean;
  424. begin
  425. {Reset}
  426. dostop:=false;
  427. v:=0;
  428. {Parse options}
  429. idx:=pos('_',s);
  430. if idx=0 then
  431. v:=V_Normal
  432. else
  433. if (idx >= 1) And (idx <= 5) then
  434. begin
  435. for i:=1 to idx do
  436. begin
  437. case upcase(s[i]) of
  438. 'F' :
  439. begin
  440. v:=v or V_Fatal;
  441. inc(status.errorcount);
  442. dostop:=true;
  443. end;
  444. 'E' :
  445. begin
  446. v:=v or V_Error;
  447. inc(status.errorcount);
  448. end;
  449. 'O' :
  450. v:=v or V_Normal;
  451. 'W':
  452. begin
  453. v:=v or V_Warning;
  454. if status.errorwarning then
  455. inc(status.errorcount);
  456. end;
  457. 'N' :
  458. begin
  459. v:=v or V_Note;
  460. if status.errornote then
  461. inc(status.errorcount);
  462. end;
  463. 'H' :
  464. begin
  465. v:=v or V_Hint;
  466. if status.errorhint then
  467. inc(status.errorcount);
  468. end;
  469. 'I' :
  470. v:=v or V_Info;
  471. 'L' :
  472. v:=v or V_LineInfo;
  473. 'U' :
  474. v:=v or V_Used;
  475. 'T' :
  476. v:=v or V_Tried;
  477. 'C' :
  478. v:=v or V_Conditional;
  479. 'D' :
  480. v:=v or V_Debug;
  481. 'X' :
  482. v:=v or V_Executable;
  483. 'S' :
  484. dostop:=true;
  485. '_' : ;
  486. end;
  487. end;
  488. end;
  489. Delete(s,1,idx);
  490. { check verbosity level }
  491. if not CheckVerbosity(v) then
  492. exit;
  493. if (v and V_LineInfoMask)<>0 then
  494. v:=v or V_LineInfo;
  495. { fix status }
  496. UpdateStatus;
  497. { Fix replacements }
  498. DefaultReplacements(s);
  499. { show comment }
  500. if do_comment(v,s) or dostop then
  501. raise ECompilerAbort.Create;
  502. if (status.errorcount>=status.maxerrorcount) and not status.skip_error then
  503. begin
  504. Message1(unit_f_errors_in_unit,tostr(status.errorcount));
  505. status.skip_error:=true;
  506. raise ECompilerAbort.Create;
  507. end;
  508. end;
  509. function MessagePchar(w:longint):pchar;
  510. begin
  511. MaybeLoadMessageFile;
  512. MessagePchar:=msg^.GetPchar(w)
  513. end;
  514. procedure Message(w:longint);
  515. begin
  516. MaybeLoadMessageFile;
  517. Msg2Comment(msg^.Get(w,[]));
  518. end;
  519. procedure Message1(w:longint;const s1:string);
  520. {$ifdef ver1_0}
  521. var
  522. hs1 : string;
  523. {$endif ver1_0}
  524. begin
  525. MaybeLoadMessageFile;
  526. {$ifdef ver1_0}
  527. { 1.0.x is broken, it uses concatcopy instead of shortstring
  528. copy when passing array of shortstring. (PFV) }
  529. hs1:=s1;
  530. Msg2Comment(msg^.Get(w,[hs1]));
  531. {$else ver1_0}
  532. Msg2Comment(msg^.Get(w,[s1]));
  533. {$endif ver1_0}
  534. end;
  535. procedure Message2(w:longint;const s1,s2:string);
  536. {$ifdef ver1_0}
  537. var
  538. hs1,hs2 : string;
  539. {$endif ver1_0}
  540. begin
  541. MaybeLoadMessageFile;
  542. {$ifdef ver1_0}
  543. { 1.0.x is broken, it uses concatcopy instead of shortstring
  544. copy when passing array of shortstring. (PFV) }
  545. hs1:=s1;
  546. hs2:=s2;
  547. Msg2Comment(msg^.Get(w,[hs1,hs2]));
  548. {$else ver1_0}
  549. Msg2Comment(msg^.Get(w,[s1,s2]));
  550. {$endif ver1_0}
  551. end;
  552. procedure Message3(w:longint;const s1,s2,s3:string);
  553. {$ifdef ver1_0}
  554. var
  555. hs1,hs2,hs3 : string;
  556. {$endif ver1_0}
  557. begin
  558. MaybeLoadMessageFile;
  559. {$ifdef ver1_0}
  560. { 1.0.x is broken, it uses concatcopy instead of shortstring
  561. copy when passing array of shortstring. (PFV) }
  562. hs1:=s1;
  563. hs2:=s2;
  564. hs3:=s3;
  565. Msg2Comment(msg^.Get(w,[hs1,hs2,hs3]));
  566. {$else ver1_0}
  567. Msg2Comment(msg^.Get(w,[s1,s2,s3]));
  568. {$endif ver1_0}
  569. end;
  570. procedure Message4(w:longint;const s1,s2,s3,s4:string);
  571. {$ifdef ver1_0}
  572. var
  573. hs1,hs2,hs3,hs4 : string;
  574. {$endif ver1_0}
  575. begin
  576. MaybeLoadMessageFile;
  577. {$ifdef ver1_0}
  578. { 1.0.x is broken, it uses concatcopy instead of shortstring
  579. copy when passing array of shortstring. (PFV) }
  580. hs1:=s1;
  581. hs2:=s2;
  582. hs3:=s3;
  583. hs4:=s4;
  584. Msg2Comment(msg^.Get(w,[hs1,hs2,hs3,hs4]));
  585. {$else ver1_0}
  586. Msg2Comment(msg^.Get(w,[s1,s2,s3,s4]));
  587. {$endif ver1_0}
  588. end;
  589. procedure MessagePos(const pos:tfileposinfo;w:longint);
  590. var
  591. oldpos : tfileposinfo;
  592. begin
  593. oldpos:=aktfilepos;
  594. aktfilepos:=pos;
  595. MaybeLoadMessageFile;
  596. Msg2Comment(msg^.Get(w,[]));
  597. aktfilepos:=oldpos;
  598. end;
  599. procedure MessagePos1(const pos:tfileposinfo;w:longint;const s1:string);
  600. var
  601. oldpos : tfileposinfo;
  602. begin
  603. oldpos:=aktfilepos;
  604. aktfilepos:=pos;
  605. MaybeLoadMessageFile;
  606. Msg2Comment(msg^.Get(w,[s1]));
  607. aktfilepos:=oldpos;
  608. end;
  609. procedure MessagePos2(const pos:tfileposinfo;w:longint;const s1,s2:string);
  610. var
  611. oldpos : tfileposinfo;
  612. begin
  613. oldpos:=aktfilepos;
  614. aktfilepos:=pos;
  615. MaybeLoadMessageFile;
  616. Msg2Comment(msg^.Get(w,[s1,s2]));
  617. aktfilepos:=oldpos;
  618. end;
  619. procedure MessagePos3(const pos:tfileposinfo;w:longint;const s1,s2,s3:string);
  620. var
  621. oldpos : tfileposinfo;
  622. begin
  623. oldpos:=aktfilepos;
  624. aktfilepos:=pos;
  625. MaybeLoadMessageFile;
  626. Msg2Comment(msg^.Get(w,[s1,s2,s3]));
  627. aktfilepos:=oldpos;
  628. end;
  629. procedure MessagePos4(const pos:tfileposinfo;w:longint;const s1,s2,s3,s4:string);
  630. var
  631. oldpos : tfileposinfo;
  632. begin
  633. oldpos:=aktfilepos;
  634. aktfilepos:=pos;
  635. MaybeLoadMessageFile;
  636. Msg2Comment(msg^.Get(w,[s1,s2,s3,s4]));
  637. aktfilepos:=oldpos;
  638. end;
  639. {*****************************************************************************
  640. override the message calls to set codegenerror
  641. *****************************************************************************}
  642. procedure cgmessage(t : longint);
  643. var
  644. olderrorcount : longint;
  645. begin
  646. if not(codegenerror) then
  647. begin
  648. olderrorcount:=Errorcount;
  649. verbose.Message(t);
  650. codegenerror:=olderrorcount<>Errorcount;
  651. end;
  652. end;
  653. procedure cgmessage1(t : longint;const s : string);
  654. var
  655. olderrorcount : longint;
  656. begin
  657. if not(codegenerror) then
  658. begin
  659. olderrorcount:=Errorcount;
  660. verbose.Message1(t,s);
  661. codegenerror:=olderrorcount<>Errorcount;
  662. end;
  663. end;
  664. procedure cgmessage2(t : longint;const s1,s2 : string);
  665. var
  666. olderrorcount : longint;
  667. begin
  668. if not(codegenerror) then
  669. begin
  670. olderrorcount:=Errorcount;
  671. verbose.Message2(t,s1,s2);
  672. codegenerror:=olderrorcount<>Errorcount;
  673. end;
  674. end;
  675. procedure cgmessage3(t : longint;const s1,s2,s3 : string);
  676. var
  677. olderrorcount : longint;
  678. begin
  679. if not(codegenerror) then
  680. begin
  681. olderrorcount:=Errorcount;
  682. verbose.Message3(t,s1,s2,s3);
  683. codegenerror:=olderrorcount<>Errorcount;
  684. end;
  685. end;
  686. procedure cgmessagepos(const pos:tfileposinfo;t : longint);
  687. var
  688. olderrorcount : longint;
  689. begin
  690. if not(codegenerror) then
  691. begin
  692. olderrorcount:=Errorcount;
  693. verbose.MessagePos(pos,t);
  694. codegenerror:=olderrorcount<>Errorcount;
  695. end;
  696. end;
  697. procedure cgmessagepos1(const pos:tfileposinfo;t : longint;const s1 : string);
  698. var
  699. olderrorcount : longint;
  700. begin
  701. if not(codegenerror) then
  702. begin
  703. olderrorcount:=Errorcount;
  704. verbose.MessagePos1(pos,t,s1);
  705. codegenerror:=olderrorcount<>Errorcount;
  706. end;
  707. end;
  708. procedure cgmessagepos2(const pos:tfileposinfo;t : longint;const s1,s2 : string);
  709. var
  710. olderrorcount : longint;
  711. begin
  712. if not(codegenerror) then
  713. begin
  714. olderrorcount:=Errorcount;
  715. verbose.MessagePos2(pos,t,s1,s2);
  716. codegenerror:=olderrorcount<>Errorcount;
  717. end;
  718. end;
  719. procedure cgmessagepos3(const pos:tfileposinfo;t : longint;const s1,s2,s3 : string);
  720. var
  721. olderrorcount : longint;
  722. begin
  723. if not(codegenerror) then
  724. begin
  725. olderrorcount:=Errorcount;
  726. verbose.MessagePos3(pos,t,s1,s2,s3);
  727. codegenerror:=olderrorcount<>Errorcount;
  728. end;
  729. end;
  730. {*****************************************************************************
  731. Initialization
  732. *****************************************************************************}
  733. procedure InitVerbose;
  734. begin
  735. { Init }
  736. msg:=new(pmessage,Init(20,msgidxmax));
  737. if msg=nil then
  738. begin
  739. writeln('Fatal: MsgIdx Wrong');
  740. halt(3);
  741. end;
  742. {$ifndef EXTERN_MSG}
  743. msg^.LoadIntern(@msgtxt,msgtxtsize);
  744. {$else EXTERN_MSG}
  745. LoadMsgFile(exepath+'errore.msg');
  746. {$endif EXTERN_MSG}
  747. FillChar(Status,sizeof(TCompilerStatus),0);
  748. status.verbosity:=V_Default;
  749. Status.MaxErrorCount:=50;
  750. Loadprefixes;
  751. lastfileidx:=-1;
  752. lastmoduleidx:=-1;
  753. status.currentmodule:='';
  754. status.currentsource:='';
  755. status.currentsourcepath:='';
  756. status.compiling_current:=false;
  757. compiling_module:=nil;
  758. { Register internalerrorproc for cutils/cclasses }
  759. internalerrorproc:=@internalerror;
  760. end;
  761. procedure DoneVerbose;
  762. begin
  763. if assigned(msg) then
  764. begin
  765. dispose(msg,Done);
  766. msg:=nil;
  767. end;
  768. DoneRedirectFile;
  769. end;
  770. initialization
  771. finalization
  772. { Be sure to close the redirect files to flush all data }
  773. DoneRedirectFile;
  774. end.