verbose.pas 26 KB

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