From 9620ff2d6f16ccd16e027bcb5ada961d9d0b8fc0 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Sat, 21 Jan 2023 15:25:30 +0000 Subject: QoL: subgetopt should return ? on --long Signed-off-by: Laurent Bercot --- src/libstddjb/subgetopt.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/libstddjb') diff --git a/src/libstddjb/subgetopt.c b/src/libstddjb/subgetopt.c index 940eb6a..6383a26 100644 --- a/src/libstddjb/subgetopt.c +++ b/src/libstddjb/subgetopt.c @@ -16,19 +16,18 @@ int subgetopt_r (int argc, char const *const *argv, char const *opts, subgetopt if (!o->pos) { + char c ; if (argv[o->ind][0] != '-') return -1 ; - else + o->pos++ ; + c = argv[o->ind][1] ; + if (c == '-') { - char c ; - o->pos++ ; - c = argv[o->ind][1] ; - if (c == '-') o->ind++ ; - if (!c || (c == '-')) - { - o->pos = 0 ; - return -1 ; - } + if (argv[o->ind][2]) return o->problem = '-', '?' ; + o->ind++ ; + o->pos = 0 ; + return -1 ; } + if (!c || c == '-') return o->pos = 0, -1 ; } { char c = argv[o->ind][o->pos++] ; -- cgit v1.2.3