changeset 167:53f289e99102

parameter can be in quotes in config file
author szabii
date Mon, 19 Mar 2001 21:58:20 +0000
parents 6b79d801e183
children bdc4a8fc04d8
files cfgparser.c
diffstat 1 files changed, 24 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/cfgparser.c	Mon Mar 19 21:06:56 2001 +0000
+++ b/cfgparser.c	Mon Mar 19 21:58:20 2001 +0000
@@ -230,6 +230,7 @@
 	char *line;
 	char opt[MAX_OPT_LEN];
 	char param[MAX_PARAM_LEN];
+	char c;		/* for the "" and '' check */
 	int tmp;
 	int line_num = 0;
 	int line_pos;	/* line pos */
@@ -316,14 +317,29 @@
 			++line_pos;
 
 		/* read the parameter */
-		for (param_pos = 0; isprint(line[line_pos]) && !isspace(line[line_pos])
-				&& line[line_pos] != '#'; /* NOTHING */) {
-			param[param_pos++] = line[line_pos++];
-			if (param_pos >= MAX_PARAM_LEN) {
-				PRINT_LINENUM;
-				printf("too long parameter\n");
-				ret = -1;
-				continue;
+		if (line[line_pos] == '"' || line[line_pos] == '\'') {
+			c = line[line_pos];
+			++line_pos;
+			for (param_pos = 0; line[line_pos] != c; /* NOTHING */) {
+				param[param_pos++] = line[line_pos++];
+				if (param_pos >= MAX_PARAM_LEN) {
+					PRINT_LINENUM;
+					printf("too long parameter\n");
+					ret = -1;
+					continue;
+				}
+			}
+			line_pos++;	/* skip the closing " or ' */
+		} else {
+			for (param_pos = 0; isprint(line[line_pos]) && !isspace(line[line_pos])
+					&& line[line_pos] != '#'; /* NOTHING */) {
+				param[param_pos++] = line[line_pos++];
+				if (param_pos >= MAX_PARAM_LEN) {
+					PRINT_LINENUM;
+					printf("too long parameter\n");
+					ret = -1;
+					continue;
+				}
 			}
 		}
 		param[param_pos] = '\0';