From: Kalle Wallin Date: Mon, 12 Jul 2004 09:22:16 +0000 (+0000) Subject: Fixed short option handling for multiple short options at once (-abcde) X-Git-Tag: v0.12_alpha1~469 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=38f981dd428f68ac70d710a3593e7e6bdd90e126;p=ncmpc.git Fixed short option handling for multiple short options at once (-abcde) git-svn-id: https://svn.musicpd.org/ncmpc/trunk@1846 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- diff --git a/ChangeLog b/ChangeLog index d7d33aa..9e56ec8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ +2004-07-12 Kalle Wallin + * options.c: fixed short option handling for multiple short options + at once (-abcde) + 2004-07-09 Kalle Wallin - * ncmpc-0.11.0 released + * ncmpc-0.11.0 released (r1820) 2004-07-08 Kalle Wallin * doc/keys.sample: Welcome back diff --git a/configure.ac b/configure.ac index c58a6cc..e2e0a23 100644 --- a/configure.ac +++ b/configure.ac @@ -4,7 +4,7 @@ dnl AC_INIT AC_CONFIG_SRCDIR([src/main.c]) -AM_INIT_AUTOMAKE(ncmpc, 0.11.0) +AM_INIT_AUTOMAKE([ncmpc], [0.11.1-svn]) AM_CONFIG_HEADER([config.h]) dnl Check for programs @@ -66,13 +66,13 @@ AC_CHECK_LIB([ncurses], dnl Check for glib-2.4 PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.4], - glib24=yes, - AC_MSG_WARN([glib-2.4 is required for NLS support!])) + [glib24=yes], + [AC_MSG_WARN([glib-2.4 is required for NLS support!])]) if test "x$glib24" != "xyes"; then PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.2], - nls=no, - AC_MSG_ERROR([glib-2.2 is required])) + [nls=no], + [AC_MSG_ERROR([glib-2.2 is required])]) fi diff --git a/src/options.c b/src/options.c index 314a0e9..94da5b8 100644 --- a/src/options.c +++ b/src/options.c @@ -100,7 +100,7 @@ option_error(int error, char *option, char *arg) fprintf(stderr, PACKAGE ": invalid option %s=%s\n", option, arg); break; case ERROR_MISSING_ARGUMENT: - fprintf(stderr, PACKAGE ": missing value for %s\n", option); + fprintf(stderr, PACKAGE ": missing value for %s option\n", option); break; default: fprintf(stderr, PACKAGE ": internal error %d\n", error); @@ -242,22 +242,28 @@ options_parse(int argc, const char *argv[]) opt = NULL; } } - /* check for a short option */ - else if( len==2 && g_str_has_prefix(arg, "-") ) + /* check for short options */ + else if( len>=2 && g_str_has_prefix(arg, "-") ) { - /* make shure we got an argument for the previous option */ - if( opt && opt->argument ) - option_error(ERROR_MISSING_ARGUMENT, opt->longopt, opt->argument); + int j; - /* check if the option exists */ - if( (opt=lookup_option(arg[1], NULL))==NULL ) - option_error(ERROR_UNKNOWN_OPTION, arg, NULL); - - /* if no option argument is needed execute callback */ - if( opt->argument==NULL ) + for(j=1; jshortopt, NULL); - opt = NULL; + /* make shure we got an argument for the previous option */ + if( opt && opt->argument ) + option_error(ERROR_MISSING_ARGUMENT, + opt->longopt, opt->argument); + + /* check if the option exists */ + if( (opt=lookup_option(arg[j], NULL))==NULL ) + option_error(ERROR_UNKNOWN_OPTION, arg, NULL); + + /* if no option argument is needed execute callback */ + if( opt->argument==NULL ) + { + option_cb (opt->shortopt, NULL); + opt = NULL; + } } } else