| 376 | alignment and max width of each column. */ |
| 377 | |
| 378 | static void |
| 379 | print_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. */ |