contrib/gdb-7/gdb/utils.c
void
puts_debug (char *prefix, char *string, char *suffix)
{
  int ch;

  /* Print prefix and suffix after each line.  */
  static int new_line = 1;
  static int return_p = 0;
  static char *prev_prefix = "";
  static char *prev_suffix = "";

  if (*string == '\n')
    return_p = 0;

  /* If the prefix is changing, print the previous suffix, a new line,
     and the new prefix.  */
  if ((return_p || (strcmp (prev_prefix, prefix) != 0)) && !new_line)
    {
      fputs_unfiltered (prev_suffix, gdb_stdlog);
      fputs_unfiltered ("\n", gdb_stdlog);
      fputs_unfiltered (prefix, gdb_stdlog);
    }

  /* Print prefix if we printed a newline during the previous call.  */
  if (new_line)
    {
      new_line = 0;
      fputs_unfiltered (prefix, gdb_stdlog);
    }

  prev_prefix = prefix;
  prev_suffix = suffix;

  /* Output characters in a printable format.  */
  while ((ch = *string++) != '\0')
    {
      switch (ch)
	{
	default:
	  if (isprint (ch))
	    fputc_unfiltered (ch, gdb_stdlog);

	  else
	    fprintf_unfiltered (gdb_stdlog, "\\x%02x", ch & 0xff);
	  break;

	case '\\':
	  fputs_unfiltered ("\\\\", gdb_stdlog);
	  break;
	case '\b':
	  fputs_unfiltered ("\\b", gdb_stdlog);
	  break;
	case '\f':
	  fputs_unfiltered ("\\f", gdb_stdlog);
	  break;
	case '\n':
	  new_line = 1;
	  fputs_unfiltered ("\\n", gdb_stdlog);
	  break;
	case '\r':
	  fputs_unfiltered ("\\r", gdb_stdlog);
	  break;
	case '\t':
	  fputs_unfiltered ("\\t", gdb_stdlog);
	  break;
	case '\v':
	  fputs_unfiltered ("\\v", gdb_stdlog);
	  break;
	}

      return_p = ch == '\r';
    }

  /* Print suffix if we printed a newline.  */
  if (new_line)
    {
      fputs_unfiltered (suffix, gdb_stdlog);
      fputs_unfiltered ("\n", gdb_stdlog);
    }
}
/* puts_debug is like fputs_unfiltered, except it prints special
   characters in printable fashion.  */
puts_debug is like fputs_unfiltered, except it prints special
characters in printable fashion.
puts_debug is like fputs_unfiltered except it prints special characters in printable fashion .
void
puts_debug (char *prefix, char *string, char *suffix)
{
  int ch;
  static int new_line = 1;
  static int return_p = 0;
  static char *prev_prefix = "";
  static char *prev_suffix = "";
  if (*string == '\n')
    return_p = 0;
  if ((return_p || (strcmp (prev_prefix, prefix) != 0)) && !new_line)
    {
      fputs_unfiltered (prev_suffix, gdb_stdlog);
      fputs_unfiltered ("\n", gdb_stdlog);
      fputs_unfiltered (prefix, gdb_stdlog);
    }
  if (new_line)
    {
      new_line = 0;
      fputs_unfiltered (prefix, gdb_stdlog);
    }
  prev_prefix = prefix;
  prev_suffix = suffix;
  while ((ch = *string++) != '\0')
    {
      switch (ch)
	{
	default:
	  if (isprint (ch))
	    fputc_unfiltered (ch, gdb_stdlog);
	  else
	    fprintf_unfiltered (gdb_stdlog, "\\x%02x", ch & 0xff);
	  break;
	case '\\':
	  fputs_unfiltered ("\\\\", gdb_stdlog);
	  break;
	case '\b':
	  fputs_unfiltered ("\\b", gdb_stdlog);
	  break;
	case '\f':
	  fputs_unfiltered ("\\f", gdb_stdlog);
	  break;
	case '\n':
	  new_line = 1;
	  fputs_unfiltered ("\\n", gdb_stdlog);
	  break;
	case '\r':
	  fputs_unfiltered ("\\r", gdb_stdlog);
	  break;
	case '\t':
	  fputs_unfiltered ("\\t", gdb_stdlog);
	  break;
	case '\v':
	  fputs_unfiltered ("\\v", gdb_stdlog);
	  break;
	}
      return_p = ch == '\r';
    }
  if (new_line)
    {
      fputs_unfiltered (suffix, gdb_stdlog);
      fputs_unfiltered ("\n", gdb_stdlog);
    }
}
void puts_debug ( char * prefix , char * string , char * suffix ) { int ch ; static int new_line = 1 ; static int return_p = 0 ; static char * prev_prefix = " " ; static char * prev_suffix = " " ; if ( * string == ' \n ' ) return_p = 0 ; if ( ( return_p || ( strcmp ( prev_prefix , prefix ) != 0 ) ) && ! new_line ) { fputs_unfiltered ( prev_suffix , gdb_stdlog ) ; fputs_unfiltered ( " \n " , gdb_stdlog ) ; fputs_unfiltered ( prefix , gdb_stdlog ) ; } if ( new_line ) { new_line = 0 ; fputs_unfiltered ( prefix , gdb_stdlog ) ; } prev_prefix = prefix ; prev_suffix = suffix ; while ( ( ch = * string ++ ) != ' \0 ' ) { switch ( ch ) { default : if ( isprint ( ch ) ) fputc_unfiltered ( ch , gdb_stdlog ) ; else fprintf_unfiltered ( gdb_stdlog , " \\ " , ch & 0xff ) ; break ; case ' \\ ' : fputs_unfiltered ( " \\ \\ " , gdb_stdlog ) ; break ; case ' \b ' : fputs_unfiltered ( " \\ " , gdb_stdlog ) ; break ; case ' \f ' : fputs_unfiltered ( " \\ " , gdb_stdlog ) ; break ; case ' \n ' : new_line = 1 ; fputs_unfiltered ( " \\ " , gdb_stdlog ) ; break ; case ' \r ' : fputs_unfiltered ( " \\ " , gdb_stdlog ) ; break ; case ' \t ' : fputs_unfiltered ( " \\ " , gdb_stdlog ) ; break ; case ' \v ' : fputs_unfiltered ( " \\ " , gdb_stdlog ) ; break ; } return_p = ch == ' \r ' ; } if ( new_line ) { fputs_unfiltered ( suffix , gdb_stdlog ) ; fputs_unfiltered ( " \n " , gdb_stdlog ) ; } }
puts_debug is like fputs_unfiltered, except it prints special
characters in printable fashion.
puts_debug is like fputs_unfiltered except it prints special characters in printable fashion .
/* Print prefix and suffix after each line.  */ /* If the prefix is changing, print the previous suffix, a new line,
     and the new prefix.  */ /* Print prefix if we printed a newline during the previous call.  */ /* Output characters in a printable format.  */ /* Print suffix if we printed a newline.  */