summaryrefslogtreecommitdiffstats
path: root/cfgparser.c
diff options
context:
space:
mode:
authoralex <alex@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-12-17 15:50:36 +0000
committeralex <alex@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-12-17 15:50:36 +0000
commit0df95143a80293badf5cd16bf10f7b7b2140c1f3 (patch)
tree86853cbccdf9ff6c9156824528cd464c3e259c93 /cfgparser.c
parent00c5d6e5cb458a7708326916e050930503cb8243 (diff)
downloadmpv-0df95143a80293badf5cd16bf10f7b7b2140c1f3.tar.bz2
mpv-0df95143a80293badf5cd16bf10f7b7b2140c1f3.tar.xz
exchanged return with goto out in subconfig parsing and fixed error messages
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@3560 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'cfgparser.c')
-rw-r--r--cfgparser.c44
1 files changed, 21 insertions, 23 deletions
diff --git a/cfgparser.c b/cfgparser.c
index 8c9912b0cd..ad535e6a53 100644
--- a/cfgparser.c
+++ b/cfgparser.c
@@ -118,7 +118,7 @@ static int read_option(struct config *conf, int conf_optnr, char *opt, char *par
!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 @@ static int read_option(struct config *conf, int conf_optnr, char *opt, char *par
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 @@ static int read_option(struct config *conf, int conf_optnr, char *opt, char *par
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 @@ static int read_option(struct config *conf, int conf_optnr, char *opt, char *par
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 @@ static int read_option(struct config *conf, int conf_optnr, char *opt, char *par
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 @@ static int read_option(struct config *conf, int conf_optnr, char *opt, char *par
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;
}