MCPcopy Create free account
hub / github.com/coreutils/coreutils / print_table

Function print_table

src/df.c:378–406  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

376 alignment and max width of each column. */
377
378static void
379print_table (void)
380{
381 for (idx_t row = 0; row < nrows; row++)
382 {
383 for (idx_t col = 0; col < ncolumns; col++)
384 {
385 char *cell = table[row][col];
386
387 /* Note the SOURCE_FIELD used to be displayed on it's own line
388 if (!posix_format && mbswidth (cell) > 20), but that
389 functionality was probably more problematic than helpful,
390 hence changed in commit v8.10-40-g99679ff. */
391 if (col != 0)
392 putchar (' ');
393
394 int width = mbswidth (cell, MBSWIDTH_FLAGS);
395 int fill = width < 0 ? 0 : columns[col]->width - width;
396 if (columns[col]->align_right)
397 for (; 0 < fill; fill--)
398 putchar (' ');
399 fputs (cell, stdout);
400 if (col + 1 < ncolumns)
401 for (; 0 < fill; fill--)
402 putchar (' ');
403 }
404 putchar ('\n');
405 }
406}
407
408/* Dynamically allocate a struct field_t in COLUMNS, which
409 can then be accessed with standard array notation. */

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected