mirror of
https://github.com/mpv-player/mpv
synced 2025-02-18 05:37:04 +00:00
parameter can be in quotes in config file
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@168 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
d5b1225aa0
commit
caf48a3f5d
32
cfgparser.c
32
cfgparser.c
@ -230,6 +230,7 @@ int parse_config_file(struct config *conf, char *conffile)
|
|||||||
char *line;
|
char *line;
|
||||||
char opt[MAX_OPT_LEN];
|
char opt[MAX_OPT_LEN];
|
||||||
char param[MAX_PARAM_LEN];
|
char param[MAX_PARAM_LEN];
|
||||||
|
char c; /* for the "" and '' check */
|
||||||
int tmp;
|
int tmp;
|
||||||
int line_num = 0;
|
int line_num = 0;
|
||||||
int line_pos; /* line pos */
|
int line_pos; /* line pos */
|
||||||
@ -316,14 +317,29 @@ int parse_config_file(struct config *conf, char *conffile)
|
|||||||
++line_pos;
|
++line_pos;
|
||||||
|
|
||||||
/* read the parameter */
|
/* read the parameter */
|
||||||
for (param_pos = 0; isprint(line[line_pos]) && !isspace(line[line_pos])
|
if (line[line_pos] == '"' || line[line_pos] == '\'') {
|
||||||
&& line[line_pos] != '#'; /* NOTHING */) {
|
c = line[line_pos];
|
||||||
param[param_pos++] = line[line_pos++];
|
++line_pos;
|
||||||
if (param_pos >= MAX_PARAM_LEN) {
|
for (param_pos = 0; line[line_pos] != c; /* NOTHING */) {
|
||||||
PRINT_LINENUM;
|
param[param_pos++] = line[line_pos++];
|
||||||
printf("too long parameter\n");
|
if (param_pos >= MAX_PARAM_LEN) {
|
||||||
ret = -1;
|
PRINT_LINENUM;
|
||||||
continue;
|
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';
|
param[param_pos] = '\0';
|
||||||
|
Loading…
Reference in New Issue
Block a user