summaryrefslogtreecommitdiff
path: root/src/libstddjb
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2023-01-21 15:25:30 +0000
committerLaurent Bercot <ska@appnovation.com>2023-01-21 15:25:30 +0000
commit9620ff2d6f16ccd16e027bcb5ada961d9d0b8fc0 (patch)
tree24d057ae002265475ceff50ae0db1c172e1d821d /src/libstddjb
parent54b77bb078333ecf576a6b59ba9b26354d855d09 (diff)
downloadskalibs-9620ff2d6f16ccd16e027bcb5ada961d9d0b8fc0.tar.xz
QoL: subgetopt should return ? on --long
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/libstddjb')
-rw-r--r--src/libstddjb/subgetopt.c19
1 files changed, 9 insertions, 10 deletions
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++] ;