Import updated Russian translation from Translation Project's website.
[deliverable/binutils-gdb.git] / gas / messages.c
index 1abfb3ac3b6f5b2ff212a2428a0b43581980fce7..39842e99547c22f95c546ee42ab0c999f9f498b7 100644 (file)
@@ -1,5 +1,6 @@
 /* messages.c - error reporter -
-   Copyright (C) 1987, 91, 92, 93, 94, 95, 96, 97, 98, 2000
+   Copyright 1987, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 2000, 2001,
+   2003, 2004
    Free Software Foundation, Inc.
    This file is part of GAS, the GNU Assembler.
 
@@ -42,53 +43,52 @@ typedef int * va_list;
 #define va_end(ARGS)
 #endif
 
-static void identify PARAMS ((char *));
-static void as_show_where PARAMS ((void));
-static void as_warn_internal PARAMS ((char *, unsigned int, char *));
-static void as_bad_internal PARAMS ((char *, unsigned int, char *));
+static void identify (char *);
+static void as_show_where (void);
+static void as_warn_internal (char *, unsigned int, char *);
+static void as_bad_internal (char *, unsigned int, char *);
 
 /* Despite the rest of the comments in this file, (FIXME-SOON),
- * here is the current scheme for error messages etc:
- *
- * as_fatal() is used when gas is quite confused and
- * continuing the assembly is pointless.  In this case we
- * exit immediately with error status.
- *
- * as_bad() is used to mark errors that result in what we
- * presume to be a useless object file.  Say, we ignored
- * something that might have been vital.  If we see any of
- * these, assembly will continue to the end of the source,
- * no object file will be produced, and we will terminate
- * with error status.  The new option, -Z, tells us to
- * produce an object file anyway but we still exit with
- * error status.  The assumption here is that you don't want
- * this object file but we could be wrong.
- *
- * as_warn() is used when we have an error from which we
- * have a plausible error recovery.  eg, masking the top
- * bits of a constant that is longer than will fit in the
- * destination.  In this case we will continue to assemble
- * the source, although we may have made a bad assumption,
- * and we will produce an object file and return normal exit
- * status (ie, no error).  The new option -X tells us to
- * treat all as_warn() errors as as_bad() errors.  That is,
- * no object file will be produced and we will exit with
- * error status.  The idea here is that we don't kill an
- * entire make because of an error that we knew how to
- * correct.  On the other hand, sometimes you might want to
- * stop the make at these points.
- *
- * as_tsktsk() is used when we see a minor error for which
- * our error recovery action is almost certainly correct.
- * In this case, we print a message and then assembly
- * continues as though no error occurred.
- */
+   here is the current scheme for error messages etc:
+
+   as_fatal() is used when gas is quite confused and
+   continuing the assembly is pointless.  In this case we
+   exit immediately with error status.
+
+   as_bad() is used to mark errors that result in what we
+   presume to be a useless object file.  Say, we ignored
+   something that might have been vital.  If we see any of
+   these, assembly will continue to the end of the source,
+   no object file will be produced, and we will terminate
+   with error status.  The new option, -Z, tells us to
+   produce an object file anyway but we still exit with
+   error status.  The assumption here is that you don't want
+   this object file but we could be wrong.
+
+   as_warn() is used when we have an error from which we
+   have a plausible error recovery.  eg, masking the top
+   bits of a constant that is longer than will fit in the
+   destination.  In this case we will continue to assemble
+   the source, although we may have made a bad assumption,
+   and we will produce an object file and return normal exit
+   status (ie, no error).  The new option -X tells us to
+   treat all as_warn() errors as as_bad() errors.  That is,
+   no object file will be produced and we will exit with
+   error status.  The idea here is that we don't kill an
+   entire make because of an error that we knew how to
+   correct.  On the other hand, sometimes you might want to
+   stop the make at these points.
+
+   as_tsktsk() is used when we see a minor error for which
+   our error recovery action is almost certainly correct.
+   In this case, we print a message and then assembly
+   continues as though no error occurred.  */
 
 static void
