ref: c0d4253e05c5b7d823a7ac852826d78294ae9bda
parent: 08fb7d893bb9f0b2e65e0ff5bf2551f4733393c2
author: cbagwell <cbagwell>
date: Sun Aug 13 12:32:26 EDT 2006
converting to getopt_long
--- a/src/sox.c
+++ b/src/sox.c
@@ -275,19 +275,27 @@
return(0);
}
-#ifdef HAVE_GETOPT_H
static char *getoptstr = "+r:v:t:c:phsuUAaigbwlfdxVSq";
-#else
-static char *getoptstr = "r:v:t:c:phsuUAaigbwlfdxVSq";
-#endif
+static struct option getoptarray[] =
+{
+ {"version", 0, NULL, 'V'},
+ {NULL, 0, NULL, 0}
+};
+
static void doopts(file_options_t *fo, int argc, char **argv)
{
int c, i;
char *str;
- while ((c = getopt(argc, argv, getoptstr)) != -1) {
+ while ((c = getopt_long(argc, argv, getoptstr, getoptarray, NULL)) != -1) {
switch(c) {
+ case 0:
+ /* FIXME: Long options here */
+ usage((char *)0);
+ /* no return from above */
+ break;
+
case 'p':
soxpreview++;
break;
@@ -388,6 +396,11 @@
case 'q':
status = 0;
quiet = 1;
+ break;
+
+ case '?':
+ usage((char *)0);
+ /* no return from above */
break;
}
}