[MPlayer-cvslog] r28862 - in trunk: subopt-helper.c subopt-helper.h
reimar
subversion at mplayerhq.hu
Fri Mar 6 21:41:02 CET 2009
Author: reimar
Date: Fri Mar 6 21:41:02 2009
New Revision: 28862
Log:
Get rid of the "set" member of the subopt-parser struct, it made
it impossible to make the those struct variables const.
Also it is not really useful, and wastes space.
Modified:
trunk/subopt-helper.c
trunk/subopt-helper.h
Modified: trunk/subopt-helper.c
==============================================================================
--- trunk/subopt-helper.c Fri Mar 6 21:20:12 2009 (r28861)
+++ trunk/subopt-helper.c Fri Mar 6 21:41:02 2009 (r28862)
@@ -45,18 +45,11 @@ static char const * parse_float( char co
* else a non-zero value is returned.
*
*/
-int subopt_parse( char const * const str, opt_t * opts )
+int subopt_parse( char const * const str, const opt_t * opts )
{
int parse_err = 0, idx;
unsigned int parse_pos = 0;
- /* Initialize set member to false. *
- * It is set to true if it was found in str */
- for ( idx=0; opts[idx].name; ++idx )
- {
- opts[idx].set = 0;
- }
-
if ( str )
{
while ( str[parse_pos] && !parse_err )
@@ -101,7 +94,7 @@ int subopt_parse( char const * const str
if( strncmp( &str[parse_pos], opts[idx].name, opt_len ) == 0 )
{
/* option was found */
- opts[idx].set = 1; next = 1;
+ next = 1;
assert( opts[idx].valp && "Need a pointer to store the arg!" );
@@ -196,7 +189,7 @@ else if ( substr_len == opt_len+2 )
strncmp( &str[parse_pos+2], opts[idx].name, opt_len ) == 0 )
{
/* option was found but negated */
- opts[idx].set = 1; next = 1;
+ next = 1;
/* set arg to false */
*((int *)(opts[idx].valp)) = 0;
Modified: trunk/subopt-helper.h
==============================================================================
--- trunk/subopt-helper.h Fri Mar 6 21:20:12 2009 (r28861)
+++ trunk/subopt-helper.h Fri Mar 6 21:41:02 2009 (r28862)
@@ -24,13 +24,10 @@ typedef struct opt_s
int type; ///< option type as defined in subopt-helper.h
void * valp; ///< pointer to the mem where the value should be stored
opt_test_f test; ///< argument test func ( optional )
- int set; ///< Is set internally by the parser if the option was found.
- ///< Don't use it at initialization of your opts, it will be
- ///< overriden anyway!
} opt_t;
/** parses the string for the options specified in opt */
-int subopt_parse( char const * const str, opt_t * opts );
+int subopt_parse( char const * const str, const opt_t * opts );
/*------------------ arg specific types and declaration -------------------*/
More information about the MPlayer-cvslog
mailing list