fix again

This commit is contained in:
2026-07-01 13:46:22 +03:00
parent 566ca36af8
commit 503325b68f
3 changed files with 16 additions and 8 deletions

View File

@@ -56,7 +56,7 @@ static glob_pars const Gdefault = {
// you can repeat the same `val` for several long-only options without any problem
static sl_option_t cmdlnopts[] = {
// short option in only-long options should be zeroed, or you can add flag to set it to given value
{"lo0", NEED_ARG, NULL, 0, arg_int, APTR(&G.lo0), _("only long arg 0 (int)")},
{"longonly",NEED_ARG, NULL, 0, arg_int, APTR(&G.lo0), _("only long arg 0 (int)")},
// for short-only options long option can be NULL
{NULL, NEED_ARG, NULL, '0', arg_string, APTR(&G.so1), _("only short arg 1 (string)")},
// if you change `arg_int` to `arg_none`, value will be incremented each `-h`
@@ -73,7 +73,7 @@ static sl_option_t cmdlnopts[] = {
{"Int", MULT_PAR, NULL, 'I', arg_int, APTR(&G.intarr), _("integer parameter")},
{"Dbl", MULT_PAR, NULL, 'D', arg_double, APTR(&G.dblarr), _("double parameter")},
{"Str", MULT_PAR, NULL, 'S', arg_string, APTR(&G.strarr), _("string parameter")},
{"lo1", NEED_ARG, NULL, 0, arg_int, APTR(&G.lo1), _("only long arg 1 (int)")},
{"long1", NEED_ARG, NULL, 0, arg_int, APTR(&G.lo1), _("only long arg 1 (int)")},
end_option
};

View File

@@ -93,9 +93,9 @@ int main(int argc, char *argv[]){
printf("String[%d]: \"%s\"\n", i, *p++);
}
}
if(GP->lo0 != INT_MIN) printf("You set lo0 to %d\n", GP->lo0);
if(GP->lo1 != INT_MIN) printf("You set lo1 to %d\n", GP->lo1);
if(GP->lo2 != INT_MIN) printf("You set lo2 to %d\n", GP->lo2);
if(GP->lo0 != INT_MIN) printf("You set long 0 to %d\n", GP->lo0);
if(GP->lo1 != INT_MIN) printf("You set long 1 to %d\n", GP->lo1);
if(GP->lo2 != INT_MIN) printf("You set long 2 to %d\n", GP->lo2);
if(GP->so1){
sl_remove_quotes(GP->so1);
printf("String so1=%s\n", GP->so1);