(mh_argp_parse): Changed prototype.
Showing
2 changed files
with
27 additions
and
26 deletions
... | @@ -95,7 +95,7 @@ my_argp_parse (struct argp *argp, int argc, char **argv, int flags, | ... | @@ -95,7 +95,7 @@ my_argp_parse (struct argp *argp, int argc, char **argv, int flags, |
95 | } | 95 | } |
96 | 96 | ||
97 | int | 97 | int |
98 | mh_argp_parse (int argc, char **argv, | 98 | mh_argp_parse (int *pargc, char **pargv[], |
99 | int flags, | 99 | int flags, |
100 | struct argp_option *option, | 100 | struct argp_option *option, |
101 | struct mh_option *mh_option, | 101 | struct mh_option *mh_option, |
... | @@ -108,8 +108,8 @@ mh_argp_parse (int argc, char **argv, | ... | @@ -108,8 +108,8 @@ mh_argp_parse (int argc, char **argv, |
108 | int index; | 108 | int index; |
109 | int extra = 0; | 109 | int extra = 0; |
110 | 110 | ||
111 | program_invocation_name = argv[0]; | 111 | program_invocation_name = (*pargv)[0]; |
112 | p = strrchr (argv[0], '/'); | 112 | p = strrchr ((*pargv)[0], '/'); |
113 | if (p) | 113 | if (p) |
114 | program_invocation_short_name = p+1; | 114 | program_invocation_short_name = p+1; |
115 | else | 115 | else |
... | @@ -131,41 +131,42 @@ mh_argp_parse (int argc, char **argv, | ... | @@ -131,41 +131,42 @@ mh_argp_parse (int argc, char **argv, |
131 | p = mh_global_profile_get (program_invocation_short_name, NULL); | 131 | p = mh_global_profile_get (program_invocation_short_name, NULL); |
132 | if (p) | 132 | if (p) |
133 | { | 133 | { |
134 | int _argc; | 134 | int argc; |
135 | char **_argv; | 135 | char **argv; |
136 | int xargc; | 136 | int xargc; |
137 | char **xargv; | 137 | char **xargv; |
138 | int i, j; | 138 | int i, j; |
139 | 139 | ||
140 | argcv_get (p, "", NULL, &xargc, &xargv); | 140 | argcv_get (p, "", NULL, &xargc, &xargv); |
141 | 141 | ||
142 | _argc = argc + xargc; | 142 | argc = *pargc + xargc; |
143 | _argv = calloc (_argc+1, sizeof *_argv); | 143 | argv = calloc (argc+1, sizeof *argv); |
144 | if (!_argv) | 144 | if (!argv) |
145 | mh_err_memory (1); | 145 | mh_err_memory (1); |
146 | 146 | ||
147 | i = 0; | 147 | i = 0; |
148 | _argv[i++] = argv[0]; | 148 | argv[i++] = (*pargv)[0]; |
149 | for (j = 0; j < xargc; i++, j++) | 149 | for (j = 0; j < xargc; i++, j++) |
150 | _argv[i] = xargv[j]; | 150 | argv[i] = xargv[j]; |
151 | for (j = 1; i < _argc; i++, j++) | 151 | for (j = 1; i < argc; i++, j++) |
152 | _argv[i] = argv[j]; | 152 | argv[i] = (*pargv)[j]; |
153 | _argv[i] = NULL; | 153 | argv[i] = NULL; |
154 | mh_argv_preproc (_argc, _argv, &data); | 154 | |
155 | |||
156 | my_argp_parse (&argp, _argc, _argv, flags, &index, &data); | ||
157 | |||
158 | free (_argv); | ||
159 | extra = index < _argc; | ||
160 | index -= xargc; | ||
161 | if (index < 0) | ||
162 | index = argc; | ||
163 | } | ||
164 | else | ||
165 | { | ||
166 | mh_argv_preproc (argc, argv, &data); | 155 | mh_argv_preproc (argc, argv, &data); |
156 | |||
167 | my_argp_parse (&argp, argc, argv, flags, &index, &data); | 157 | my_argp_parse (&argp, argc, argv, flags, &index, &data); |
158 | |||
168 | extra = index < argc; | 159 | extra = index < argc; |
160 | |||
161 | *pargc = argc; | ||
162 | *pargv = argv; | ||
163 | free (xargv); | ||
164 | } | ||
165 | else | ||
166 | { | ||
167 | mh_argv_preproc (*pargc, *pargv, &data); | ||
168 | my_argp_parse (&argp, *pargc, *pargv, flags, &index, &data); | ||
169 | extra = index < *pargc; | ||
169 | } | 170 | } |
170 | if (pindex) | 171 | if (pindex) |
171 | *pindex = index; | 172 | *pindex = index; | ... | ... |
... | @@ -178,7 +178,7 @@ struct mh_argp_data | ... | @@ -178,7 +178,7 @@ struct mh_argp_data |
178 | void mh_argv_preproc __P((int argc, char **argv, struct mh_argp_data *data)); | 178 | void mh_argv_preproc __P((int argc, char **argv, struct mh_argp_data *data)); |
179 | int mh_getopt __P((int argc, char **argv, struct mh_option *mh_opt, | 179 | int mh_getopt __P((int argc, char **argv, struct mh_option *mh_opt, |
180 | const char *doc)); | 180 | const char *doc)); |
181 | int mh_argp_parse __P((int argc, char **argv, | 181 | int mh_argp_parse __P((int *argc, char **argv[], |
182 | int flags, | 182 | int flags, |
183 | struct argp_option *option, | 183 | struct argp_option *option, |
184 | struct mh_option *mh_option, | 184 | struct mh_option *mh_option, | ... | ... |
-
Please register or sign in to post a comment