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]

[patch/mi] For MI case, suppress table output when no table rows


Hello,

This patch corresponds to the CLI patch that suppressed table output 
when there were no rows in the table.  For the moment it always 
suppresses output.  I'll later tweek things so that this only happens 
for mi0.

	Andrew
2001-06-21  Andrew Cagney  <ac131313@redhat.com>

	* mi-out.c (struct ui_out_data): Replace field first_header with
	suppress_output.
	(mi_begin, mi_end): Check suppress_header.
	(mi_field_int, mi_field_skip): Ditto.
	(mi_field_string, mi_field_fmt): Ditto.
	(mi_table_begin): When nr_rows is zero, set suppress_header else,
	output the start of the header.
	(mi_table_body): Clear suppress header.

Index: mi/mi-out.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-out.c,v
retrieving revision 1.17
diff -p -r1.17 mi-out.c
*** mi-out.c	2001/06/21 16:15:20	1.17
--- mi-out.c	2001/06/21 19:16:09
***************
*** 32,38 ****
  struct ui_out_data
    {
      int suppress_field_separator;
!     int first_header;
      int mi_version;
      struct ui_file *buffer;
    };
--- 32,38 ----
  struct ui_out_data
    {
      int suppress_field_separator;
!     int suppress_output;
      int mi_version;
      struct ui_file *buffer;
    };
*************** mi_table_begin (struct ui_out *uiout, in
*** 111,117 ****
  {
    struct ui_out_data *data = ui_out_data (uiout);
    mi_open (uiout, tblid, ui_out_type_tuple);
!   data->first_header = 0;
  }
  
  /* Mark beginning of a table body */
--- 111,122 ----
  {
    struct ui_out_data *data = ui_out_data (uiout);
    mi_open (uiout, tblid, ui_out_type_tuple);
!   if (nr_rows == 0)
!     {
!       data->suppress_output = 1;
!       return;
!     }
!   mi_open (uiout, "hdr", ui_out_type_tuple);
  }
  
  /* Mark beginning of a table body */
*************** mi_table_body (struct ui_out *uiout)
*** 121,128 ****
  {
    struct ui_out_data *data = ui_out_data (uiout);
    /* close the table header line if there were any headers */
!   if (data->first_header)
!     mi_close (uiout, ui_out_type_tuple);
  }
  
  /* Mark end of a table */
--- 126,134 ----
  {
    struct ui_out_data *data = ui_out_data (uiout);
    /* close the table header line if there were any headers */
!   if (data->suppress_output)
!     return;
!   mi_close (uiout, ui_out_type_tuple);
  }
  
  /* Mark end of a table */
*************** void
*** 131,136 ****
--- 137,143 ----
  mi_table_end (struct ui_out *uiout)
  {
    struct ui_out_data *data = ui_out_data (uiout);
+   data->suppress_output = 0;
    mi_close (uiout, ui_out_type_tuple);
  }
  
*************** mi_table_header (struct ui_out *uiout, i
*** 142,151 ****
  		 const char *colhdr)
  {
    struct ui_out_data *data = ui_out_data (uiout);
!   if (!data->first_header++)
!     {
!       mi_open (uiout, "hdr", ui_out_type_tuple);
!     }
    mi_field_string (uiout, 0, width, alignment, 0, colhdr);
  }
  
--- 149,156 ----
  		 const char *colhdr)
  {
    struct ui_out_data *data = ui_out_data (uiout);
!   if (data->suppress_output)
!     return;
    mi_field_string (uiout, 0, width, alignment, 0, colhdr);
  }
  
*************** mi_begin (struct ui_out *uiout,
*** 158,163 ****
--- 163,170 ----
  	  const char *id)
  {
    struct ui_out_data *data = ui_out_data (uiout);
+   if (data->suppress_output)
+     return;
    mi_open (uiout, id, type);
  }
  
*************** mi_end (struct ui_out *uiout,
*** 169,174 ****
--- 176,183 ----
  	int level)
  {
    struct ui_out_data *data = ui_out_data (uiout);
+   if (data->suppress_output)
+     return;
    mi_close (uiout, type);
  }
  
*************** mi_field_int (struct ui_out *uiout, int 
*** 179,184 ****
--- 188,196 ----
  	      const char *fldname, int value)
  {
    char buffer[20];		/* FIXME: how many chars long a %d can become? */
+   struct ui_out_data *data = ui_out_data (uiout);
+   if (data->suppress_output)
+     return;
  
    sprintf (buffer, "%d", value);
    mi_field_string (uiout, fldno, width, alignment, fldname, buffer);
*************** void
*** 190,195 ****
--- 202,210 ----
  mi_field_skip (struct ui_out *uiout, int fldno, int width, int alignment,
  	       const char *fldname)
  {
+   struct ui_out_data *data = ui_out_data (uiout);
+   if (data->suppress_output)
+     return;
    mi_field_string (uiout, fldno, width, alignment, fldname, "");
  }
  
*************** mi_field_string (struct ui_out *uiout,
*** 205,210 ****
--- 220,227 ----
  		 const char *string)
  {
    struct ui_out_data *data = ui_out_data (uiout);
+   if (data->suppress_output)
+     return;
    field_separator (uiout);
    if (fldname)
      fprintf_unfiltered (data->buffer, "%s=", fldname);
*************** mi_field_fmt (struct ui_out *uiout, int 
*** 224,229 ****
--- 241,248 ----
  	      va_list args)
  {
    struct ui_out_data *data = ui_out_data (uiout);
+   if (data->suppress_output)
+     return;
    field_separator (uiout);
    if (fldname)
      fprintf_unfiltered (data->buffer, "%s=\"", fldname);

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