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:
reimar 2010-01-01 13:23:16 +00:00
parent f102ac7a8c
commit 92cd6dc3e9
4 changed files with 5 additions and 15 deletions

View File

@ -265,9 +265,7 @@ static void print_help (void)
static int str_maxlen(void *strp) { static int str_maxlen(void *strp) {
strarg_t *str = strp; strarg_t *str = strp;
if (str->len > ALSA_DEVICE_SIZE) return str->len <= ALSA_DEVICE_SIZE;
return 0;
return 1;
} }
static int try_open_device(const char *device, int open_mode, int try_ac3) static int try_open_device(const char *device, int open_mode, int try_ac3)

View File

@ -333,9 +333,7 @@ static void check_events(void)
static int int_zero_hundred(void *valp) static int int_zero_hundred(void *valp)
{ {
int *val = valp; int *val = valp;
if ( (*val >=0) && (*val<=100) ) return *val >= 0 && *val <= 100;
return 1;
return 0;
} }
static int preinit(const char *arg) static int preinit(const char *arg)

View File

@ -286,9 +286,7 @@ static void check_events(void){}
static int int_zero_to_nine(void *value) static int int_zero_to_nine(void *value)
{ {
int *sh = value; int *sh = value;
if ( (*sh < 0) || (*sh > 9) ) return *sh >= 0 && *sh <= 9;
return 0;
return 1;
} }
static const opt_t subopts[] = { static const opt_t subopts[] = {

View File

@ -303,17 +303,13 @@ static char const * parse_str( char const * str, strarg_t * const valp )
int int_non_neg(void *iptr) int int_non_neg(void *iptr)
{ {
int *i = iptr; int *i = iptr;
if ( *i < 0 ) { return 0; } return *i >= 0;
return 1;
} }
/** \brief Test if i is positive. */ /** \brief Test if i is positive. */
int int_pos(void *iptr) int int_pos(void *iptr)
{ {
int *i = iptr; int *i = iptr;
if ( *i > 0 ) { return 1; } return *i > 0;
return 0;
} }
/*** little helpers */ /*** little helpers */