contrib/gdb-7/gdb/utils.c
static void
fputs_maybe_filtered (const char *linebuffer, struct ui_file *stream,
		      int filter)
{
  const char *lineptr;

  if (linebuffer == 0)
    return;

  /* Don't do any filtering if it is disabled.  */
  if (stream != gdb_stdout
      || !pagination_enabled
      || batch_flag
      || (lines_per_page == UINT_MAX && chars_per_line == UINT_MAX)
      || top_level_interpreter () == NULL
      || ui_out_is_mi_like_p (interp_ui_out (top_level_interpreter ())))
    {
      fputs_unfiltered (linebuffer, stream);
      return;
    }

  /* Go through and output each character.  Show line extension
     when this is necessary; prompt user for new page when this is
     necessary.  */

  lineptr = linebuffer;
  while (*lineptr)
    {
      /* Possible new page.  */
      if (filter && (lines_printed >= lines_per_page - 1))
	prompt_for_continue ();

      while (*lineptr && *lineptr != '\n')
	{
	  /* Print a single line.  */
	  if (*lineptr == '\t')
	    {
	      if (wrap_column)
		*wrap_pointer++ = '\t';
	      else
		fputc_unfiltered ('\t', stream);
	      /* Shifting right by 3 produces the number of tab stops
	         we have already passed, and then adding one and
	         shifting left 3 advances to the next tab stop.  */
	      chars_printed = ((chars_printed >> 3) + 1) << 3;
	      lineptr++;
	    }
	  else
	    {
	      if (wrap_column)
		*wrap_pointer++ = *lineptr;
	      else
		fputc_unfiltered (*lineptr, stream);
	      chars_printed++;
	      lineptr++;
	    }

	  if (chars_printed >= chars_per_line)
	    {
	      unsigned int save_chars = chars_printed;

	      chars_printed = 0;
	      lines_printed++;
	      /* If we aren't actually wrapping, don't output newline --
	         if chars_per_line is right, we probably just overflowed
	         anyway; if it's wrong, let us keep going.  */
	      if (wrap_column)
		fputc_unfiltered ('\n', stream);

	      /* Possible new page.  */
	      if (lines_printed >= lines_per_page - 1)
		prompt_for_continue ();

	      /* Now output indentation and wrapped string.  */
	      if (wrap_column)
		{
		  fputs_unfiltered (wrap_indent, stream);
		  *wrap_pointer = '\0';	/* Null-terminate saved stuff, */
		  fputs_unfiltered (wrap_buffer, stream); /* and eject it.  */
		  /* FIXME, this strlen is what prevents wrap_indent from
		     containing tabs.  However, if we recurse to print it
		     and count its chars, we risk trouble if wrap_indent is
		     longer than (the user settable) chars_per_line.
		     Note also that this can set chars_printed > chars_per_line
		     if we are printing a long string.  */
		  chars_printed = strlen (wrap_indent)
		    + (save_chars - wrap_column);
		  wrap_pointer = wrap_buffer;	/* Reset buffer */
		  wrap_buffer[0] = '\0';
		  wrap_column = 0;	/* And disable fancy wrap */
		}
	    }
	}

      if (*lineptr == '\n')
	{
	  chars_printed = 0;
	  wrap_here ((char *) 0);	/* Spit out chars, cancel
					   further wraps.  */
	  lines_printed++;
	  fputc_unfiltered ('\n', stream);
	  lineptr++;
	}
    }
}
/* Like fputs but if FILTER is true, pause after every screenful.

   Regardless of FILTER can wrap at points other than the final
   character of a line.

   Unlike fputs, fputs_maybe_filtered does not return a value.
   It is OK for LINEBUFFER to be NULL, in which case just don't print
   anything.

   Note that a longjmp to top level may occur in this routine (only if
   FILTER is true) (since prompt_for_continue may do so) so this
   routine should not be called when cleanups are not in place.  */
Like fputs but if FILTER is true, pause after every screenful.
Regardless of FILTER can wrap at points other than the final
character of a line.

Unlike fputs, fputs_maybe_filtered does not return a value.
It is OK for LINEBUFFER to be NULL, in which case just don't print
anything.

