* - 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 <stdint.h>
#include <unistd.h>
#include <string.h>
-#include <getopt.h>
+
+#include "getopt.h"
char *optarg;
int optind, opterr, optopt;
} 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 {