[MPlayer-cvslog] CVS: main subopt-helper.c,1.8,1.9
Joey Parrish CVS
syncmail at mplayerhq.hu
Mon Oct 10 14:56:47 CEST 2005
CVS change done by Joey Parrish CVS
Update of /cvsroot/mplayer/main
In directory mail:/var2/tmp/cvs-serv25857
Modified Files:
subopt-helper.c
Log Message:
support float arguments in subopt helper.
Index: subopt-helper.c
===================================================================
RCS file: /cvsroot/mplayer/main/subopt-helper.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- subopt-helper.c 27 Sep 2005 08:52:40 -0000 1.8
+++ subopt-helper.c 10 Oct 2005 12:56:44 -0000 1.9
@@ -32,6 +32,7 @@
/* prototypes for argument parsing */
static char const * parse_int( char const * const str, int * const valp );
static char const * parse_str( char const * const str, strarg_t * const valp );
+static char const * parse_float( char const * const str, float * const valp );
/**
* \brief Try to parse all options in str and fail if it was not possible.
@@ -162,6 +163,10 @@
}
break;
}
+ case OPT_ARG_FLOAT:
+ last = parse_float( &str[parse_pos],
+ (float *)opts[idx].valp );
+ break;
default:
assert( 0 && "Arg type of suboption doesn't exist!" );
last = NULL; // break parsing!
@@ -247,6 +252,20 @@
return endp;
}
+static char const * parse_float( char const * const str, float * const valp )
+{
+ char * endp;
+
+ assert( str && "parse_float(): str == NULL" );
+
+ *valp = strtof( str, &endp );
+
+ /* nothing was converted */
+ if ( str == endp ) { return NULL; }
+
+ return endp;
+}
+
#define QUOTE_CHAR '%'
static char const * parse_str( char const * str, strarg_t * const valp )
{
More information about the MPlayer-cvslog
mailing list