aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar szabii <szabii@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-03-19 21:58:20 +0000
committerGravatar szabii <szabii@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-03-19 21:58:20 +0000
commitcaf48a3f5da35dd2e183da9f34ed265bf082856f (patch)
treeafd83cf09d1752503739f485f2addd42a3139331
parentd5b1225aa03ae0111ec3873207b6442d9ffeb23d (diff)
parameter can be in quotes in config file
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@168 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r--cfgparser.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/cfgparser.c b/cfgparser.c
index 6580f6a5aa..4e449be16d 100644
--- a/cfgparser.c
+++ b/cfgparser.c
@@ -230,6 +230,7 @@ int parse_config_file(struct config *conf, char *conffile)
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 @@ int parse_config_file(struct config *conf, char *conffile)
++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';