[MPlayer-cvslog] CVS: main subopt-helper.c, 1.8, 1.9 subopt-helper.h, 1.5, 1.6

Joey Parrish CVS syncmail at mplayerhq.hu
Mon Oct 10 14:52:40 CEST 2005


CVS change done by Joey Parrish CVS

Update of /cvsroot/mplayer/main
In directory mail:/var2/tmp/cvs-serv8112

Modified Files:
	subopt-helper.c subopt-helper.h 
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:52:37 -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, 0 );
+
+  /* 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 )
 {

Index: subopt-helper.h
===================================================================
RCS file: /cvsroot/mplayer/main/subopt-helper.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- subopt-helper.h	16 Jun 2005 09:08:07 -0000	1.5
+++ subopt-helper.h	10 Oct 2005 12:52:37 -0000	1.6
@@ -13,6 +13,7 @@
 #define OPT_ARG_INT  1
 #define OPT_ARG_STR  2
 #define OPT_ARG_MSTRZ 3 ///< A malloced, zero terminated string, use free()!
+#define OPT_ARG_FLOAT 4
 
 typedef int (*opt_test_f)(void *);
 




More information about the MPlayer-cvslog mailing list