# HG changeset patch # User Mike Becker # Date 1593942444 -7200 # Node ID c401f4af44b1105287c70f9159927f8fedd2b776 # Parent 2b8a65ed6f4c6c0cba82b8be984b843a62bf33b7 adds support for option terminator '--' also adds support for option arguments within the same cmd arg e.g. -omyoutfile does now work diff -r 2b8a65ed6f4c -r c401f4af44b1 dav/optparser.c --- a/dav/optparser.c Sun Apr 05 11:06:34 2020 +0200 +++ b/dav/optparser.c Sun Jul 05 11:47:24 2020 +0200 @@ -53,16 +53,27 @@ char *option = NULL; char optchar = 0; + int optterminated = 0; for(int i=0;i 1 && arg[0] == '-') { + if(len == 2 && arg[0] == '-' && arg[1] == '-') { + optterminated = 1; + } else if(!optterminated && len > 1 && arg[0] == '-') { + // argument is in next arg but starts with a dash + // we assume this is not intended and consider this an error + if(option) { + fprintf(stderr, + "Missing argument for option -%c\n\n", optchar); + cmd_args_free(a); + return NULL; + } for(int c=1;coptions, option, &arg[c]); + option = NULL; + break; } switch(arg[c]) {