Note that a longjmp to top level may occur in this routine (only if
FILTER is true) (since prompt_for_continue may do so) so this
routine should not be called when cleanups are not in place.
Like fputs but if FILTER is true pause after every screenful . Regardless of FILTER can wrap at points other than the final character of a line . Unlike fputs fputs_maybe_filtered does not return a value . It is OK for LINEBUFFER to be NULL in which case just don ' t print anything . Note that a longjmp to top level may occur in this routine ( only if FILTER is true ) ( since prompt_for_continue may do so ) so this routine should not be called when cleanups are not in place .
static void
fputs_maybe_filtered (const char *linebuffer, struct ui_file *stream,
		      int filter)
{
  const char *lineptr;
  if (linebuffer == 0)
    return;
  if (stream != gdb_stdout
      || !pagination_enabled
      || batch_flag
      || (lines_per_page == UINT_MAX && chars_per_line == UINT_MAX)
      || top_level_interpreter () == NULL
      || ui_out_is_mi_like_p (interp_ui_out (top_level_interpreter ())))
    {
      fputs_unfiltered (linebuffer, stream);
      return;
    }
  lineptr = linebuffer;
  while (*lineptr)
    {
      if (filter && (lines_printed >= lines_per_page - 1))
	prompt_for_continue ();
      while (*lineptr && *lineptr != '\n')
	{
	  if (*lineptr == '\t')
	    {
	      if (wrap_column)
		*wrap_pointer++ = '\t';
	      else
		fputc_unfiltered ('\t', stream);
	      chars_printed = ((chars_printed >> 3) + 1) << 3;
	      lineptr++;
	    }
	  else
	    {
	      if (wrap_column)
		*wrap_pointer++ = *lineptr;
	      else
		fputc_unfiltered (*lineptr, stream);
	      chars_printed++;
	      lineptr++;
	    }
	  if (chars_printed >= chars_per_line)
	    {
	      unsigned int save_chars = chars_printed;
	      chars_printed = 0;
	      lines_printed++;
	      if (wrap_column)
		fputc_unfiltered ('\n', stream);
	      if (lines_printed >= lines_per_page - 1)
		prompt_for_continue ();
	      if (wrap_column)
		{
		  fputs_unfiltered (wrap_indent, stream);
		  *wrap_pointer = '\0';	
		  fputs_unfiltered (wrap_buffer, stream); 
		  chars_printed = strlen (wrap_indent)
		    + (save_chars - wrap_column);
		  wrap_pointer = wrap_buffer;	
		  wrap_buffer[0] = '\0';
		  wrap_column = 0;	
		}
	    }
	}
      if (*lineptr == '\n')
	{
	  chars_printed = 0;
	  wrap_here ((char *) 0);	
	  lines_printed++;
	  fputc_unfiltered ('\n', stream);
	  lineptr++;
	}
    }
}
static void fputs_maybe_filtered ( const char * linebuffer , struct ui_file * stream , int filter ) { const char * lineptr ; if ( linebuffer == 0 ) return ; if ( stream != gdb_stdout || ! pagination_enabled || batch_flag || ( lines_per_page == UINT_MAX && chars_per_line == UINT_MAX ) || top_level_interpreter ( ) == NULL || ui_out_is_mi_like_p ( interp_ui_out ( top_level_interpreter ( ) ) ) ) { fputs_unfiltered ( linebuffer , stream ) ; return ; } lineptr = linebuffer ; while ( * lineptr ) { if ( filter && ( lines_printed >= lines_per_page - 1 ) ) prompt_for_continue ( ) ; while ( * lineptr && * lineptr != ' \n ' ) { if ( * lineptr == ' \t ' ) { if ( wrap_column ) * wrap_pointer ++ = ' \t ' ; else fputc_unfiltered ( ' \t ' , stream ) ; chars_printed = ( ( chars_printed >> 3 ) + 1 ) << 3 ; lineptr ++ ; } else { if ( wrap_column ) * wrap_pointer ++ = * lineptr ; else fputc_unfiltered ( * lineptr , stream ) ; chars_printed ++ ; lineptr ++ ; } if ( chars_printed >= chars_per_line ) { unsigned int save_chars = chars_printed ; chars_printed = 0 ; lines_printed ++ ; if ( wrap_column ) fputc_unfiltered ( ' \n ' , stream ) ; if ( lines_printed >= lines_per_page - 1 ) prompt_for_continue ( ) ; if ( wrap_column ) { fputs_unfiltered ( wrap_indent , stream ) ; * wrap_pointer = ' \0 ' ; fputs_unfiltered ( wrap_buffer , stream ) ; chars_printed = strlen ( wrap_indent ) + ( save_chars - wrap_column ) ; wrap_pointer = wrap_buffer ; wrap_buffer [ 0 ] = ' \0 ' ; wrap_column = 0 ; } } } if ( * lineptr == ' \n ' ) { chars_printed = 0 ; wrap_here ( ( char * ) 0 ) ; lines_printed ++ ; fputc_unfiltered ( ' \n ' , stream ) ; lineptr ++ ; } } }
Like fputs but if FILTER is true, pause after every screenful.
Like fputs but if FILTER is true pause after every screenful .
/* Don't do any filtering if it is disabled.  */ /* Go through and output each character.  Show line extension
     when this is necessary; prompt user for new page when this is
     necessary.  */ /* Possible new page.  */ /* Print a single line.  */ /* Shifting right by 3 produces the number of tab stops
	         we have already passed, and then adding one and
	         shifting left 3 advances to the next tab stop.  */ /* If we aren't actually wrapping, don't output newline --
	         if chars_per_line is right, we probably just overflowed
	         anyway; if it's wrong, let us keep going.  */ /* Possible new page.  */ /* Now output indentation and wrapped string.  */ /* Null-terminate saved stuff, */ /* and eject it.  */ /* FIXME, this strlen is what prevents wrap_indent from
		     containing tabs.  However, if we recurse to print it
		     and count its chars, we risk trouble if wrap_indent is
		     longer than (the user settable) chars_per_line.
		     Note also that this can set chars_printed > chars_per_line
		     if we are printing a long string.  */ /* Reset buffer */ /* And disable fancy wrap */ /* Spit out chars, cancel
					   further wraps.  */