home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / f2csrc.zip / f2csrc / src / error.c < prev    next >
C/C++ Source or Header  |  1994-02-25  |  5KB  |  348 lines

  1. /****************************************************************
  2. Copyright 1990, 1993, 1994 by AT&T Bell Laboratories and Bellcore.
  3.  
  4. Permission to use, copy, modify, and distribute this software
  5. and its documentation for any purpose and without fee is hereby
  6. granted, provided that the above copyright notice appear in all
  7. copies and that both that the copyright notice and this
  8. permission notice and warranty disclaimer appear in supporting
  9. documentation, and that the names of AT&T Bell Laboratories or
  10. Bellcore or any of their entities not be used in advertising or
  11. publicity pertaining to distribution of the software without
  12. specific, written prior permission.
  13.  
  14. AT&T and Bellcore disclaim all warranties with regard to this
  15. software, including all implied warranties of merchantability
  16. and fitness.  In no event shall AT&T or Bellcore be liable for
  17. any special, indirect or consequential damages or any damages
  18. whatsoever resulting from loss of use, data or profits, whether
  19. in an action of contract, negligence or other tortious action,
  20. arising out of or in connection with the use or performance of
  21. this software.
  22. ****************************************************************/
  23.  
  24. #include "defs.h"
  25.  
  26.  void
  27. #ifdef KR_headers
  28. warni(s, t)
  29.     char *s;
  30.     int t;
  31. #else
  32. warni(char *s, int t)
  33. #endif
  34. {
  35.     char buf[100];
  36.     sprintf(buf,s,t);
  37.     warn(buf);
  38.     }
  39.  
  40.  void
  41. #ifdef KR_headers
  42. warn1(s, t)
  43.     char *s;
  44.     char *t;
  45. #else
  46. warn1(char *s, char *t)
  47. #endif
  48. {
  49.     char buff[100];
  50.     sprintf(buff, s, t);
  51.     warn(buff);
  52. }
  53.  
  54.  void
  55. #ifdef KR_headers
  56. warn(s)
  57.     char *s;
  58. #else
  59. warn(char *s)
  60. #endif
  61. {
  62.     if(nowarnflag)
  63.         return;
  64.     if (infname && *infname)
  65.         fprintf(diagfile, "Warning on line %ld of %s: %s\n",
  66.             lineno, infname, s);
  67.     else
  68.         fprintf(diagfile, "Warning on line %ld: %s\n", lineno, s);
  69.     fflush(diagfile);
  70.     ++nwarn;
  71. }
  72.  
  73.  void
  74. #ifdef KR_headers
  75. errstr(s, t)
  76.     char *s;
  77.     char *t;
  78. #else
  79. errstr(char *s, char *t)
  80. #endif
  81. {
  82.     char buff[100];
  83.     sprintf(buff, s, t);
  84.     err(buff);
  85. }
  86.  
  87.  
  88.  void
  89. #ifdef KR_headers
  90. erri(s, t)
  91.     char *s;
  92.     int t;
  93. #else
  94. erri(char *s, int t)
  95. #endif
  96. {
  97.     char buff[100];
  98.     sprintf(buff, s, t);
  99.     err(buff);
  100. }
  101.  
  102.  void
  103. #ifdef KR_headers
  104. errl(s, t)
  105.     char *s;
  106.     long t;
  107. #else
  108. errl(char *s, long t)
  109. #endif
  110. {
  111.     char buff[100];
  112.     sprintf(buff, s, t);
  113.     err(buff);
  114. }
  115.  
  116.  char *err_proc = 0;
  117.  
  118.  void
  119. #ifdef KR_headers
  120. err(s)
  121.     char *s;
  122. #else
  123. err(char *s)
  124. #endif
  125. {
  126.     if (err_proc)
  127.         fprintf(diagfile,
  128.             "Error processing %s before line %ld",
  129.             err_proc, lineno);
  130.     else
  131.         fprintf(diagfile, "Error on line %ld", lineno);
  132.     if (infname && *infname)
  133.         fprintf(diagfile, " of %s", infname);
  134.     fprintf(diagfile, ": %s\n", s);
  135.     fflush(diagfile);
  136.     ++nerr;
  137. }
  138.  
  139.  void
  140. #ifdef KR_headers
  141. yyerror(s)
  142.     char *s;
  143. #else
  144. yyerror(char *s)
  145. #endif
  146. {
  147.     err(s);
  148. }
  149.  
  150.  
  151.  void
  152. #ifdef KR_headers
  153. dclerr(s, v)
  154.     char *s;
  155.     Namep v;
  156. #else
  157. dclerr(char *s, Namep v)
  158. #endif
  159. {
  160.     char buff[100];
  161.  
  162.     if(v)
  163.     {
  164.         sprintf(buff, "Declaration error for %s: %s", v->fvarname, s);
  165.         err(buff);
  166.     }
  167.     else
  168.         errstr("Declaration error %s", s);
  169. }
  170.  
  171.  
  172.  void
  173. #ifdef KR_headers
  174. execerr(s, n)
  175.     char *s;
  176.     char *n;
  177. #else
  178. execerr(char *s, char *n)
  179. #endif
  180. {
  181.     char buf1[100], buf2[100];
  182.  
  183.     sprintf(buf1, "Execution error %s", s);
  184.     sprintf(buf2, buf1, n);
  185.     err(buf2);
  186. }
  187.  
  188.  
  189.  void
  190. #ifdef KR_headers
  191. Fatal(t)
  192.     char *t;
  193. #else
  194. Fatal(char *t)
  195. #endif
  196. {
  197.     fprintf(diagfile, "Compiler error line %ld", lineno);
  198.     if (infname)
  199.         fprintf(diagfile, " of %s", infname);
  200.     fprintf(diagfile, ": %s\n", t);
  201.     done(3);
  202. }
  203.  
  204.  
  205.  
  206.  void
  207. #ifdef KR_headers
  208. fatalstr(t, s)
  209.     char *t;
  210.     char *s;
  211. #else
  212. fatalstr(char *t, char *s)
  213. #endif
  214. {
  215.     char buff[100];
  216.     sprintf(buff, t, s);
  217.     Fatal(buff);
  218. }
  219.  
  220.  
  221.  void
  222. #ifdef KR_headers
  223. fatali(t, d)
  224.     char *t;
  225.     int d;
  226. #else
  227. fatali(char *t, int d)
  228. #endif
  229. {
  230.     char buff[100];
  231.     sprintf(buff, t, d);
  232.     Fatal(buff);
  233. }
  234.  
  235.  
  236.  void
  237. #ifdef KR_headers
  238. badthing(thing, r, t)
  239.     char *thing;
  240.     char *r;
  241.     int t;
  242. #else
  243. badthing(char *thing, char *r, int t)
  244. #endif
  245. {
  246.     char buff[50];
  247.     sprintf(buff, "Impossible %s %d in routine %s", thing, t, r);
  248.     Fatal(buff);
  249. }
  250.  
  251.  
  252.  void
  253. #ifdef KR_headers
  254. badop(r, t)
  255.     char *r;
  256.     int t;
  257. #else
  258. badop(char *r, int t)
  259. #endif
  260. {
  261.     badthing("opcode", r, t);
  262. }
  263.  
  264.  
  265.  void
  266. #ifdef KR_headers
  267. badtag(r, t)
  268.     char *r;
  269.     int t;
  270. #else
  271. badtag(char *r, int t)
  272. #endif
  273. {
  274.     badthing("tag", r, t);
  275. }
  276.  
  277.  
  278.  
  279.  
  280.  void
  281. #ifdef KR_headers
  282. badstg(r, t)
  283.     char *r;
  284.     int t;
  285. #else
  286. badstg(char *r, int t)
  287. #endif
  288. {
  289.     badthing("storage class", r, t);
  290. }
  291.  
  292.  
  293.  
  294.  void
  295. #ifdef KR_headers
  296. badtype(r, t)
  297.     char *r;
  298.     int t;
  299. #else
  300. badtype(char *r, int t)
  301. #endif
  302. {
  303.     badthing("type", r, t);
  304. }
  305.  
  306.  void
  307. #ifdef KR_headers
  308. many(s, c, n)
  309.     char *s;
  310.     char c;
  311.     int n;
  312. #else
  313. many(char *s, char c, int n)
  314. #endif
  315. {
  316.     char buff[250];
  317.  
  318.     sprintf(buff,
  319.         "Too many %s.\nTable limit now %d.\nTry rerunning with the -N%c%d option.\n",
  320.         s, n, c, 2*n);
  321.     Fatal(buff);
  322. }
  323.  
  324.  void
  325. #ifdef KR_headers
  326. err66(s)
  327.     char *s;
  328. #else
  329. err66(char *s)
  330. #endif
  331. {
  332.     errstr("Fortran 77 feature used: %s", s);
  333.     --nerr;
  334. }
  335.  
  336.  
  337.  void
  338. #ifdef KR_headers
  339. errext(s)
  340.     char *s;
  341. #else
  342. errext(char *s)
  343. #endif
  344. {
  345.     errstr("f2c extension used: %s", s);
  346.     --nerr;
  347. }
  348.