ref: 3824eb5c056c2a823b3f6ae0324a79aec04c6b4c
parent: 8556fb693a23045c30ab6b7bf3949d3adc0cec46
author: rrt <rrt>
date: Sun Jan 21 14:38:31 EST 2007
Sort file format names, because sndfile.c has a whole bunch and hence throws the alphabetical order out. Display pseudo-formats too.
--- a/src/sox.c
+++ b/src/sox.c
@@ -1582,9 +1582,15 @@
}
}
+static int strcmp_p(const void *p1, const void *p2)
+{
+ return strcmp(*(const char **)p1, *(const char **)p2);
+}
+
static void usage(char const *message)
{
- int i;
+ size_t i, formats;
+ const char **format_list;
const st_effect_t *e;
printf("%s: ", myname);
@@ -1636,17 +1642,27 @@
"\n");
printf("Supported file formats:");
- for (i = 0; st_format_fns[i]; i++) {
- char const * const * names = st_format_fns[i]()->names;
- if (!(st_format_fns[i]()->flags & ST_FILE_PHONY))
- while (*names) printf(" %s", *names++);
+ for (i = 0, formats = 0; st_format_fns[i]; i++) {
+ char const * const *names = st_format_fns[i]()->names;
+ while (*names++)
+ formats++;
}
+ format_list = (const char **)xmalloc(formats * sizeof(char *));
+ for (i = 0, formats = 0; st_format_fns[i]; i++) {
+ char const * const *names = st_format_fns[i]()->names;
+ while (*names)
+ format_list[formats++] = *names++;
+ }
+ qsort(format_list, formats, sizeof(char *), strcmp_p);
+ for (i = 0; i < formats; i++)
+ printf(" %s", format_list[i]);
+ free(format_list);
- printf("\n\nSupported effects: ");
+ printf("\n\nSupported effects:");
for (i = 0; st_effect_fns[i]; i++) {
e = st_effect_fns[i]();
if (e && e->name)
- printf("%s ", e->name);
+ printf(" %s", e->name);
}
printf( "\n\neffopts: depends on effect\n");