if (r < 0)
return r;
- (void) table_sync_column_width(options, 0, verbs, 0);
+ (void) table_sync_column_widths(0, options, verbs);
printf("%s [OPTIONS...] COMMAND\n"
"\n%sMark the boot process as good or bad.%s\n"
return r;
/* Make the 1st column same width in both tables */
- (void) table_sync_column_width(options, 0, commands, 0);
+ (void) table_sync_column_widths(0, options, commands);
printf("%1$s [OPTIONS...] IMAGE\n"
"%1$s [OPTIONS...] --mount IMAGE PATH\n"
return r;
/* Make the 1st column same width in both tables */
- (void) table_sync_column_width(options, 0, verbs, 0);
+ (void) table_sync_column_widths(0, options, verbs);
printf("%s [OPTIONS...] COMMAND\n\n"
"%sGenerate and print 128-bit identifiers.%s\n"
return r;
}
-int table_sync_column_width(Table *a, size_t column_a, Table *b, size_t column_b) {
- size_t w1, w2;
- int r;
+int _table_sync_column_widths(size_t column, Table *a, ...) {
+ size_t max = 0;
+ va_list ap;
+ int r = 0;
assert(a);
- assert(b);
- /* Make both tables have specified columns of same width */
+ /* Make the specified column have the same width in the tables. */
- r = table_data_requested_width(a, column_a, &w1);
- if (r < 0)
- return log_error_errno(r, "Failed to query table column width: %m");
+ va_start(ap, a);
+ for (Table *t = a; t; t = va_arg(ap, Table*)) {
+ size_t w;
- r = table_data_requested_width(b, column_b, &w2);
+ r = table_data_requested_width(t, column, &w);
+ if (r < 0)
+ break;
+
+ max = MAX(max, w);
+ }
+ va_end(ap);
if (r < 0)
return log_error_errno(r, "Failed to query table column width: %m");
r = 0;
- RET_GATHER(r, table_set_column_width(a, column_a, MAX(w1, w2)));
- RET_GATHER(r, table_set_column_width(b, column_b, MAX(w1, w2)));
+ va_start(ap, a);
+ for (Table *t = a; t; t = va_arg(ap, Table*))
+ RET_GATHER(r, table_set_column_width(t, column, max));
+ va_end(ap);
+
return r;
}
int table_data_requested_width(Table *table, size_t column, size_t *ret);
int table_set_column_width(Table *t, size_t column, size_t width);
-int table_sync_column_width(Table *a, size_t column_a, Table *b, size_t column_b);
+int _table_sync_column_widths(size_t column, Table *a, ...);
+#define table_sync_column_widths(column, a, ...) _table_sync_column_widths(column, a, __VA_ARGS__, NULL)
int table_print(Table *t, FILE *f);
int table_format(Table *t, char **ret);