This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

Re: [PATCH] Remove hardcoded limit on max error message length


Jakub Jelinek wrote:
> Ok to commit?
> 
> 2005-07-12  Jakub Jelinek  <jakub@redhat.com>
> 
> 	* gfortran.h (MAX_ERROR_MESSAGE): Remove.
> 	(gfc_error_buf): Add allocated and cur_ptr fields.  Change message
> 	field from array to a pointer.
> 	* error.c (use_warning_buffer, error_ptr, warning_ptr): Remove.
> 	(cur_error_buffer): New variable.
> 	(error_char): Use cur_error_buffer->{message,cur_ptr} instead of
> 	{warning,error}_{buffer.message,ptr}.  Reallocate message buffer
> 	if too small.
> 	(gfc_warning, gfc_notify_std, gfc_error, gfc_error_now): Setup
> 	cur_error_buffer and its cur_ptr rather than {warning,error}_ptr
> 	and use_warning_buffer.
> 	(gfc_warning_check, gfc_error_check): Don't print anything if
> 	message is NULL.
> 	(gfc_push_error): Allocate saved message with xstrdup.
> 	(gfc_pop_error): Free saved message with gfc_free.
> 	(gfc_free_error): New function.
> 	* primary.c (match_complex_constant): Call gfc_free_error if
> 	gfc_pop_error will not be called.
> 	* match.c (gfc_match_st_function): Likewise.
> 
> 	* gfortran.dg/g77/cpp6.f: New test.
> 
> --- gcc/fortran/gfortran.h.jj	2005-07-07 13:04:21.000000000 +0200
> +++ gcc/fortran/gfortran.h	2005-07-12 09:20:42.000000000 +0200
> @@ -58,7 +58,6 @@ char *alloca ();
> @@ -1548,7 +1547,8 @@ const char * gfc_get_string (const char 
>  typedef struct gfc_error_buf
>  {
>    int flag;
> -  char message[MAX_ERROR_MESSAGE];
> +  size_t allocated;
> +  char *message, *cur_ptr;
>  } gfc_error_buf;
>  
>  void gfc_error_init_1 (void);
> --- gcc/fortran/error.c.jj	2005-07-07 13:04:21.000000000 +0200
> +++ gcc/fortran/error.c	2005-07-12 10:00:03.000000000 +0200
> @@ -33,12 +33,9 @@ Software Foundation, 51 Franklin Street,
>  
>  int gfc_suppress_error = 0;
>  
> -static int terminal_width, buffer_flag, errors,
> -  use_warning_buffer, warnings;
> +static int terminal_width, buffer_flag, errors, warnings;
>  
> -static char *error_ptr, *warning_ptr;
> -
> -static gfc_error_buf error_buffer, warning_buffer;
> +static gfc_error_buf error_buffer, warning_buffer, *cur_error_buffer;

I'm wondering if making error_buffer and warning_buffer pointers, and changing
gfc_error_buf to
 typedef struct gfc_error_buf
 {
   int flag;
   char message[MAX_ERROR_MESSAGE];
   size_t allocated;
   size_t index; /* instead of cur_ptr, index into the message array */
   char message[];
 } gfc_error_buf;
and then doing away with the pointer arithmetic would be simpler.

Otherwise this is ok.  How did you find the place where you inserted
gfc_free_error?  Is that list exhaustive?

- Tobi


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