messages.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /* messages.c - error reporter -
  2. Copyright (C) 1987 Free Software Foundation, Inc.
  3. This file is part of GAS, the GNU Assembler.
  4. GAS 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 1, or (at your option)
  7. any later version.
  8. GAS 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 GAS; see the file COPYING. If not, write to
  14. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
  15. #include <stdio.h> /* define stderr */
  16. #include "as.h"
  17. #ifndef NO_VARARGS
  18. #include <varargs.h>
  19. #endif
  20. /*
  21. ERRORS
  22. We print the error message 1st, beginning in column 1.
  23. All ancillary info starts in column 2 on lines after the
  24. key error text.
  25. We try to print a location in logical and physical file
  26. just after the main error text.
  27. Caller then prints any appendices after that, begining all
  28. lines with at least 1 space.
  29. Optionally, we may die.
  30. There is no need for a trailing '\n' in your error text format
  31. because we supply one.
  32. as_warn(fmt,args) Like fprintf(stderr,fmt,args) but also call errwhere().
  33. as_fatal(fmt,args) Like as_warn() but exit with a fatal status.
  34. */
  35. /*
  36. * a s _ w a r n ( )
  37. *
  38. * Send to stderr a string (with bell) (JF: Bell is obnoxious!) as a warning, and locate warning
  39. * in input file(s).
  40. * Please only use this for when we have some recovery action.
  41. * Please explain in string (which may have '\n's) what recovery was done.
  42. */
  43. #ifdef NO_VARARGS
  44. /*VARARGS1*/
  45. as_warn(Format,args)
  46. char *Format;
  47. {
  48. if ( ! flagseen ['W']) /* -W supresses warning messages. */
  49. {
  50. as_where();
  51. _doprnt (Format, &args, stderr);
  52. (void)putc ('\n', stderr);
  53. /* as_where(); */
  54. }
  55. }
  56. #else
  57. void
  58. as_warn(Format,va_alist)
  59. char *Format;
  60. va_dcl
  61. {
  62. va_list args;
  63. if( ! flagseen['W'])
  64. {
  65. as_where();
  66. va_start(args);
  67. vfprintf(stderr, Format, args);
  68. va_end(args);
  69. (void) putc('\n', stderr);
  70. }
  71. }
  72. #endif
  73. #ifdef DONTDEF
  74. void
  75. as_warn(Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an)
  76. char *format;
  77. {
  78. if(!flagseen['W']) {
  79. as_where();
  80. fprintf(stderr,Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an);
  81. (void)putc('\n',stderr);
  82. }
  83. }
  84. #endif
  85. /*
  86. * a s _ f a t a l ( )
  87. *
  88. * Send to stderr a string (with bell) (JF: Bell is obnoxious!) as a fatal
  89. * message, and locate stdsource in input file(s).
  90. * Please only use this for when we DON'T have some recovery action.
  91. * It exit()s with a warning status.
  92. */
  93. #ifdef NO_VARARGS
  94. /*VARARGS1*/
  95. as_fatal (Format, args)
  96. char *Format;
  97. {
  98. as_where();
  99. fprintf(stderr,"FATAL:");
  100. _doprnt (Format, &args, stderr);
  101. (void)putc ('\n', stderr);
  102. /* as_where(); */
  103. exit(42); /* What is a good exit status? */
  104. }
  105. #else
  106. void
  107. as_fatal(Format,va_alist)
  108. char *Format;
  109. va_dcl
  110. {
  111. va_list args;
  112. as_where();
  113. va_start(args);
  114. fprintf (stderr, "FATAL:");
  115. vfprintf(stderr, Format, args);
  116. (void) putc('\n', stderr);
  117. va_end(args);
  118. exit(42);
  119. }
  120. #endif
  121. #ifdef DONTDEF
  122. void
  123. as_fatal(Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an)
  124. char *Format;
  125. {
  126. as_where();
  127. fprintf (stderr, "FATAL:");
  128. fprintf(stderr, Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an);
  129. (void) putc('\n', stderr);
  130. exit(42);
  131. }
  132. #endif
  133. /* end: messages.c */