diff --git a/examples/long.c b/examples/long.c index 00993fa..4ba63b9 100644 --- a/examples/long.c +++ b/examples/long.c @@ -48,7 +48,12 @@ int main(int argc, char **argv) } } - /* Print remaining arguments. */ + printf("amend : %s\n", amend ? "true" : "false"); + printf("brief : %s\n", brief ? "true" : "false"); + printf("color : %s\n", color); + printf("delay : %d\n", delay); + + printf("Print remaining arguments:\n"); while ((arg = optparse_arg(&options))) printf("%s\n", arg); diff --git a/optparse.h b/optparse.h index 9b7c7f8..00bcea1 100644 --- a/optparse.h +++ b/optparse.h @@ -256,6 +256,13 @@ optparse(struct optparse *options, const char *optstring) options->optind++; if (option[1]) options->optarg = option + 1; +#ifdef IMPROVED_OPTPARSE_OPTIONAL + else if (next && next[0] != '-') + { + options->optarg = next; + options->optind++; + } +#endif else options->optarg = 0; return option[0];