contrib/gdb-7/gdb/utils.c
void
puts_filtered_tabular (char *string, int width, int right)
{
  int spaces = 0;
  int stringlen;
  char *spacebuf;

  gdb_assert (chars_per_line > 0);
  if (chars_per_line == UINT_MAX)
    {
      fputs_filtered (string, gdb_stdout);
      fputs_filtered ("\n", gdb_stdout);
      return;
    }

  if (((chars_printed - 1) / width + 2) * width >= chars_per_line)
    fputs_filtered ("\n", gdb_stdout);

  if (width >= chars_per_line)
    width = chars_per_line - 1;

  stringlen = strlen (string);

  if (chars_printed > 0)
    spaces = width - (chars_printed - 1) % width - 1;
  if (right)
    spaces += width - stringlen;

  spacebuf = alloca (spaces + 1);
  spacebuf[spaces] = '\0';
  while (spaces--)
    spacebuf[spaces] = ' ';

  fputs_filtered (spacebuf, gdb_stdout);
  fputs_filtered (string, gdb_stdout);
}
/* Print input string to gdb_stdout, filtered, with wrap, 
   arranging strings in columns of n chars.  String can be
   right or left justified in the column.  Never prints 
   trailing spaces.  String should never be longer than
   width.  FIXME: this could be useful for the EXAMINE 
   command, which currently doesn't tabulate very well.  */
Print input string to gdb_stdout, filtered, with wrap,
arranging strings in columns of n chars.  String can be
right or left justified in the column.  Never prints
trailing spaces.  String should never be longer than
width.  FIXME: this could be useful for the EXAMINE
command, which currently doesn't tabulate very well.
Print input string to gdb_stdout filtered with wrap arranging strings in columns of n chars . String can be right or left justified in the column . Never prints trailing spaces . String should never be longer than width . FIXME : this could be useful for the EXAMINE command which currently doesn ' t tabulate very well .
void
puts_filtered_tabular (char *string, int width, int right)
{
  int spaces = 0;
  int stringlen;
  char *spacebuf;
  gdb_assert (chars_per_line > 0);
  if (chars_per_line == UINT_MAX)
    {
      fputs_filtered (string, gdb_stdout);
      fputs_filtered ("\n", gdb_stdout);
      return;
    }
  if (((chars_printed - 1) / width + 2) * width >= chars_per_line)
    fputs_filtered ("\n", gdb_stdout);
  if (width >= chars_per_line)
    width = chars_per_line - 1;
  stringlen = strlen (string);
  if (chars_printed > 0)
    spaces = width - (chars_printed - 1) % width - 1;
  if (right)
    spaces += width - stringlen;
  spacebuf = alloca (spaces + 1);
  spacebuf[spaces] = '\0';
  while (spaces--)
    spacebuf[spaces] = ' ';
  fputs_filtered (spacebuf, gdb_stdout);
  fputs_filtered (string, gdb_stdout);
}
void puts_filtered_tabular ( char * string , int width , int right ) { int spaces = 0 ; int stringlen ; char * spacebuf ; gdb_assert ( chars_per_line > 0 ) ; if ( chars_per_line == UINT_MAX ) { fputs_filtered ( string , gdb_stdout ) ; fputs_filtered ( " \n " , gdb_stdout ) ; return ; } if ( ( ( chars_printed - 1 ) / width + 2 ) * width >= chars_per_line ) fputs_filtered ( " \n " , gdb_stdout ) ; if ( width >= chars_per_line ) width = chars_per_line - 1 ; stringlen = strlen ( string ) ; if ( chars_printed > 0 ) spaces = width - ( chars_printed - 1 ) % width - 1 ; if ( right ) spaces += width - stringlen ; spacebuf = alloca ( spaces + 1 ) ; spacebuf [ spaces ] = ' \0 ' ; while ( spaces -- ) spacebuf [ spaces ] = ' ' ; fputs_filtered ( spacebuf , gdb_stdout ) ; fputs_filtered ( string , gdb_stdout ) ; }
Print input string to gdb_stdout, filtered, with wrap,
arranging strings in columns of n chars.
Print input string to gdb_stdout filtered with wrap arranging strings in columns of n chars .