This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch/rfc] clean up type_error() and range_error()


Hello,

(The function type_error() doesn't appear to be used but I'll ignore 
that :-)

The funtion pair type_error() and parse_error() either print errors or 
warning depending on a corresponding internal variable.  The wierd thing 
is that they they still print the warning when that variable is set to 
_off_.  I suspect, because the code is only used by Fortran and 
Modula-2, no one has noticed.

Thoughts?

Anyway, ignoring that, this cleans up those functions.  I'l check it in 
in a day or so.

enjoy,
Andrew
2002-01-31  Andrew Cagney  <ac131313@redhat.com>

	* language.h (type_error, range_error): Make string parameter
	constant.
	* language.c (warning_pre_print): Delete extern declaration.
	* dwarfread.c (warning_pre_print): Ditto.
	* language.c (type_error, range_error): Rewrite to use verror and
	vwarning instead of warning_begin.

Index: language.c
===================================================================
RCS file: /cvs/src/src/gdb/language.c,v
retrieving revision 1.19
diff -p -r1.19 language.c
*** language.c	2002/01/12 20:00:07	1.19
--- language.c	2002/01/31 15:27:00
*************** static int unk_lang_value_print (struct 
*** 100,106 ****
  
  /* Forward declaration */
  extern const struct language_defn unknown_language_defn;
- extern char *warning_pre_print;
  
  /* The current (default at startup) state of type and range checking.
     (If the modes are set to "auto", though, these are changed based
--- 100,105 ----
*************** op_error (char *fmt, enum exp_opcode op,
*** 1234,1280 ****
      }
  }
  
! /* These are called when a language fails a type- or range-check.
!    The first argument should be a printf()-style format string, and
!    the rest of the arguments should be its arguments.  If
!    [type|range]_check is [type|range]_check_on, then return_to_top_level()
!    is called in the style of error ().  Otherwise, the message is prefixed
!    by the value of warning_pre_print and we do not return to the top level. */
  
  void
! type_error (char *string,...)
  {
    va_list args;
    va_start (args, string);
  
!   if (type_check == type_check_warn)
!     fprintf_filtered (gdb_stderr, warning_pre_print);
!   else
!     error_begin ();
! 
!   vfprintf_filtered (gdb_stderr, string, args);
!   fprintf_filtered (gdb_stderr, "\n");
    va_end (args);
-   if (type_check == type_check_on)
-     return_to_top_level (RETURN_ERROR);
  }
  
  void
! range_error (char *string,...)
  {
    va_list args;
    va_start (args, string);
  
!   if (range_check == range_check_warn)
!     fprintf_filtered (gdb_stderr, warning_pre_print);
!   else
!     error_begin ();
! 
!   vfprintf_filtered (gdb_stderr, string, args);
!   fprintf_filtered (gdb_stderr, "\n");
    va_end (args);
-   if (range_check == range_check_on)
-     return_to_top_level (RETURN_ERROR);
  }
  
  
--- 1233,1295 ----
      }
  }
  
! /* These are called when a language fails a type- or range-check.  The
!    first argument should be a printf()-style format string, and the
!    rest of the arguments should be its arguments.  If
!    [type|range]_check is [type|range]_check_on, an error is printed;
!    if [type|range]_check_warn, a warning; otherwise just the
!    message. */
  
  void
! type_error (const char *string,...)
  {
    va_list args;
    va_start (args, string);
  
!   switch (type_check)
!     {
!     case type_check_warn:
!       vwarning (string, args);
!       break;
!     case type_check_on:
!       verror (string, args);
!       break;
!     case type_check_off:
!       /* FIXME: cagney/2002-01-30: Should this function print anything
!          when type error is off?  */
!       vfprintf_filtered (gdb_stderr, string, args);
!       fprintf_filtered (gdb_stderr, "\n");
!       break;
!     default:
!       internal_error (__FILE__, __LINE__, "bad switch");
!     }
    va_end (args);
  }
  
  void
! range_error (const char *string,...)
  {
    va_list args;
    va_start (args, string);
  
!   switch (range_check)
!     {
!     case range_check_warn:
!       vwarning (string, args);
!       break;
!     case range_check_on:
!       verror (string, args);
!       break;
!     case range_check_off:
!       /* FIXME: cagney/2002-01-30: Should this function print anything
!          when range error is off?  */
!       vfprintf_filtered (gdb_stderr, string, args);
!       fprintf_filtered (gdb_stderr, "\n");
!       break;
!     default:
!       internal_error (__FILE__, __LINE__, "bad switch");
!     }
    va_end (args);
  }
  
  
Index: language.h
===================================================================
RCS file: /cvs/src/src/gdb/language.h,v
retrieving revision 1.8
diff -p -r1.8 language.h
*** language.h	2001/03/06 08:21:09	1.8
--- language.h	2002/01/31 15:27:03
*************** extern void op_error (char *fmt, enum ex
*** 440,450 ****
  #define range_op_error(f,o) \
     op_error((f),(o),range_check==range_check_on ? 1 : 0)
  
! extern void type_error (char *, ...) ATTR_FORMAT (printf, 1, 2);
  
! void
! range_error (char *, ...)
! ATTR_FORMAT (printf, 1, 2);
  
  /* Data:  Does this value represent "truth" to the current language?  */
  
--- 440,448 ----
  #define range_op_error(f,o) \
     op_error((f),(o),range_check==range_check_on ? 1 : 0)
  
! extern void type_error (const char *, ...) ATTR_FORMAT (printf, 1, 2);
  
! extern void range_error (const char *, ...) ATTR_FORMAT (printf, 1, 2);
  
  /* Data:  Does this value represent "truth" to the current language?  */
  
Index: dwarfread.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarfread.c,v
retrieving revision 1.11
diff -p -r1.11 dwarfread.c
*** dwarfread.c	2001/12/12 02:11:51	1.11
--- dwarfread.c	2002/01/31 15:27:30
*************** typedef unsigned int DIE_REF;	/* Referen
*** 239,248 ****
  
  #define	AT_short_element_list	 (0x00f0|FORM_BLOCK2)
  
- /* External variables referenced. */
- 
- extern char *warning_pre_print;	/* From utils.c */
- 
  /* The DWARF debugging information consists of two major pieces,
     one is a block of DWARF Information Entries (DIE's) and the other
     is a line number table.  The "struct dieinfo" structure contains
--- 239,244 ----

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]