Mercurial > mplayer.hg
changeset 195:452453f82bfa
strto* int/float reader
author | szabii |
---|---|
date | Thu, 22 Mar 2001 18:52:45 +0000 |
parents | 88c20ac9c62c |
children | 9b82a3ef38ee |
files | cfgparser.c |
diffstat | 1 files changed, 9 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/cfgparser.c Thu Mar 22 18:16:06 2001 +0000 +++ b/cfgparser.c Thu Mar 22 18:52:45 2001 +0000 @@ -56,9 +56,10 @@ static int read_option(char *opt, char *param) { int i; - int tmp_int; - float tmp_float; + long tmp_int; + double tmp_float; int ret = -1; + char *endptr; for (i = 0; i < nr_options; i++) { if (!strcasecmp(opt, config[i].name)) @@ -113,14 +114,14 @@ case CONF_TYPE_INT: if (param == NULL) goto err_missing_param; - if (!isdigit(*param)) { + + tmp_int = strtol(param, &endptr, 0); + if (*endptr) { printf("parameter must be an integer:\n"); ret = ERR_OUT_OF_RANGE; goto out; } - tmp_int = atoi(param); - if (config[i].flags & CONF_MIN) if (tmp_int < config[i].min) { printf("parameter must be >= %d:\n", (int) config[i].min); @@ -141,14 +142,14 @@ case CONF_TYPE_FLOAT: if (param == NULL) goto err_missing_param; - if (!isdigit(*param) && *param != '-' && *param != '.') { + + tmp_float = strtod(param, &endptr); + if (*endptr) { printf("parameter must be a floating point number:\n"); ret = ERR_MISSING_PARAM; goto out; } - tmp_float = atof(param); - if (config[i].flags & CONF_MIN) if (tmp_float < config[i].min) { printf("parameter must be >= %f:\n", config[i].min);