1
0
mirror of http://mpg123.de/trunk/.git synced 2025-10-25 04:37:34 +03:00

There were several option parsing regressions most probably caused by application of Nicholas' changes to my code with changed command line parsing.

Fixed the obvious ones and made the option parser bail out if it encouters such an error again.


git-svn-id: svn://scm.orgis.org/mpg123/trunk@181 35dc7657-300d-0410-a2e5-dc2837fedb53
This commit is contained in:
thor
2006-06-26 21:36:07 +00:00
parent f977f6b480
commit 0d729b47c8
2 changed files with 15 additions and 8 deletions

View File

@@ -9,6 +9,7 @@
* Fri Dec 23, 2005 * Fri Dec 23, 2005
*/ */
#include <stdio.h>
#include "config.h" #include "config.h"
#include "debug.h" #include "debug.h"
#include "getlopt.h" #include "getlopt.h"
@@ -48,6 +49,11 @@ topt *findopt (int islong, char *opt, topt *opts)
int performoption (int argc, char *argv[], topt *opt) int performoption (int argc, char *argv[], topt *opt)
{ {
int result = GLO_CONTINUE; int result = GLO_CONTINUE;
#define prog_error() \
{ \
fprintf(stderr, __FILE__ ":%i Option without type flag! This is a programming error! Developer: fix this ASAP to regain your honor.\n", __LINE__); \
exit(1); \
}
if (!(opt->flags & GLO_ARG)) { /* doesn't take argument */ if (!(opt->flags & GLO_ARG)) { /* doesn't take argument */
if (opt->var) { if (opt->var) {
@@ -66,7 +72,7 @@ int performoption (int argc, char *argv[], topt *opt)
debug1("int at %p", opt->var); debug1("int at %p", opt->var);
*( (int *) opt->var ) = (int) opt->value; *( (int *) opt->var ) = (int) opt->value;
} }
else debug("Option without type flag! This is a programming error!"); else prog_error();
debug("casting assignment done"); debug("casting assignment done");
} }
@@ -85,7 +91,7 @@ int performoption (int argc, char *argv[], topt *opt)
*((long *) opt->var) = atol(loptarg); *((long *) opt->var) = atol(loptarg);
else if(opt->flags & GLO_INT) else if(opt->flags & GLO_INT)
*((int *) opt->var) = atoi(loptarg); *((int *) opt->var) = atoi(loptarg);
else debug("Option without type flag! This is a programming error!"); else prog_error();
} }
else else
result = opt->value ? opt->value : opt->sname; result = opt->value ? opt->value : opt->sname;

View File

@@ -510,22 +510,23 @@ topt opts[] = {
{'Z', "random", GLO_INT, 0, &param.shuffle, 2}, {'Z', "random", GLO_INT, 0, &param.shuffle, 2},
{'E', "equalizer", GLO_ARG | GLO_CHAR, 0, &equalfile,1}, {'E', "equalizer", GLO_ARG | GLO_CHAR, 0, &equalfile,1},
#ifdef HAVE_SETPRIORITY #ifdef HAVE_SETPRIORITY
{0, "aggressive", 0, 0, &param.aggressive, 2}, {0, "aggressive", GLO_INT, 0, &param.aggressive, 2},
#endif #endif
#ifdef USE_3DNOW #ifdef USE_3DNOW
{0, "force-3dnow", 0, 0, &param.stat_3dnow,1}, {0, "force-3dnow", GLO_INT, 0, &param.stat_3dnow, 1},
{0, "no-3dnow", 0, 0, &param.stat_3dnow,2}, {0, "no-3dnow", GLO_INT, 0, &param.stat_3dnow, 2},
{0, "test-3dnow", 0, 0, &param.test_3dnow,TRUE}, {0, "test-3dnow", GLO_INT, 0, &param.test_3dnow, TRUE},
#endif #endif
#if !defined(WIN32) && !defined(GENERIC) #if !defined(WIN32) && !defined(GENERIC)
{'u', "auth", GLO_ARG | GLO_CHAR, 0, &httpauth, 0}, {'u', "auth", GLO_ARG | GLO_CHAR, 0, &httpauth, 0},
#endif #endif
#ifdef HAVE_SCHED_SETSCHEDULER #ifdef HAVE_SCHED_SETSCHEDULER
{'T', "realtime", 0, 0, &param.realtime, TRUE }, /* check why this should be a long variable instead of int! */
{'T', "realtime", GLO_LONG, 0, &param.realtime, TRUE },
#else #else
{'T', "realtime", 0, realtime_not_compiled, 0, 0 }, {'T', "realtime", 0, realtime_not_compiled, 0, 0 },
#endif #endif
{0, "title", 0, 0, &param.xterm_title, TRUE }, {0, "title", GLO_INT, 0, &param.xterm_title, TRUE },
{'w', "wav", GLO_ARG | GLO_CHAR, set_wav, 0 , 0 }, {'w', "wav", GLO_ARG | GLO_CHAR, set_wav, 0 , 0 },
{0, "cdr", GLO_ARG | GLO_CHAR, set_cdr, 0 , 0 }, {0, "cdr", GLO_ARG | GLO_CHAR, set_cdr, 0 , 0 },
{0, "au", GLO_ARG | GLO_CHAR, set_au, 0 , 0 }, {0, "au", GLO_ARG | GLO_CHAR, set_au, 0 , 0 },