Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions src/listconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +592,9 @@ void listconf_parse_late(void)
if (!strcasecmp(options.listconf, "formats")) {
struct fmt_main *format;
int column = 0, dynamics = 0;
int grp_dyna, total = 0, add_comma = 0;
int grp_dyna, total = 0;
char *format_option = options.format ? options.format : options.format_list;
int stdout_is_pipe = !isatty(fileno(stdout));

grp_dyna = !format_option || (!strcasestr(format_option, "disabled") && !strcasestr(format_option, "dynamic"));

Expand All @@ -613,23 +614,23 @@ void listconf_parse_late(void)

length = strlen(label) + 2;
column += length;
if (add_comma)
if (total > 1 && !stdout_is_pipe)
printf(", ");
else
add_comma = 1;
if (column > 78) {
if (column > 78 || (total > 1 && stdout_is_pipe)) {
printf("\n");
column = length;
}
printf("%s", label);
} while ((format = format->next));
printf("\n");

fflush(stdout);
fprintf(stderr, "%d formats", total);
if (dynamics)
fprintf(stderr, " (%d dynamic formats shown as just \"dynamic_n\" here)", dynamics);
fprintf(stderr, "\n");
if (!stdout_is_pipe) {
fflush(stdout);
fprintf(stderr, "%d formats", total);
if (dynamics)
fprintf(stderr, " (%d dynamic formats shown as just \"dynamic_n\" here)", dynamics);
fprintf(stderr, "\n");
}

exit(EXIT_SUCCESS);
}
Expand Down