Mercurial > mplayer.hg
changeset 3559:f61dcc63be5f
exchanged return with goto out in subconfig parsing and fixed error messages
author | alex |
---|---|
date | Mon, 17 Dec 2001 15:50:36 +0000 |
parents | 1dbf58c3d50c |
children | 61e0e3ecf47a |
files | cfgparser.c cfgparser.h |
diffstat | 2 files changed, 23 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/cfgparser.c Mon Dec 17 14:19:37 2001 +0000 +++ b/cfgparser.c Mon Dec 17 15:50:36 2001 +0000 @@ -118,7 +118,7 @@ !strcmp(param, "0")) *((int *) conf[i].p) = conf[i].min; else { - mp_msg(MSGT_CFGPARSER, MSGL_ERR, "invalid parameter for flag:\n"); + mp_msg(MSGT_CFGPARSER, MSGL_ERR, "invalid parameter for flag: %s\n", param); ret = ERR_OUT_OF_RANGE; goto out; } @@ -134,21 +134,21 @@ tmp_int = strtol(param, &endptr, 0); if (*endptr) { - mp_msg(MSGT_CFGPARSER, MSGL_ERR, "parameter must be an integer:\n"); + mp_msg(MSGT_CFGPARSER, MSGL_ERR, "parameter must be an integer: %s\n", param); ret = ERR_OUT_OF_RANGE; goto out; } if (conf[i].flags & CONF_MIN) if (tmp_int < conf[i].min) { - mp_msg(MSGT_CFGPARSER, MSGL_ERR, "parameter must be >= %d:\n", (int) conf[i].min); + mp_msg(MSGT_CFGPARSER, MSGL_ERR, "parameter must be >= %d: %s\n", (int) conf[i].min, param); ret = ERR_OUT_OF_RANGE; goto out; } if (conf[i].flags & CONF_MAX) if (tmp_int > conf[i].max) { - mp_msg(MSGT_CFGPARSER, MSGL_ERR, "parameter must be <= %d:\n", (int) conf[i].max); + mp_msg(MSGT_CFGPARSER, MSGL_ERR, "parameter must be <= %d: %s\n", (int) conf[i].max, param); ret = ERR_OUT_OF_RANGE; goto out; } @@ -167,22 +167,21 @@ if (*endptr) { mp_msg(MSGT_CFGPARSER, MSGL_ERR, "parameter must be a floating point number" - " or a ratio (numerator[:/]denominator):\n"); - + " or a ratio (numerator[:/]denominator): %s\n", param); ret = ERR_MISSING_PARAM; goto out; } if (conf[i].flags & CONF_MIN) if (tmp_float < conf[i].min) { - mp_msg(MSGT_CFGPARSER, MSGL_ERR, "parameter must be >= %f:\n", conf[i].min); + mp_msg(MSGT_CFGPARSER, MSGL_ERR, "parameter must be >= %f: %s\n", conf[i].min, param); ret = ERR_OUT_OF_RANGE; goto out; } if (conf[i].flags & CONF_MAX) if (tmp_float > conf[i].max) { - mp_msg(MSGT_CFGPARSER, MSGL_ERR, "parameter must be <= %f:\n", conf[i].max); + mp_msg(MSGT_CFGPARSER, MSGL_ERR, "parameter must be <= %f: %s\n", conf[i].max, param); ret = ERR_OUT_OF_RANGE; goto out; } @@ -196,20 +195,19 @@ if (conf[i].flags & CONF_MIN) if (strlen(param) < conf[i].min) { - mp_msg(MSGT_CFGPARSER, MSGL_ERR, "parameter must be >= %d chars:\n", - (int) conf[i].min); + mp_msg(MSGT_CFGPARSER, MSGL_ERR, "parameter must be >= %d chars: %s\n", + (int) conf[i].min, param); ret = ERR_OUT_OF_RANGE; goto out; } if (conf[i].flags & CONF_MAX) if (strlen(param) > conf[i].max) { - mp_msg(MSGT_CFGPARSER, MSGL_ERR, "parameter must be <= %d chars:\n", - (int) conf[i].max); + mp_msg(MSGT_CFGPARSER, MSGL_ERR, "parameter must be <= %d chars: %s\n", + (int) conf[i].max, param); ret = ERR_OUT_OF_RANGE; goto out; } - *((char **) conf[i].p) = strdup(param); ret = 1; break; @@ -261,26 +259,26 @@ token = strtok(param, (char *)&(":")); while(token) { - int ret; - int err; + int sscanf_ret; - ret = sscanf(token, "%[^=]=%s", subopt, subparam); - switch(ret) + sscanf_ret = sscanf(token, "%[^=]=%s", subopt, subparam); + switch(sscanf_ret) { case 1: case 2: - if ((err = read_option((struct config *)subconf, subconf_optnr, subopt, subparam)) < 0) + if ((ret = read_option((struct config *)subconf, subconf_optnr, subopt, subparam)) < 0) { mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Subconfig parsing returned error: %d in token: %s\n", - err, token); - return(err); + ret, token); + goto out; } break; default: mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Invalid subconfig argument! ('%s')\n", token); - return(ERR_NOT_AN_OPTION); + ret = ERR_NOT_AN_OPTION; + goto out; } - mp_msg(MSGT_CFGPARSER, MSGL_DBG3, "token: '%s', i=%d, subopt='%s, subparam='%s'\n", token, i, subopt, subparam); + mp_dbg(MSGT_CFGPARSER, MSGL_DBG3, "token: '%s', i=%d, subopt='%s, subparam='%s'\n", token, i, subopt, subparam); token = strtok(NULL, (char *)&(":")); } @@ -299,7 +297,7 @@ out: return ret; err_missing_param: - mp_msg(MSGT_CFGPARSER, MSGL_ERR, "missing parameter:\n"); + mp_msg(MSGT_CFGPARSER, MSGL_ERR, "missing parameter: %s\n", param); ret = ERR_MISSING_PARAM; goto out; }
--- a/cfgparser.h Mon Dec 17 14:19:37 2001 +0000 +++ b/cfgparser.h Mon Dec 17 15:50:36 2001 +0000 @@ -16,7 +16,6 @@ #define CONF_TYPE_SUBCONFIG 8 - #define ERR_NOT_AN_OPTION -1 #define ERR_MISSING_PARAM -2 #define ERR_OUT_OF_RANGE -3 @@ -33,8 +32,8 @@ struct config { char *name; void *p; - unsigned int type :4; - unsigned int flags:4; + unsigned int type; + unsigned int flags; float min,max; };