verbose.pas 24 KB

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