home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.2 (Developer) / NS_dev_3.2.iso / NextDeveloper / Source / GNU / cctools / as / messages.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-25  |  5.2 KB  |  244 lines

  1. /* messages.c - error reporter -
  2.    Copyright (C) 1987 Free Software Foundation, Inc.
  3.  
  4. This file is part of GAS, the GNU Assembler.
  5.  
  6. GAS is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 1, or (at your option)
  9. any later version.
  10.  
  11. GAS is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GAS; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. #include <stdio.h>        /* define stderr */
  21. #include "as.h"
  22. #ifndef NO_VARARGS
  23. #include <varargs.h>
  24. #endif
  25.  
  26. /*
  27.         ERRORS
  28.  
  29.     We print the error message 1st, beginning in column 1.
  30.     All ancillary info starts in column 2 on lines after the
  31.     key error text.
  32.     We try to print a location in logical and physical file
  33.     just after the main error text.
  34.     Caller then prints any appendices after that, begining all
  35.     lines with at least 1 space.
  36.  
  37.     Optionally, we may die.
  38.     There is no need for a trailing '\n' in your error text format
  39.     because we supply one.
  40.  
  41. as_warn(fmt,args)  Like fprintf(stderr,fmt,args) but also call errwhere().
  42.  
  43. as_fatal(fmt,args) Like as_warn() but exit with a fatal status.
  44.  
  45. */
  46.  
  47.  
  48. /* Nonzero if we've hit a 'bad error', and should not write an obj file,
  49.    and exit with a nonzero error code */
  50.  
  51. int bad_error = 0;
  52.  
  53. #ifdef NeXT
  54. int arch_multiple = 0;
  55.  
  56. static
  57. void
  58. print_architecture_banner(void)
  59. {
  60.     static int printed = 0;
  61.  
  62.     if(arch_multiple && !printed){
  63. #ifdef M68K
  64.         printf("as: for architecture m68k\n");
  65. #endif /* M68K */
  66. #ifdef M88K
  67.         printf("as: for architecture m88k\n");
  68. #endif /* M88K */
  69. #ifdef I860
  70.         printf("as: for architecture i860\n");
  71. #endif /* I860 */
  72. #ifdef I386
  73.         printf("as: for architecture i386\n");
  74. #endif /* I386 */
  75.         printed = 1;
  76.     }
  77. }
  78. #endif /* NeXT */
  79.  
  80. /*
  81.  *            a s _ w a r n ( )
  82.  *
  83.  * Send to stderr a string (with bell) (JF: Bell is obnoxious!) as a warning, and locate warning
  84.  * in input file(s).
  85.  * Please only use this for when we have some recovery action.
  86.  * Please explain in string (which may have '\n's) what recovery was done.
  87.  */
  88.  
  89. #ifdef NO_VARARGS
  90. /*VARARGS1*/
  91. as_warn(Format,args)
  92. char *Format;
  93. {
  94.   if ( ! flagseen ['W'])    /* -W supresses warning messages. */
  95.     {
  96.       as_where();
  97.       _doprnt (Format, &args, stderr);
  98.       (void)putc ('\n', stderr);
  99.       /* as_where(); */
  100.     }
  101. }
  102. #else
  103. void
  104. as_warn(Format,va_alist)
  105. char *Format;
  106. va_dcl
  107. {
  108.   va_list args;
  109.  
  110.   if( ! flagseen['W'])
  111.     {
  112. #ifdef NeXT
  113.       print_architecture_banner();
  114. #endif /* NeXT */
  115. #ifdef NeXT /* bug #16137 and #16044 */
  116.       bad_error=1;
  117. #endif NeXT
  118.       as_where();
  119.       va_start(args);
  120.       vfprintf(stderr, Format, args);
  121.       va_end(args);
  122.       (void) putc('\n', stderr);
  123.     }
  124. }
  125. #endif
  126. #ifdef DONTDEF
  127. void
  128. as_warn(Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an)
  129. char *format;
  130. {
  131.     if(!flagseen['W']) {
  132.         as_where();
  133.         fprintf(stderr,Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an);
  134.         (void)putc('\n',stderr);
  135.     }
  136. }
  137. #endif
  138. /*
  139.  *            a s _ b a d ( )
  140.  *
  141.  * Send to stderr a string (with bell) (JF: Bell is obnoxious!) as a warning,
  142.  * and locate warning in input file(s).
  143.  * Please us when there is no recovery, but we want to continue processing
  144.  * but not produce an object file.
  145.  * Please explain in string (which may have '\n's) what recovery was done.
  146.  */
  147.  
  148. #ifdef NO_VARARGS
  149. /*VARARGS1*/
  150. as_bad(Format,args)
  151. char *Format;
  152. {
  153.   bad_error=1;
  154.   as_where();
  155.   _doprnt (Format, &args, stderr);
  156.   (void)putc ('\n', stderr);
  157.   /* as_where(); */
  158. }
  159. #else
  160. void
  161. as_bad(Format,va_alist)
  162. char *Format;
  163. va_dcl
  164. {
  165.   va_list args;
  166.  
  167. #ifdef NeXT
  168.   print_architecture_banner();
  169. #endif /* NeXT */
  170.   bad_error=1;
  171.   as_where();
  172.   va_start(args);
  173.   vfprintf(stderr, Format, args);
  174.   va_end(args);
  175.   (void) putc('\n', stderr);
  176. }
  177. #endif
  178. #ifdef DONTDEF
  179. void
  180. as_bad(Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an)
  181. char *format;
  182. {
  183.     as_where();
  184.     bad_error=1;
  185.     fprintf(stderr,Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an);
  186.     (void)putc('\n',stderr);
  187. }
  188. #endif
  189. /*
  190.  *            a s _ f a t a l ( )
  191.  *
  192.  * Send to stderr a string (with bell) (JF: Bell is obnoxious!) as a fatal
  193.  * message, and locate stdsource in input file(s).
  194.  * Please only use this for when we DON'T have some recovery action.
  195.  * It exit()s with a warning status.
  196.  */
  197.  
  198. #ifdef NO_VARARGS
  199. /*VARARGS1*/
  200. as_fatal (Format, args)
  201. char *Format;
  202. {
  203.   as_where();
  204.   fprintf(stderr,"FATAL:");
  205.   _doprnt (Format, &args, stderr);
  206.   (void)putc ('\n', stderr);
  207.   /* as_where(); */
  208.   exit(42);            /* What is a good exit status? */
  209. }
  210. #else
  211. void
  212. as_fatal(Format,va_alist)
  213. char *Format;
  214. va_dcl
  215. {
  216.   va_list args;
  217.  
  218. #ifdef NeXT
  219.   print_architecture_banner();
  220. #endif /* NeXT */
  221.   as_where();
  222.   va_start(args);
  223.   fprintf (stderr, "FATAL:");
  224.   vfprintf(stderr, Format, args);
  225.   (void) putc('\n', stderr);
  226.   va_end(args);
  227.   exit(42);
  228. }
  229. #endif
  230. #ifdef DONTDEF
  231. void
  232. as_fatal(Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an)
  233. char *Format;
  234. {
  235.   as_where();
  236.   fprintf (stderr, "FATAL:");
  237.   fprintf(stderr, Format,aa,ab,ac,ad,ae,af,ag,ah,ai,aj,ak,al,am,an);
  238.   (void) putc('\n', stderr);
  239.   exit(42);
  240. }
  241. #endif
  242.  
  243. /* end: messages.c */
  244.