ref: bf3310d56996e07243fba7e3f1472329c25c80b2
parent: d60b2b3e283ac27a4637497c15b72633fea50106
author: cbagwell <cbagwell>
date: Sun Aug 27 19:48:49 EDT 2006
Added --version flag
--- a/sox.1
+++ b/sox.1
@@ -140,6 +140,9 @@
Print status while processing audio data. Tells how much of audio data has been
processed in terms of audio running time instead of samples.
.TP 10
+\fB--version\fR
+Print version number and exit.
+.TP 10
\fB-V\fR
Print a description of processing phases.
Useful for figuring out exactly how
--- a/sox.txt
+++ b/sox.txt
@@ -109,6 +109,8 @@
audio data has been processed in terms of audio running time
instead of samples.
+ --version Print version number and exit.
+
-V Print a description of processing phases. Useful for figur-
ing out exactly how SoX
@@ -879,8 +881,8 @@
This means progressively sharper stop-band rejection, at pro-
portionally slower execution times.
- rolloff refers to the cut-off frequency of the low pass fil-
- ter and is given in terms of the Nyquist frequency for the
+ rolloff refers to the cut-off frequency of the low pass
+ filter and is given in terms of the Nyquist frequency for the
lower sample rate. rolloff therefore should be something
between 0.0 and 1.0, in practice 0.8-0.95. The defaults are
indicated above.
--- a/src/misc.c
+++ b/src/misc.c
@@ -481,7 +481,7 @@
{
static char versionstr[20];
- sprintf(versionstr, "Version %d.%d.%d",
+ sprintf(versionstr, "%d.%d.%d",
(ST_LIB_VERSION_CODE & 0xff0000) >> 16,
(ST_LIB_VERSION_CODE & 0x00ff00) >> 8,
(ST_LIB_VERSION_CODE & 0x0000ff));
--- a/src/sox.c
+++ b/src/sox.c
@@ -280,7 +280,7 @@
static struct option long_options[] =
{
- {"version", 0, NULL, 'V'},
+ {"version", 0, NULL, 0},
{"help", 0, NULL, 'h'},
{"help-effect", 1, NULL, 0},
{NULL, 0, NULL, 0}
@@ -299,6 +299,13 @@
if (strncmp("help-effect", long_options[option_index].name,
11) == 0)
usage_effect(optarg);
+ else if (strncmp("version", long_options[option_index].name,
+ 7) == 0)
+ {
+ printf("%s: ", myname);
+ printf("v%s\n", st_version());
+ exit(0);
+ }
/* no return from above */
break;
@@ -1597,16 +1604,15 @@
{
int i;
- fprintf(stderr, "%s: ", myname);
- fprintf(stderr, "%s\n\n", st_version());
+ printf("%s: ", myname);
+ printf("Version %s\n\n", st_version());
if (opt)
fprintf(stderr, "Failed: %s\n\n", opt);
- fprintf(stderr, "Usage: %s\n\n", usagestr);
- fprintf(stderr,
+ printf("Usage: %s\n\n", usagestr);
+ printf(
"Global options (gopts):\n"
"\n"
-"Global options can be specified anywhere on the command and\n"
-"are applied globally.\n"
+"Global options can be specified anywhere on the command\n"
"\n"
"-h print version number and usage information\n"
"--help same as -h\n"
@@ -1615,12 +1621,13 @@
"-p run in preview mode and run fast\n"
"-q run in quite mode. Inverse of -S option\n"
"-S print status while processing audio data.\n"
+"--version print version number of SoX and exit\n"
"-V verbose mode. print a description during processing phase\n"
"\n"
"Format options (fopts):\n"
"\n"
"Format options only need to be supplied on input files that are\n"
-"headerless otherwise they are obtained from the audio datas header.\n"
+"headerless otherwise they are obtained from the audio data's header.\n"
"Output files will default to the same format options as the input\n"
"file unless overriden on the command line.\n"
"\n"
@@ -1637,19 +1644,18 @@
" long(32-bits)/double long(64-bits)\n"
"\n");
- fprintf(stderr, "Supported file formats: ");
+ printf("Supported file formats: ");
for (i = 0; st_formats[i]->names != NULL; i++) {
/* only print the first name */
- fprintf(stderr, "%s ", st_formats[i]->names[0]);
+ printf("%s ", st_formats[i]->names[0]);
}
- fprintf(stderr, "\n\nSupported effects: ");
+ printf("\n\nSupported effects: ");
for (i = 0; st_effects[i]->name != NULL; i++) {
- fprintf(stderr, "%s ", st_effects[i]->name);
+ printf("%s ", st_effects[i]->name);
}
- fprintf(stderr, "\n\neffopts: depends on effect\n");
- fputc('\n', stderr);
+ printf( "\n\neffopts: depends on effect\n\n");
exit(1);
}
@@ -1657,20 +1663,20 @@
{
int i;
- fprintf(stderr, "%s: ", myname);
- fprintf(stderr, "%s\n\n", st_version());
+ printf("%s: ", myname);
+ printf("v%s\n\n", st_version());
- fprintf(stderr, "Effect usage:\n\n");
+ printf("Effect usage:\n\n");
for (i = 0; st_effects[i]->name != NULL; i++)
if (!strcmp ("all", effect) || !strcmp (st_effects[i]->name, effect))
{
- char *p = strstr (st_effects[i]->usage, "Usage: ");
- fprintf (stderr, "%s\n\n", p ? p + 7 : st_effects[i]->usage);
+ char *p = strstr(st_effects[i]->usage, "Usage: ");
+ printf("%s\n\n", p ? p + 7 : st_effects[i]->usage);
}
if (!effect)
- fprintf (stderr, "see --help-effect=effect for effopts (all for effopts of all effects)\n\n");
+ printf("see --help-effect=effect for effopts ('all' for effopts of all effects)\n\n");
exit(1);
} /* usage_effect */