[MPlayer-dev-eng] Re: [PATCH] allow multiple help clauses on the command line

Alban Bedel albeu at free.fr
Thu Aug 11 16:08:01 CEST 2005


On Thu, 11 Aug 2005 07:28:01 -0400
kiriuja <mplayer-patches at en-directo.net> wrote:

> On Thu 11 Aug 2005 05:54, Alban Bedel wrote:
> > I don't like that patch very much. In particular the opt_exit global thing
> > in m_config.c is quiet ugly. imho you shouldn't remove the M_OPT_EXIT
> > return code, instead modify the commande line parsers (parser-m?cmp.c) so
> > that they don't exit on M_OPT_EXIT but pass it up properly the caller.
> 
> That was how the previous versions of the patch worked (see post from
> July 18). The problem with that is the return value that parsers get
> from m_option_* tells them how many command line arguments the option
> consumed, and for help commands it is either zero or one at present,
> but potentially it can be any number. So in those previous versions I
> had to introduce another constant, M_OPT_EXIT0, to distinguish the case
> where -pphelp did not consume an additional argument. I thought that
> was uglier than having a global variable for opt_exit.

Right, it could return any number. But the api only allow to pass one
parameter, so it can only be 1 or 0. The M_OPT_EXIT0 (or EXIT1) thing
is ok imho, it's then up to the command line parsers to handle these.

> > So *not* with a global, modify the arguments to the command line parser
> > if you need to.
> 
> Could you elaborate please? It seems to me we'd have to return two values
> (a count of arguments consumed and an error/success status) from each one
> of the parse_* and get_* functions in m_option.c. I realize that global
> variables are not the ideal way of passing information, but in this case
> changing all the parsing functions referenced by all the the m_option_type
> structs seems like an inferior solution to me.

No i mean in m_config_parse_m[pe]_command_line(), and yes it need to return
2 values, if one need to exit and the playlist. Just use an extra pointer,
for example:
int m_config_parse_mp_command_line(m_config_t *config,
                                   int argc, char **argv,
                                   play_tree_t** tree)
You could then also return different values for ok, command line errors and
"should still print some stuff".

	Albeu




More information about the MPlayer-dev-eng mailing list