error.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  3. * See the copyright notice in the ACK home directory, in the file "Copyright".
  4. */
  5. #ifndef lint
  6. static char rcsid[] = "$Id$";
  7. #endif
  8. #include <stdio.h>
  9. #include <out.h>
  10. #include "const.h"
  11. static short nerrors = 0;
  12. static diag();
  13. stop()
  14. {
  15. extern char *outputname;
  16. extern int exitstatus;
  17. if (nerrors) {
  18. unlink(outputname);
  19. exit(nerrors);
  20. }
  21. exit(exitstatus);
  22. }
  23. /* VARARGS1 */
  24. fatal(format, a1, a2, a3, a4)
  25. char *format;
  26. {
  27. nerrors++;
  28. diag("fatal", format, a1, a2, a3, a4);
  29. stop();
  30. }
  31. /* VARARGS1 */
  32. warning(format, a1, a2, a3, a4)
  33. char *format;
  34. {
  35. diag("warning", format, a1, a2, a3, a4);
  36. }
  37. /* VARARGS1 */
  38. error(format, a1, a2, a3, a4)
  39. char *format;
  40. {
  41. nerrors++;
  42. diag("error", format, a1, a2, a3, a4);
  43. }
  44. /* VARARGS1 */
  45. do_verbose(format, a1, a2, a3, a4)
  46. char *format;
  47. {
  48. diag((char *) 0, format, a1, a2, a3, a4);
  49. }
  50. static
  51. diag(tail, format, a1, a2, a3, a4)
  52. char *tail;
  53. char *format;
  54. {
  55. extern char *progname, *archname, *modulname;
  56. fprintf(stderr, "%s: ", progname);
  57. if (archname && modulname)
  58. fprintf(stderr, "%s(%.14s): ", archname, modulname);
  59. else if (archname)
  60. fprintf(stderr, "%s: ", archname);
  61. else if (modulname)
  62. fprintf(stderr, "%s: ", modulname);
  63. fprintf(stderr, format, a1, a2, a3, a4);
  64. if (tail) fprintf(stderr, " (%s)\n", tail);
  65. else putc('\n', stderr);
  66. }