MCPcopy Create free account
hub / github.com/apache/cloudberry / print_aligned_text

Function print_aligned_text

src/fe_utils/print.c:564–1152  ·  view source on GitHub ↗

* Print pretty boxes around cells. */

Source from the content-addressed store, hash-verified

562 * Print pretty boxes around cells.
563 */
564static void
565print_aligned_text(const printTableContent *cont, FILE *fout, bool is_pager)
566{
567 bool opt_tuples_only = cont->opt->tuples_only;
568 int encoding = cont->opt->encoding;
569 unsigned short opt_border = cont->opt->border;
570 const printTextFormat *format = get_line_style(cont->opt);
571 const printTextLineFormat *dformat = &format->lrule[PRINT_RULE_DATA];
572
573 unsigned int col_count = 0,
574 cell_count = 0;
575
576 unsigned int i,
577 j;
578
579 unsigned int *width_header,
580 *max_width,
581 *width_wrap,
582 *width_average;
583 unsigned int *max_nl_lines, /* value split by newlines */
584 *curr_nl_line,
585 *max_bytes;
586 unsigned char **format_buf;
587 unsigned int width_total;
588 unsigned int total_header_width;
589 unsigned int extra_row_output_lines = 0;
590 unsigned int extra_output_lines = 0;
591
592 const char *const *ptr;
593
594 struct lineptr **col_lineptrs; /* pointers to line pointer per column */
595
596 bool *header_done; /* Have all header lines been output? */
597 int *bytes_output; /* Bytes output for column value */
598 printTextLineWrap *wrap; /* Wrap status for each column */
599 int output_columns = 0; /* Width of interactive console */
600 bool is_local_pager = false;
601
602 if (cancel_pressed)
603 return;
604
605 if (opt_border > 2)
606 opt_border = 2;
607
608 if (cont->ncolumns > 0)
609 {
610 col_count = cont->ncolumns;
611 width_header = pg_malloc0(col_count * sizeof(*width_header));
612 width_average = pg_malloc0(col_count * sizeof(*width_average));
613 max_width = pg_malloc0(col_count * sizeof(*max_width));
614 width_wrap = pg_malloc0(col_count * sizeof(*width_wrap));
615 max_nl_lines = pg_malloc0(col_count * sizeof(*max_nl_lines));
616 curr_nl_line = pg_malloc0(col_count * sizeof(*curr_nl_line));
617 col_lineptrs = pg_malloc0(col_count * sizeof(*col_lineptrs));
618 max_bytes = pg_malloc0(col_count * sizeof(*max_bytes));
619 format_buf = pg_malloc0(col_count * sizeof(*format_buf));
620 header_done = pg_malloc0(col_count * sizeof(*header_done));
621 bytes_output = pg_malloc0(col_count * sizeof(*bytes_output));

Callers 1

printTableFunction · 0.85

Calls 12

get_line_styleFunction · 0.85
pg_malloc0Function · 0.85
pg_wcssizeFunction · 0.85
pg_mallocFunction · 0.85
print_aligned_verticalFunction · 0.85
PageOutputFunction · 0.85
IsPagerNeededFunction · 0.85
_print_horizontal_lineFunction · 0.85
pg_wcsformatFunction · 0.85
strlen_max_widthFunction · 0.85
footers_with_defaultFunction · 0.85
ClosePagerFunction · 0.85

Tested by

no test coverage detected