]>
Commit | Line | Data |
---|---|---|
4a59fd13 PH |
1 | #include "git-compat-util.h" |
2 | #include "parse-options.h" | |
26141b5b | 3 | #include "cache.h" |
269defdf | 4 | #include "commit.h" |
4a59fd13 PH |
5 | |
6 | #define OPT_SHORT 1 | |
7 | #define OPT_UNSET 2 | |
8 | ||
4a59fd13 PH |
9 | static int opterror(const struct option *opt, const char *reason, int flags) |
10 | { | |
11 | if (flags & OPT_SHORT) | |
12 | return error("switch `%c' %s", opt->short_name, reason); | |
13 | if (flags & OPT_UNSET) | |
14 | return error("option `no-%s' %s", opt->long_name, reason); | |
15 | return error("option `%s' %s", opt->long_name, reason); | |
16 | } | |
17 | ||
1cc6985c PH |
18 | static int get_arg(struct parse_opt_ctx_t *p, const struct option *opt, |
19 | int flags, const char **arg) | |
20 | { | |
21 | if (p->opt) { | |
22 | *arg = p->opt; | |
23 | p->opt = NULL; | |
24 | } else if (p->argc == 1 && (opt->flags & PARSE_OPT_LASTARG_DEFAULT)) { | |
25 | *arg = (const char *)opt->defval; | |
d5d745f9 | 26 | } else if (p->argc > 1) { |
1cc6985c PH |
27 | p->argc--; |
28 | *arg = *++p->argv; | |
29 | } else | |
30 | return opterror(opt, "requires a value", flags); | |
31 | return 0; | |
32 | } | |
33 | ||
7e7bbcb4 | 34 | static int get_value(struct parse_opt_ctx_t *p, |
1cc6985c | 35 | const struct option *opt, int flags) |
4a59fd13 | 36 | { |
ffe659f9 | 37 | const char *s, *arg; |
db7244bd | 38 | const int unset = flags & OPT_UNSET; |
4a59fd13 | 39 | |
db7244bd | 40 | if (unset && p->opt) |
4a59fd13 | 41 | return opterror(opt, "takes no value", flags); |
db7244bd PH |
42 | if (unset && (opt->flags & PARSE_OPT_NONEG)) |
43 | return opterror(opt, "isn't available", flags); | |
4a59fd13 | 44 | |
db7244bd PH |
45 | if (!(flags & OPT_SHORT) && p->opt) { |
46 | switch (opt->type) { | |
47 | case OPTION_CALLBACK: | |
48 | if (!(opt->flags & PARSE_OPT_NOARG)) | |
49 | break; | |
50 | /* FALLTHROUGH */ | |
51 | case OPTION_BOOLEAN: | |
52 | case OPTION_BIT: | |
53 | case OPTION_SET_INT: | |
54 | case OPTION_SET_PTR: | |
4a59fd13 | 55 | return opterror(opt, "takes no value", flags); |
db7244bd PH |
56 | default: |
57 | break; | |
58 | } | |
59 | } | |
60 | ||
db7244bd PH |
61 | switch (opt->type) { |
62 | case OPTION_BIT: | |
63 | if (unset) | |
64 | *(int *)opt->value &= ~opt->defval; | |
4a59fd13 | 65 | else |
db7244bd PH |
66 | *(int *)opt->value |= opt->defval; |
67 | return 0; | |
68 | ||
69 | case OPTION_BOOLEAN: | |
70 | *(int *)opt->value = unset ? 0 : *(int *)opt->value + 1; | |
71 | return 0; | |
72 | ||
73 | case OPTION_SET_INT: | |
74 | *(int *)opt->value = unset ? 0 : opt->defval; | |
75 | return 0; | |
76 | ||
77 | case OPTION_SET_PTR: | |
78 | *(void **)opt->value = unset ? NULL : (void *)opt->defval; | |
4a59fd13 PH |
79 | return 0; |
80 | ||
81 | case OPTION_STRING: | |
1cc6985c | 82 | if (unset) |
db7244bd | 83 | *(const char **)opt->value = NULL; |
1cc6985c | 84 | else if (opt->flags & PARSE_OPT_OPTARG && !p->opt) |
ffe659f9 | 85 | *(const char **)opt->value = (const char *)opt->defval; |
1cc6985c PH |
86 | else |
87 | return get_arg(p, opt, flags, (const char **)opt->value); | |
4a59fd13 PH |
88 | return 0; |
89 | ||
ffe659f9 | 90 | case OPTION_CALLBACK: |
db7244bd | 91 | if (unset) |
07fe54db | 92 | return (*opt->callback)(opt, NULL, 1) ? (-1) : 0; |
db7244bd | 93 | if (opt->flags & PARSE_OPT_NOARG) |
07fe54db | 94 | return (*opt->callback)(opt, NULL, 0) ? (-1) : 0; |
c43a2483 | 95 | if (opt->flags & PARSE_OPT_OPTARG && !p->opt) |
07fe54db | 96 | return (*opt->callback)(opt, NULL, 0) ? (-1) : 0; |
1cc6985c PH |
97 | if (get_arg(p, opt, flags, &arg)) |
98 | return -1; | |
99 | return (*opt->callback)(opt, arg, 0) ? (-1) : 0; | |
ffe659f9 | 100 | |
4a59fd13 | 101 | case OPTION_INTEGER: |
db7244bd | 102 | if (unset) { |
4a59fd13 PH |
103 | *(int *)opt->value = 0; |
104 | return 0; | |
105 | } | |
c43a2483 | 106 | if (opt->flags & PARSE_OPT_OPTARG && !p->opt) { |
ffe659f9 PH |
107 | *(int *)opt->value = opt->defval; |
108 | return 0; | |
109 | } | |
1cc6985c PH |
110 | if (get_arg(p, opt, flags, &arg)) |
111 | return -1; | |
112 | *(int *)opt->value = strtol(arg, (char **)&s, 10); | |
4a59fd13 PH |
113 | if (*s) |
114 | return opterror(opt, "expects a numerical value", flags); | |
115 | return 0; | |
116 | ||
117 | default: | |
118 | die("should not happen, someone must be hit on the forehead"); | |
119 | } | |
120 | } | |
121 | ||
7e7bbcb4 | 122 | static int parse_short_opt(struct parse_opt_ctx_t *p, const struct option *options) |
4a59fd13 PH |
123 | { |
124 | for (; options->type != OPTION_END; options++) { | |
125 | if (options->short_name == *p->opt) { | |
126 | p->opt = p->opt[1] ? p->opt + 1 : NULL; | |
127 | return get_value(p, options, OPT_SHORT); | |
128 | } | |
129 | } | |
07fe54db | 130 | return -2; |
4a59fd13 PH |
131 | } |
132 | ||
7e7bbcb4 | 133 | static int parse_long_opt(struct parse_opt_ctx_t *p, const char *arg, |
4a59fd13 PH |
134 | const struct option *options) |
135 | { | |
7f275b91 | 136 | const char *arg_end = strchr(arg, '='); |
243e0614 JS |
137 | const struct option *abbrev_option = NULL, *ambiguous_option = NULL; |
138 | int abbrev_flags = 0, ambiguous_flags = 0; | |
7f275b91 JS |
139 | |
140 | if (!arg_end) | |
141 | arg_end = arg + strlen(arg); | |
142 | ||
4a59fd13 PH |
143 | for (; options->type != OPTION_END; options++) { |
144 | const char *rest; | |
145 | int flags = 0; | |
146 | ||
147 | if (!options->long_name) | |
148 | continue; | |
149 | ||
150 | rest = skip_prefix(arg, options->long_name); | |
580d5bff PH |
151 | if (options->type == OPTION_ARGUMENT) { |
152 | if (!rest) | |
153 | continue; | |
154 | if (*rest == '=') | |
155 | return opterror(options, "takes no value", flags); | |
156 | if (*rest) | |
157 | continue; | |
158 | p->out[p->cpidx++] = arg - 2; | |
159 | return 0; | |
160 | } | |
4a59fd13 | 161 | if (!rest) { |
7f275b91 JS |
162 | /* abbreviated? */ |
163 | if (!strncmp(options->long_name, arg, arg_end - arg)) { | |
164 | is_abbreviated: | |
243e0614 JS |
165 | if (abbrev_option) { |
166 | /* | |
167 | * If this is abbreviated, it is | |
168 | * ambiguous. So when there is no | |
169 | * exact match later, we need to | |
170 | * error out. | |
171 | */ | |
172 | ambiguous_option = abbrev_option; | |
173 | ambiguous_flags = abbrev_flags; | |
174 | } | |
7f275b91 JS |
175 | if (!(flags & OPT_UNSET) && *arg_end) |
176 | p->opt = arg_end + 1; | |
177 | abbrev_option = options; | |
178 | abbrev_flags = flags; | |
179 | continue; | |
180 | } | |
181 | /* negated and abbreviated very much? */ | |
182 | if (!prefixcmp("no-", arg)) { | |
183 | flags |= OPT_UNSET; | |
184 | goto is_abbreviated; | |
185 | } | |
186 | /* negated? */ | |
4a59fd13 PH |
187 | if (strncmp(arg, "no-", 3)) |
188 | continue; | |
189 | flags |= OPT_UNSET; | |
190 | rest = skip_prefix(arg + 3, options->long_name); | |
7f275b91 JS |
191 | /* abbreviated and negated? */ |
192 | if (!rest && !prefixcmp(options->long_name, arg + 3)) | |
193 | goto is_abbreviated; | |
4a59fd13 PH |
194 | if (!rest) |
195 | continue; | |
196 | } | |
197 | if (*rest) { | |
198 | if (*rest != '=') | |
199 | continue; | |
200 | p->opt = rest + 1; | |
201 | } | |
202 | return get_value(p, options, flags); | |
203 | } | |
243e0614 JS |
204 | |
205 | if (ambiguous_option) | |
206 | return error("Ambiguous option: %s " | |
207 | "(could be --%s%s or --%s%s)", | |
208 | arg, | |
209 | (ambiguous_flags & OPT_UNSET) ? "no-" : "", | |
210 | ambiguous_option->long_name, | |
211 | (abbrev_flags & OPT_UNSET) ? "no-" : "", | |
212 | abbrev_option->long_name); | |
7f275b91 JS |
213 | if (abbrev_option) |
214 | return get_value(p, abbrev_option, abbrev_flags); | |
07fe54db | 215 | return -2; |
4a59fd13 PH |
216 | } |
217 | ||
1121a878 | 218 | static void check_typos(const char *arg, const struct option *options) |
3a9f0f41 PH |
219 | { |
220 | if (strlen(arg) < 3) | |
221 | return; | |
222 | ||
223 | if (!prefixcmp(arg, "no-")) { | |
224 | error ("did you mean `--%s` (with two dashes ?)", arg); | |
225 | exit(129); | |
226 | } | |
227 | ||
228 | for (; options->type != OPTION_END; options++) { | |
229 | if (!options->long_name) | |
230 | continue; | |
231 | if (!prefixcmp(options->long_name, arg)) { | |
232 | error ("did you mean `--%s` (with two dashes ?)", arg); | |
233 | exit(129); | |
234 | } | |
235 | } | |
236 | } | |
237 | ||
7e7bbcb4 PH |
238 | void parse_options_start(struct parse_opt_ctx_t *ctx, |
239 | int argc, const char **argv, int flags) | |
240 | { | |
241 | memset(ctx, 0, sizeof(*ctx)); | |
242 | ctx->argc = argc - 1; | |
243 | ctx->argv = argv + 1; | |
244 | ctx->out = argv; | |
a32a4eaa | 245 | ctx->cpidx = ((flags & PARSE_OPT_KEEP_ARGV0) != 0); |
7e7bbcb4 PH |
246 | ctx->flags = flags; |
247 | } | |
248 | ||
ee68b87a | 249 | static int usage_with_options_internal(const char * const *, |
ff43ec3e | 250 | const struct option *, int); |
dd3bf0f4 | 251 | |
ff43ec3e PH |
252 | int parse_options_step(struct parse_opt_ctx_t *ctx, |
253 | const struct option *options, | |
254 | const char * const usagestr[]) | |
4a59fd13 | 255 | { |
26141b5b PH |
256 | /* we must reset ->opt, unknown short option leave it dangling */ |
257 | ctx->opt = NULL; | |
258 | ||
ff43ec3e PH |
259 | for (; ctx->argc; ctx->argc--, ctx->argv++) { |
260 | const char *arg = ctx->argv[0]; | |
4a59fd13 PH |
261 | |
262 | if (*arg != '-' || !arg[1]) { | |
ff43ec3e | 263 | if (ctx->flags & PARSE_OPT_STOP_AT_NON_OPTION) |
a0ec9d25 | 264 | break; |
ff43ec3e | 265 | ctx->out[ctx->cpidx++] = ctx->argv[0]; |
4a59fd13 PH |
266 | continue; |
267 | } | |
268 | ||
269 | if (arg[1] != '-') { | |
ff43ec3e PH |
270 | ctx->opt = arg + 1; |
271 | if (*ctx->opt == 'h') | |
272 | return parse_options_usage(usagestr, options); | |
07fe54db PH |
273 | switch (parse_short_opt(ctx, options)) { |
274 | case -1: | |
275 | return parse_options_usage(usagestr, options); | |
276 | case -2: | |
277 | return PARSE_OPT_UNKNOWN; | |
278 | } | |
ff43ec3e | 279 | if (ctx->opt) |
3a9f0f41 | 280 | check_typos(arg + 1, options); |
ff43ec3e PH |
281 | while (ctx->opt) { |
282 | if (*ctx->opt == 'h') | |
283 | return parse_options_usage(usagestr, options); | |
07fe54db PH |
284 | switch (parse_short_opt(ctx, options)) { |
285 | case -1: | |
286 | return parse_options_usage(usagestr, options); | |
287 | case -2: | |
26141b5b PH |
288 | /* fake a short option thing to hide the fact that we may have |
289 | * started to parse aggregated stuff | |
290 | * | |
291 | * This is leaky, too bad. | |
292 | */ | |
293 | ctx->argv[0] = xstrdup(ctx->opt - 1); | |
294 | *(char *)ctx->argv[0] = '-'; | |
07fe54db PH |
295 | return PARSE_OPT_UNKNOWN; |
296 | } | |
3a9f0f41 | 297 | } |
4a59fd13 PH |
298 | continue; |
299 | } | |
300 | ||
301 | if (!arg[2]) { /* "--" */ | |
ff43ec3e PH |
302 | if (!(ctx->flags & PARSE_OPT_KEEP_DASHDASH)) { |
303 | ctx->argc--; | |
304 | ctx->argv++; | |
4a59fd13 PH |
305 | } |
306 | break; | |
307 | } | |
308 | ||
dd3bf0f4 | 309 | if (!strcmp(arg + 2, "help-all")) |
ff43ec3e | 310 | return usage_with_options_internal(usagestr, options, 1); |
4a59fd13 | 311 | if (!strcmp(arg + 2, "help")) |
ff43ec3e | 312 | return parse_options_usage(usagestr, options); |
07fe54db PH |
313 | switch (parse_long_opt(ctx, arg + 2, options)) { |
314 | case -1: | |
315 | return parse_options_usage(usagestr, options); | |
316 | case -2: | |
317 | return PARSE_OPT_UNKNOWN; | |
318 | } | |
ff43ec3e PH |
319 | } |
320 | return PARSE_OPT_DONE; | |
321 | } | |
322 | ||
323 | int parse_options_end(struct parse_opt_ctx_t *ctx) | |
324 | { | |
325 | memmove(ctx->out + ctx->cpidx, ctx->argv, ctx->argc * sizeof(*ctx->out)); | |
326 | ctx->out[ctx->cpidx + ctx->argc] = NULL; | |
327 | return ctx->cpidx + ctx->argc; | |
328 | } | |
329 | ||
330 | int parse_options(int argc, const char **argv, const struct option *options, | |
331 | const char * const usagestr[], int flags) | |
332 | { | |
333 | struct parse_opt_ctx_t ctx; | |
334 | ||
335 | parse_options_start(&ctx, argc, argv, flags); | |
336 | switch (parse_options_step(&ctx, options, usagestr)) { | |
337 | case PARSE_OPT_HELP: | |
338 | exit(129); | |
339 | case PARSE_OPT_DONE: | |
340 | break; | |
341 | default: /* PARSE_OPT_UNKNOWN */ | |
07fe54db PH |
342 | if (ctx.argv[0][1] == '-') { |
343 | error("unknown option `%s'", ctx.argv[0] + 2); | |
344 | } else { | |
345 | error("unknown switch `%c'", *ctx.opt); | |
346 | } | |
347 | usage_with_options(usagestr, options); | |
4a59fd13 PH |
348 | } |
349 | ||
7e7bbcb4 | 350 | return parse_options_end(&ctx); |
4a59fd13 | 351 | } |
d7a38c54 PH |
352 | |
353 | #define USAGE_OPTS_WIDTH 24 | |
354 | #define USAGE_GAP 2 | |
355 | ||
ee68b87a | 356 | int usage_with_options_internal(const char * const *usagestr, |
ff43ec3e | 357 | const struct option *opts, int full) |
d7a38c54 | 358 | { |
f389c808 AR |
359 | fprintf(stderr, "usage: %s\n", *usagestr++); |
360 | while (*usagestr && **usagestr) | |
361 | fprintf(stderr, " or: %s\n", *usagestr++); | |
44d86e91 JK |
362 | while (*usagestr) { |
363 | fprintf(stderr, "%s%s\n", | |
364 | **usagestr ? " " : "", | |
365 | *usagestr); | |
366 | usagestr++; | |
367 | } | |
d7a38c54 PH |
368 | |
369 | if (opts->type != OPTION_GROUP) | |
f389c808 | 370 | fputc('\n', stderr); |
d7a38c54 PH |
371 | |
372 | for (; opts->type != OPTION_END; opts++) { | |
373 | size_t pos; | |
374 | int pad; | |
375 | ||
376 | if (opts->type == OPTION_GROUP) { | |
f389c808 | 377 | fputc('\n', stderr); |
d7a38c54 | 378 | if (*opts->help) |
f389c808 | 379 | fprintf(stderr, "%s\n", opts->help); |
d7a38c54 PH |
380 | continue; |
381 | } | |
dd3bf0f4 PH |
382 | if (!full && (opts->flags & PARSE_OPT_HIDDEN)) |
383 | continue; | |
d7a38c54 | 384 | |
f389c808 | 385 | pos = fprintf(stderr, " "); |
d7a38c54 | 386 | if (opts->short_name) |
f389c808 | 387 | pos += fprintf(stderr, "-%c", opts->short_name); |
d7a38c54 | 388 | if (opts->long_name && opts->short_name) |
f389c808 | 389 | pos += fprintf(stderr, ", "); |
d7a38c54 | 390 | if (opts->long_name) |
f389c808 | 391 | pos += fprintf(stderr, "--%s", opts->long_name); |
d7a38c54 PH |
392 | |
393 | switch (opts->type) { | |
580d5bff PH |
394 | case OPTION_ARGUMENT: |
395 | break; | |
d7a38c54 | 396 | case OPTION_INTEGER: |
ffe659f9 | 397 | if (opts->flags & PARSE_OPT_OPTARG) |
6422f633 MB |
398 | if (opts->long_name) |
399 | pos += fprintf(stderr, "[=<n>]"); | |
400 | else | |
401 | pos += fprintf(stderr, "[<n>]"); | |
ffe659f9 PH |
402 | else |
403 | pos += fprintf(stderr, " <n>"); | |
d7a38c54 | 404 | break; |
ffe659f9 | 405 | case OPTION_CALLBACK: |
f481e22a PH |
406 | if (opts->flags & PARSE_OPT_NOARG) |
407 | break; | |
408 | /* FALLTHROUGH */ | |
409 | case OPTION_STRING: | |
ffe659f9 PH |
410 | if (opts->argh) { |
411 | if (opts->flags & PARSE_OPT_OPTARG) | |
6422f633 MB |
412 | if (opts->long_name) |
413 | pos += fprintf(stderr, "[=<%s>]", opts->argh); | |
414 | else | |
415 | pos += fprintf(stderr, "[<%s>]", opts->argh); | |
ffe659f9 PH |
416 | else |
417 | pos += fprintf(stderr, " <%s>", opts->argh); | |
418 | } else { | |
419 | if (opts->flags & PARSE_OPT_OPTARG) | |
6422f633 MB |
420 | if (opts->long_name) |
421 | pos += fprintf(stderr, "[=...]"); | |
422 | else | |
423 | pos += fprintf(stderr, "[...]"); | |
ffe659f9 PH |
424 | else |
425 | pos += fprintf(stderr, " ..."); | |
426 | } | |
d7a38c54 | 427 | break; |
db7244bd | 428 | default: /* OPTION_{BIT,BOOLEAN,SET_INT,SET_PTR} */ |
d7a38c54 PH |
429 | break; |
430 | } | |
431 | ||
f389c808 AR |
432 | if (pos <= USAGE_OPTS_WIDTH) |
433 | pad = USAGE_OPTS_WIDTH - pos; | |
d7a38c54 | 434 | else { |
f389c808 | 435 | fputc('\n', stderr); |
d7a38c54 PH |
436 | pad = USAGE_OPTS_WIDTH; |
437 | } | |
f389c808 | 438 | fprintf(stderr, "%*s%s\n", pad + USAGE_GAP, "", opts->help); |
d7a38c54 | 439 | } |
f389c808 AR |
440 | fputc('\n', stderr); |
441 | ||
ee68b87a | 442 | return PARSE_OPT_HELP; |
d7a38c54 | 443 | } |
0ce865b1 | 444 | |
dd3bf0f4 | 445 | void usage_with_options(const char * const *usagestr, |
ff43ec3e | 446 | const struct option *opts) |
dd3bf0f4 | 447 | { |
ff43ec3e PH |
448 | usage_with_options_internal(usagestr, opts, 0); |
449 | exit(129); | |
dd3bf0f4 PH |
450 | } |
451 | ||
ee68b87a PH |
452 | int parse_options_usage(const char * const *usagestr, |
453 | const struct option *opts) | |
454 | { | |
ff43ec3e | 455 | return usage_with_options_internal(usagestr, opts, 0); |
ee68b87a PH |
456 | } |
457 | ||
458 | ||
0ce865b1 PH |
459 | /*----- some often used options -----*/ |
460 | #include "cache.h" | |
db7244bd | 461 | |
0ce865b1 PH |
462 | int parse_opt_abbrev_cb(const struct option *opt, const char *arg, int unset) |
463 | { | |
464 | int v; | |
465 | ||
466 | if (!arg) { | |
467 | v = unset ? 0 : DEFAULT_ABBREV; | |
468 | } else { | |
469 | v = strtol(arg, (char **)&arg, 10); | |
470 | if (*arg) | |
471 | return opterror(opt, "expects a numerical value", 0); | |
472 | if (v && v < MINIMUM_ABBREV) | |
473 | v = MINIMUM_ABBREV; | |
474 | else if (v > 40) | |
475 | v = 40; | |
476 | } | |
477 | *(int *)(opt->value) = v; | |
478 | return 0; | |
479 | } | |
1f4a711a MB |
480 | |
481 | int parse_opt_approxidate_cb(const struct option *opt, const char *arg, | |
482 | int unset) | |
483 | { | |
484 | *(unsigned long *)(opt->value) = approxidate(arg); | |
485 | return 0; | |
486 | } | |
dbd0f5c7 | 487 | |
7f87aff2 TA |
488 | int parse_opt_verbosity_cb(const struct option *opt, const char *arg, |
489 | int unset) | |
490 | { | |
491 | int *target = opt->value; | |
492 | ||
493 | if (unset) | |
494 | /* --no-quiet, --no-verbose */ | |
495 | *target = 0; | |
496 | else if (opt->short_name == 'v') { | |
497 | if (*target >= 0) | |
498 | (*target)++; | |
499 | else | |
500 | *target = 1; | |
501 | } else { | |
502 | if (*target <= 0) | |
503 | (*target)--; | |
504 | else | |
505 | *target = -1; | |
506 | } | |
507 | return 0; | |
508 | } | |
509 | ||
269defdf JG |
510 | int parse_opt_with_commit(const struct option *opt, const char *arg, int unset) |
511 | { | |
512 | unsigned char sha1[20]; | |
513 | struct commit *commit; | |
514 | ||
515 | if (!arg) | |
516 | return -1; | |
517 | if (get_sha1(arg, sha1)) | |
518 | return error("malformed object name %s", arg); | |
519 | commit = lookup_commit_reference(sha1); | |
520 | if (!commit) | |
521 | return error("no such commit %s", arg); | |
522 | commit_list_insert(commit, opt->value); | |
523 | return 0; | |
524 | } | |
525 | ||
dbd0f5c7 JH |
526 | /* |
527 | * This should really be OPTION_FILENAME type as a part of | |
528 | * parse_options that take prefix to do this while parsing. | |
529 | */ | |
530 | extern const char *parse_options_fix_filename(const char *prefix, const char *file) | |
531 | { | |
532 | if (!file || !prefix || is_absolute_path(file) || !strcmp("-", file)) | |
533 | return file; | |
534 | return prefix_filename(prefix, strlen(prefix), file); | |
535 | } | |
536 |