changeset 1090:fd0d77973d08

bugfix
author szabii
date Sun, 10 Jun 2001 23:40:20 +0000
parents b2a29e1224e4
children 06fd776f6b59
files cfgparser.c
diffstat 1 files changed, 17 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/cfgparser.c	Sun Jun 10 23:06:44 2001 +0000
+++ b/cfgparser.c	Sun Jun 10 23:40:20 2001 +0000
@@ -241,6 +241,7 @@
 	int opt_pos;	/* opt pos */
 	int param_pos;	/* param pos */
 	int ret = 1;
+	int errors = 0;
 
 #ifdef DEBUG
 	assert(conffile != NULL);
@@ -276,6 +277,12 @@
 		printf("\n");
 
 	while (fgets(line, MAX_LINE_LEN, fp)) {
+nextline:
+		if (errors >= 16) {
+			printf("too many errors\n");
+			goto out;
+		}
+
 		line_num++;
 		line_pos = 0;
 
@@ -296,14 +303,16 @@
 			if (opt_pos >= MAX_OPT_LEN) {
 				PRINT_LINENUM;
 				printf("too long option\n");
+				errors++;
 				ret = -1;
-				continue;
+				goto nextline;
 			}
 		}
 		if (opt_pos == 0) {
 			PRINT_LINENUM;
 			printf("parse error\n");
 			ret = -1;
+			errors++;
 			continue;
 		}
 		opt[opt_pos] = '\0';
@@ -321,6 +330,7 @@
 			PRINT_LINENUM;
 			printf("option without parameter\n");
 			ret = -1;
+			errors++;
 			continue;
 		}
 
@@ -338,7 +348,8 @@
 					PRINT_LINENUM;
 					printf("too long parameter\n");
 					ret = -1;
-					continue;
+					errors++;
+					goto nextline;
 				}
 			}
 			line_pos++;	/* skip the closing " or ' */
@@ -350,7 +361,8 @@
 					PRINT_LINENUM;
 					printf("too long parameter\n");
 					ret = -1;
-					continue;
+					errors++;
+					goto nextline;
 				}
 			}
 		}
@@ -361,6 +373,7 @@
 			PRINT_LINENUM;
 			printf("option without parameter\n");
 			ret = -1;
+			errors++;
 			continue;
 		}
 #ifdef DEBUG
@@ -388,6 +401,7 @@
 			PRINT_LINENUM;
 			printf("%s\n", opt);
 			ret = -1;
+			errors++;
 			continue;
 			/* break */
 		}