diff options
author | Jens Axboe <axboe@kernel.dk> | 2011-10-18 13:26:01 +0200 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2011-10-18 13:26:01 +0200 |
commit | 9f170691560bacdcd8cef6296d14fc0a8467a9dd (patch) | |
tree | 817acf94b7c38ef6139acc10383ccad1e1dedc08 /lib/getopt_long.c | |
parent | 203913ea773a19dce4a885204e9d7681b89429fe (diff) | |
download | fio-9f170691560bacdcd8cef6296d14fc0a8467a9dd.tar.gz |
Fix klibc getopt_long_only() for optional arguments
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'lib/getopt_long.c')
-rw-r--r-- | lib/getopt_long.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/getopt_long.c b/lib/getopt_long.c index 6e8abc06..70894e32 100644 --- a/lib/getopt_long.c +++ b/lib/getopt_long.c @@ -126,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 { |