- for (p = first_lopt(&i, &len); p; p = next_lopt(p, &i, &len)) {
- if (index == 0) {
- *name = p;
- return &opt_table[i];
- }
- index--;
- }
- abort();
-}
-
-/* glibc does this as:
-/tmp/opt-example: invalid option -- 'x'
-/tmp/opt-example: unrecognized option '--long'
-/tmp/opt-example: option '--someflag' doesn't allow an argument
-/tmp/opt-example: option '--s' is ambiguous
-/tmp/opt-example: option requires an argument -- 's'
-*/
-static void parse_fail(void (*errlog)(const char *fmt, ...),
- char shortopt, const char *longopt, const char *problem)
-{
- if (shortopt)
- errlog("%s: -%c: %s", opt_argv0, shortopt, problem);
- else
- errlog("%s: --%.*s: %s", opt_argv0,
- strcspn(longopt, "/"), longopt, problem);
-}
+ /* We could avoid a copy and skip instead, but this is simple. */
+ memcpy(tmpargv, argv, sizeof(argv[0]) * (argc + 1));