summaryrefslogtreecommitdiffstats
path: root/cfgparser.c
diff options
context:
space:
mode:
authoralex <alex@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-11-02 00:25:28 +0000
committeralex <alex@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-11-02 00:25:28 +0000
commit60ff845221e33623a6d5309d2282dd2128b9d949 (patch)
tree4ae50f01da8b5bbec43473a22d0285fcb4206291 /cfgparser.c
parent5431aa097d867810eb4b81bb292cc4d214584d98 (diff)
downloadmpv-60ff845221e33623a6d5309d2282dd2128b9d949.tar.bz2
mpv-60ff845221e33623a6d5309d2282dd2128b9d949.tar.xz
fixed arpi's cfgparser bug
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@2616 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'cfgparser.c')
-rw-r--r--cfgparser.c61
1 files changed, 39 insertions, 22 deletions
diff --git a/cfgparser.c b/cfgparser.c
index 0e63f04c1f..e370627904 100644
--- a/cfgparser.c
+++ b/cfgparser.c
@@ -236,7 +236,7 @@ static int read_option(char *opt, char *param)
printf("%s", (char *) config[i].p);
exit(1);
default:
- printf("picsaba\n");
+ printf("Unknown config type specified in conf-mplayer.h!\n");
break;
}
out:
@@ -445,6 +445,7 @@ int parse_command_line(struct config *conf, int argc, char **argv, char **envp,
int f_nr = 0;
int tmp;
char *opt;
+ int no_more_opts = 0;
#ifdef DEBUG
assert(argv != NULL);
@@ -459,33 +460,49 @@ int parse_command_line(struct config *conf, int argc, char **argv, char **envp,
++recursion_depth;
for (i = 1; i < argc; i++) {
+next:
opt = argv[i];
- if (*opt != '-')
- goto filename;
-
- /* remove trailing '-' */
- opt++;
-
- tmp = read_option(opt, argv[i + 1]);
-
- switch (tmp) {
- case ERR_NOT_AN_OPTION:
-filename:
- /* opt is not an option -> treat it as a filename */
- if (!(f = (char **) realloc(f, sizeof(*f) * (f_nr + 2))))
- goto err_out_mem;
-
- f[f_nr++] = argv[i];
- break;
- case ERR_MISSING_PARAM:
- case ERR_OUT_OF_RANGE:
- case ERR_FUNC_ERR:
+ if ((*opt == '-') && (*(opt+1) == '-'))
+ {
+ no_more_opts = 1;
+// printf("no more opts! %d\n",i);
+ i++;
+ goto next;
+ }
+
+ if ((no_more_opts == 0) && (*opt == '-')) /* option */
+ {
+ /* remove trailing '-' */
+ opt++;
+// printf("this_opt = option: %s\n", opt);
+
+ tmp = read_option(opt, argv[i + 1]);
+
+ switch (tmp) {
+ case ERR_NOT_AN_OPTION:
+ case ERR_MISSING_PARAM:
+ case ERR_OUT_OF_RANGE:
+ case ERR_FUNC_ERR:
+ printf("Error %d while parsing option: '%s'!\n",
+ tmp, opt);
goto err_out;
/* break; */
- default:
+ default:
i += tmp;
+ break;
+ }
+ }
+ else /* filename */
+ {
+// printf("this_opt = filename: %s\n", opt);
+ /* opt is not an option -> treat it as a filename */
+ if (!(f = (char **) realloc(f, sizeof(*f) * (f_nr + 2))))
+ goto err_out_mem;
+
+ f[f_nr++] = argv[i];
}
}
+
if (f)
f[f_nr] = NULL;
if (filenames)