mirror of
https://github.com/mpv-player/mpv.git
synced 2026-10-28 23:13:18 +08:00
Simplify range-checking functions for subopt parsing.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30165 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
+1
-3
@@ -265,9 +265,7 @@ static void print_help (void)
|
||||
|
||||
static int str_maxlen(void *strp) {
|
||||
strarg_t *str = strp;
|
||||
if (str->len > ALSA_DEVICE_SIZE)
|
||||
return 0;
|
||||
return 1;
|
||||
return str->len <= ALSA_DEVICE_SIZE;
|
||||
}
|
||||
|
||||
static int try_open_device(const char *device, int open_mode, int try_ac3)
|
||||
|
||||
+1
-3
@@ -333,9 +333,7 @@ static void check_events(void)
|
||||
static int int_zero_hundred(void *valp)
|
||||
{
|
||||
int *val = valp;
|
||||
if ( (*val >=0) && (*val<=100) )
|
||||
return 1;
|
||||
return 0;
|
||||
return *val >= 0 && *val <= 100;
|
||||
}
|
||||
|
||||
static int preinit(const char *arg)
|
||||
|
||||
+1
-3
@@ -286,9 +286,7 @@ static void check_events(void){}
|
||||
static int int_zero_to_nine(void *value)
|
||||
{
|
||||
int *sh = value;
|
||||
if ( (*sh < 0) || (*sh > 9) )
|
||||
return 0;
|
||||
return 1;
|
||||
return *sh >= 0 && *sh <= 9;
|
||||
}
|
||||
|
||||
static const opt_t subopts[] = {
|
||||
|
||||
+2
-6
@@ -303,17 +303,13 @@ static char const * parse_str( char const * str, strarg_t * const valp )
|
||||
int int_non_neg(void *iptr)
|
||||
{
|
||||
int *i = iptr;
|
||||
if ( *i < 0 ) { return 0; }
|
||||
|
||||
return 1;
|
||||
return *i >= 0;
|
||||
}
|
||||
/** \brief Test if i is positive. */
|
||||
int int_pos(void *iptr)
|
||||
{
|
||||
int *i = iptr;
|
||||
if ( *i > 0 ) { return 1; }
|
||||
|
||||
return 0;
|
||||
return *i > 0;
|
||||
}
|
||||
|
||||
/*** little helpers */
|
||||
|
||||
Reference in New Issue
Block a user