X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=lib%2Fgetopt_long.c;h=70894e3281e04f7830cc583c2079affb9c545518;hp=3d80627f5395c6bba4d5d28ac73170c46290e198;hb=9f170691560bacdcd8cef6296d14fc0a8467a9dd;hpb=bf2e821a55d8aa3de1cda7288a0e22883110fdc6 diff --git a/lib/getopt_long.c b/lib/getopt_long.c index 3d80627f..70894e32 100644 --- a/lib/getopt_long.c +++ b/lib/getopt_long.c @@ -6,12 +6,15 @@ * - Option reordering is not supported * - -W foo is not supported * - First optstring character "-" not supported. + * + * This file was imported from the klibc library from hpa */ #include #include #include -#include + +#include "getopt.h" char *optarg; int optind, opterr, optopt; @@ -123,7 +126,16 @@ int getopt_long_only(int argc, char *const *argv, const char *optstring, } else { /* Argument-taking option with non-attached argument */ - if (argv[optind + 1]) { + if (osptr[2] == ':') { + if (argv[optind + 1]) { + optarg = (char *)argv[optind+1]; + optind += 2; + } else { + optarg = NULL; + optind++; + } + return opt; + } else if (argv[optind + 1]) { optarg = (char *)argv[optind+1]; optind += 2; } else {