changeset 9578:0c5454233dcf

Better error messages (with line number now) and make unknow option non-fatal for ppl wich compile many different versions
author albeu
date Thu, 13 Mar 2003 14:09:49 +0000
parents e39a71d9ca5f
children 89d27a306886
files parser-cfg.c
diffstat 1 files changed, 11 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/parser-cfg.c	Thu Mar 13 09:24:03 2003 +0000
+++ b/parser-cfg.c	Thu Mar 13 14:09:49 2003 +0000
@@ -94,7 +94,7 @@
 			opt[opt_pos++] = line[line_pos++];
 			if (opt_pos >= MAX_OPT_LEN) {
 				PRINT_LINENUM;
-				mp_msg(MSGT_CFGPARSER,MSGL_ERR,"too long option\n");
+				mp_msg(MSGT_CFGPARSER,MSGL_ERR,"too long option at line %d\n",line_num);
 				errors++;
 				ret = -1;
 				goto nextline;
@@ -102,7 +102,7 @@
 		}
 		if (opt_pos == 0) {
 			PRINT_LINENUM;
-			mp_msg(MSGT_CFGPARSER,MSGL_ERR,"parse error\n");
+			mp_msg(MSGT_CFGPARSER,MSGL_ERR,"parse error at line %d\n",line_num);
 			ret = -1;
 			errors++;
 			continue;
@@ -121,7 +121,7 @@
 		/* check '=' */
 		if (line[line_pos++] != '=') {
 			PRINT_LINENUM;
-			mp_msg(MSGT_CFGPARSER,MSGL_ERR,"option without parameter\n");
+			mp_msg(MSGT_CFGPARSER,MSGL_ERR,"Option %s need a parameter at line %d\n",line_num);
 			ret = -1;
 			errors++;
 			continue;
@@ -139,7 +139,7 @@
 				param[param_pos++] = line[line_pos++];
 				if (param_pos >= MAX_PARAM_LEN) {
 					PRINT_LINENUM;
-					mp_msg(MSGT_CFGPARSER,MSGL_ERR,"too long parameter\n");
+					mp_msg(MSGT_CFGPARSER,MSGL_ERR,"Option %s have a too long parameter at line %d\n",opt,line_num);
 					ret = -1;
 					errors++;
 					goto nextline;
@@ -164,7 +164,7 @@
 		/* did we read a parameter? */
 		if (param_pos == 0) {
 			PRINT_LINENUM;
-			mp_msg(MSGT_CFGPARSER,MSGL_ERR,"option without parameter\n");
+			mp_msg(MSGT_CFGPARSER,MSGL_ERR,"Option %s need a parameter at line %d\n",opt,line_num);
 			ret = -1;
 			errors++;
 			continue;
@@ -183,14 +183,18 @@
 		/* EOL / comment */
 		if (line[line_pos] != '\0' && line[line_pos] != '#') {
 			PRINT_LINENUM;
-			mp_msg(MSGT_CFGPARSER,MSGL_WARN,"extra characters on line: %s\n", line+line_pos);
+			mp_msg(MSGT_CFGPARSER,MSGL_WARN,"extra characters on line %d: %s\n",line_num, line+line_pos);
 			ret = -1;
 		}
 
 		tmp = m_config_set_option(config, opt, param);
 		if (tmp < 0) {
 			PRINT_LINENUM;
-			mp_msg(MSGT_CFGPARSER,MSGL_INFO,"%s\n", opt);
+			if(tmp == M_OPT_UNKNOW) {
+				mp_msg(MSGT_CFGPARSER,MSGL_WARN,"Warning unknown option %s at line %d\n", opt,line_num);
+				continue;
+			}
+			mp_msg(MSGT_CFGPARSER,MSGL_ERR,"Error parsing option %s=%s at line %d\n",opt,param,line_num);
 			ret = -1;
 			errors++;
 			continue;