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]

PATCH to diagnostics library



This bit corrects a thinko in the diagnostics library options and adds
sort-of indentation in line-wrapping mode.

Bootstrapped and tested on i686-pc-linux.  No regression.  Installed.

-- Gaby
CodeSourcery, LLC		http://www.codesourcery.com

2000-09-06  Gabriel Dos Reis  <gdr@codesourcery.com>

	* toplev.c (display_help): Fix thinko in documentation.

	* diagnostic.h (output_buffer::indent_skip): New fields.
	(output_indentation): New macro.

	* diagnostic.c (output_indent): New function.
	(output_set_prefix, clear_diagnostic_info): Use.
	(output_emit_prefix): Predict future indentation.

Index: toplev.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/toplev.c,v
retrieving revision 1.374
diff -c -p -r1.374 toplev.c
*** toplev.c	2000/09/01 01:03:29	1.374
--- toplev.c	2000/09/06 18:31:00
*************** display_help ()
*** 3774,3780 ****
    printf (_("  -fcall-saved-<register> Mark <register> as being preserved across functions\n"));
    printf (_("  -finline-limit=<number> Limits the size of inlined functions to <number>\n"));
    printf (_("  -fmessage-length=<number> Limits diagnostics messages lengths to <number> characters per line.  0 suppresses line-wrapping\n"));
!   printf (_("  -fdiagnostics-show-location=[once | never] Indicates how often source location information should be emitted, as prefix, at the beginning of diagnostics when line-wrapping\n"));
  
    for (i = ARRAY_SIZE (f_options); i--;)
      {
--- 3774,3780 ----
    printf (_("  -fcall-saved-<register> Mark <register> as being preserved across functions\n"));
    printf (_("  -finline-limit=<number> Limits the size of inlined functions to <number>\n"));
    printf (_("  -fmessage-length=<number> Limits diagnostics messages lengths to <number> characters per line.  0 suppresses line-wrapping\n"));
!   printf (_("  -fdiagnostics-show-location=[once | every-line] Indicates how often source location information should be emitted, as prefix, at the beginning of diagnostics when line-wrapping\n"));
  
    for (i = ARRAY_SIZE (f_options); i--;)
      {
Index: diagnostic.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/diagnostic.h,v
retrieving revision 1.14
diff -c -p -r1.14 diagnostic.h
*** diagnostic.h	2000/08/24 08:30:01	1.14
--- diagnostic.h	2000/09/06 18:31:01
*************** typedef struct
*** 51,56 ****
--- 51,60 ----
    /* The ideal upper bound of number of characters per line, as suggested
       by front-end. */  
    int ideal_maximum_length;
+ 
+   /* Indentation count.  */
+   int indent_skip;
+ 
    /* Nonzero if current PREFIX was emitted at least once.  */
    int emitted_prefix_p;
  
*************** struct output_buffer
*** 88,93 ****
--- 92,98 ----
  #define output_buffer_format_args(BUFFER) *((BUFFER)->state.format_args)
  #define output_needs_newline(BUFFER) (BUFFER)->state.need_newline_p
  #define output_buffer_state(BUFFER) (BUFFER)->state
+ #define output_indentation(BUFFER) (BUFFER)->state.indent_skip
  
  /* This data structure bundles altogether any information relevent to
     the context of a diagnostic message.  */
Index: diagnostic.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/diagnostic.c,v
retrieving revision 1.34
diff -c -p -r1.34 diagnostic.c
*** diagnostic.c	2000/08/24 08:30:01	1.34
--- diagnostic.c	2000/09/06 18:31:01
*************** static void output_do_verbatim PARAMS ((
*** 67,72 ****
--- 67,73 ----
                                          const char *, va_list *));
  static void output_to_stream PARAMS ((output_buffer *, FILE *));
  static void output_format PARAMS ((output_buffer *));
+ static void output_indent PARAMS ((output_buffer *));
  
  static char *vbuild_message_string PARAMS ((const char *, va_list));
  static char *build_message_string PARAMS ((const char *, ...))
*************** output_set_prefix (buffer, prefix)
*** 267,272 ****
--- 268,274 ----
    output_prefix (buffer) = prefix;
    set_real_maximum_length (buffer);
    prefix_was_emitted_for (buffer) = 0;
+   output_indentation (buffer) = 0;
  }
  
  /* Free BUFFER's prefix, a previously malloc'd string.  */
*************** clear_diagnostic_info (buffer)
*** 301,306 ****
--- 303,309 ----
    output_buffer_text_cursor (buffer) = NULL;
    output_buffer_ptr_to_format_args (buffer) = NULL;
    prefix_was_emitted_for (buffer) = 0;
+   output_indentation (buffer) = 0;
  }
  
  /* Construct an output BUFFER with PREFIX and of MAXIMUM_LENGTH
*************** output_emit_prefix (buffer)
*** 395,402 ****
  
          case DIAGNOSTICS_SHOW_PREFIX_ONCE:
            if (prefix_was_emitted_for (buffer))
!             break;
!           /* Else fall through.  */
  
          case DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE:
            {
--- 398,409 ----
  
          case DIAGNOSTICS_SHOW_PREFIX_ONCE:
            if (prefix_was_emitted_for (buffer))
!             {
!               output_indent (buffer);
!               break;
!             }
!           output_indentation (buffer) += 3;          
!           /* Fall through.  */
  
          case DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE:
            {
*************** output_append (buffer, start, end)
*** 547,552 ****
--- 554,570 ----
            ++start;
      }
    output_append_r (buffer, start, end - start);
+ }
+ 
+ static void
+ output_indent (buffer)
+      output_buffer *buffer;
+ {
+   int n = output_indentation (buffer);
+   int i;
+ 
+   for (i = 0; i < n; ++i)
+     output_add_character (buffer, ' ');
  }
  
  /* Wrap a text delimited by START and END into BUFFER.  */
       http://www.codesourcery.com/gcc-compile.shtml

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