-identify (file)
-     char *file;
+identify (char *file)
 {
   static int identified;
+
   if (identified)
     return;
   identified++;
@@ -108,9 +108,9 @@ identify (file)
 static int warning_count;
 
 int
-had_warnings ()
+had_warnings (void)
 {
-  return (warning_count);
+  return warning_count;
 }
 
 /* Nonzero if we've hit a 'bad error', and should not write an obj file,
@@ -119,15 +119,15 @@ had_warnings ()
 static int error_count;
 
 int
-had_errors ()
+had_errors (void)
 {
-  return (error_count);
+  return error_count;
 }
 
 /* Print the current location to stderr.  */
 
 static void
-as_show_where ()
+as_show_where (void)
 {
   char *file;
   unsigned int line;
@@ -141,14 +141,15 @@ as_show_where ()
 /* Like perror(3), but with more info.  */
 
 void
-as_perror (gripe, filename)
-     const char *gripe;                /* Unpunctuated error theme.  */
-     const char *filename;
+as_perror (const char *gripe,          /* Unpunctuated error theme.  */
+          const char *filename)
 {
   const char *errtxt;
+  int saved_errno = errno;
 
   as_show_where ();
   fprintf (stderr, gripe, filename);
+  errno = saved_errno;
 #ifdef BFD_ASSEMBLER
   errtxt = bfd_errmsg (bfd_get_error ());
 #else
@@ -198,10 +199,7 @@ as_tsktsk (format, va_alist)
 /* The common portion of as_warn and as_warn_where.  */
 
 static void
-as_warn_internal (file, line, buffer)
-     char *file;
-     unsigned int line;
-     char *buffer;
+as_warn_internal (char *file, unsigned int line, char *buffer)
 {
   ++warning_count;
 
@@ -302,10 +300,7 @@ as_warn_where (file, line, format, va_alist)
 /* The common portion of as_bad and as_bad_where.  */
 
 static void
-as_bad_internal (file, line, buffer)
-     char *file;
-     unsigned int line;
-     char *buffer;
+as_bad_internal (char *file, unsigned int line, char *buffer)
 {
   ++error_count;
 
@@ -327,7 +322,7 @@ as_bad_internal (file, line, buffer)
    file(s).  Please us when there is no recovery, but we want to
    continue processing but not produce an object file.
    Please explain in string (which may have '\n's) what recovery was
-   done. */
+   done.  */
 
 #ifdef USE_STDARG
 void
@@ -417,7 +412,7 @@ as_fatal (const char *format, ...)
   /* Delete the output file, if it exists.  This will prevent make from
      thinking that a file was created and hence does not need rebuilding.  */
   if (out_file_name != NULL)
-    unlink (out_file_name);
+    unlink_if_ordinary (out_file_name);
   xexit (EXIT_FAILURE);
 }
 #else
@@ -442,9 +437,7 @@ as_fatal (format, va_alist)
    Arguments: Filename, line number, optional function name.  */
 
 void
-as_assert (file, line, fn)
-     const char *file, *fn;
-     int line;
+as_assert (const char *file, int line, const char *fn)
 {
   as_show_where ();
   fprintf (stderr, _("Internal error!\n"));
@@ -461,9 +454,7 @@ as_assert (file, line, fn)
    and exit without producing a core file.  */
 
 void
-as_abort (file, line, fn)
-     const char *file, *fn;
-     int line;
+as_abort (const char *file, int line, const char *fn)
 {
   as_show_where ();
   if (fn)
@@ -479,9 +470,7 @@ as_abort (file, line, fn)
 /* Support routines.  */
 
 void
-fprint_value (file, val)
-     FILE *file;
-     valueT val;
+fprint_value (FILE *file, valueT val)
 {
   if (sizeof (val) <= sizeof (long))
     {
@@ -499,9 +488,7 @@ fprint_value (file, val)
 }
 
 void
-sprint_value (buf, val)
-     char *buf;
-     valueT val;
+sprint_value (char *buf, valueT val)
 {
   if (sizeof (val) <= sizeof (long))
     {
@@ -517,3 +504,86 @@ sprint_value (buf, val)
 #endif
   abort ();
 }
+
+#define HEX_MAX_THRESHOLD      1024
+#define HEX_MIN_THRESHOLD      -(HEX_MAX_THRESHOLD)
+
+static void
+as_internal_value_out_of_range (char *    prefix,
+                               offsetT   val,
+                               offsetT   min,
+                               offsetT   max,
+                               char *    file,
+                               unsigned  line,
+                               int       bad)
+{
+  const char * err;
+
+  if (prefix == NULL)
+    prefix = "";
+
+#ifdef BFD_ASSEMBLER
+  if (   val < HEX_MAX_THRESHOLD
+      && min < HEX_MAX_THRESHOLD
+      && max < HEX_MAX_THRESHOLD
+      && val > HEX_MIN_THRESHOLD
+      && min > HEX_MIN_THRESHOLD
+      && max > HEX_MIN_THRESHOLD)
+#endif
+    {
+      /* xgettext:c-format  */
+      err = _("%s out of range (%d is not between %d and %d)");
+
+      if (bad)
+       as_bad_where (file, line, err,
+                     prefix, (int) val, (int) min, (int) max);
+      else
+       as_warn_where (file, line, err,
+                      prefix, (int) val, (int) min, (int) max);
+    }
+#ifdef BFD_ASSEMBLER
+  else
+    {
+      char val_buf [sizeof (val) * 3 + 2];
+      char min_buf [sizeof (val) * 3 + 2];
+      char max_buf [sizeof (val) * 3 + 2];
+
+      if (sizeof (val) > sizeof (bfd_vma))
+       abort ();
+
+      sprintf_vma (val_buf, val);
+      sprintf_vma (min_buf, min);
+      sprintf_vma (max_buf, max);
+
+      /* xgettext:c-format.  */
+      err = _("%s out of range (0x%s is not between 0x%s and 0x%s)");
+
+      if (bad)
+       as_bad_where (file, line, err, prefix, val_buf, min_buf, max_buf);
+      else
+       as_warn_where (file, line, err, prefix, val_buf, min_buf, max_buf);
+    }
+#endif
+}
+
+void
+as_warn_value_out_of_range (char *   prefix,
+                          offsetT  value,
+                          offsetT  min,
+                          offsetT  max,
+                          char *   file,
+                          unsigned line)
+{
+  as_internal_value_out_of_range (prefix, value, min, max, file, line, 0);
+}
+
+void
+as_bad_value_out_of_range (char *   prefix,
+                          offsetT  value,
+                          offsetT  min,
+                          offsetT  max,
+                          char *   file,
+                          unsigned line)
+{
+  as_internal_value_out_of_range (prefix, value, min, max, file, line, 1);
+}
This page took 0.025909 seconds and 4 git commands to generate.