From d11eb7755cffa6a8796c5922ee06499acfcb120c Mon Sep 17 00:00:00 2001 From: millert <> Date: Sun, 8 Dec 2002 19:25:08 +0000 Subject: Test option "-" (BSD extension) --- src/regress/lib/libc/getopt_long/Makefile | 11 ++++++----- src/regress/lib/libc/getopt_long/getopt_long_test.c | 3 ++- src/regress/lib/libc/getopt_long/test.ok | 12 ++++++++---- 3 files changed, 16 insertions(+), 10 deletions(-) (limited to 'src/regress/lib/libc') diff --git a/src/regress/lib/libc/getopt_long/Makefile b/src/regress/lib/libc/getopt_long/Makefile index 7729261079..13a187e190 100644 --- a/src/regress/lib/libc/getopt_long/Makefile +++ b/src/regress/lib/libc/getopt_long/Makefile @@ -1,7 +1,8 @@ -# $OpenBSD: Makefile,v 1.3 2002/12/07 19:57:24 millert Exp $ +# $OpenBSD: Makefile,v 1.4 2002/12/08 19:25:08 millert Exp $ NOMAN= PROG=getopt_long_test +CLEANFILES+=test.out # test getopt_long and getopt_long_only run-regress-${PROG}: ${PROG} @@ -9,22 +10,22 @@ run-regress-${PROG}: ${PROG} test -n "$$LONG_ONLY" && unset LONG_ONLY; \ ./${PROG} myfile --force -f infile -9 ; \ ./${PROG} onefile twofile --best -Williterate -i foo.in threefile ; \ - ./${PROG} -1bfast ; \ + ./${PROG} -1bfast - ; \ ./${PROG} --fast --drinking=guiness -i foo.in somefile ; \ export POSIXLY_CORRECT=1 ; \ ./${PROG} myfile --force -f infile -9 ; \ ./${PROG} onefile twofile --best -Williterate -i foo.in threefile ; \ - ./${PROG} -1bfast ; \ + ./${PROG} -1bfast - ; \ ./${PROG} --fast --drinking=guiness -i foo.in somefile ; \ unset POSIXLY_CORRECT ; export LONG_ONLY=1 ; \ ./${PROG} myfile -force -f infile -9 ; \ ./${PROG} onefile twofile -best -Williterate -i foo.in threefile ; \ - ./${PROG} -1bfast ; \ + ./${PROG} -1bfast - ; \ ./${PROG} --fast -drinking=guiness -i foo.in somefile ; \ export POSIXLY_CORRECT=1 ; \ ./${PROG} myfile -force -f infile -9 ; \ ./${PROG} onefile twofile -best -Williterate -i foo.in threefile ; \ - ./${PROG} -1bfast ; \ + ./${PROG} -1bfast - ; \ ./${PROG} --fast -drinking=guiness -i foo.in somefile ) >test.out 2>&1 cmp -s ${.OBJDIR}/test.out ${.CURDIR}/test.ok diff --git a/src/regress/lib/libc/getopt_long/getopt_long_test.c b/src/regress/lib/libc/getopt_long/getopt_long_test.c index b15613d982..27a2dc4a5f 100644 --- a/src/regress/lib/libc/getopt_long/getopt_long_test.c +++ b/src/regress/lib/libc/getopt_long/getopt_long_test.c @@ -67,7 +67,7 @@ main(int argc, char **argv) goggles = 0; for (;;) { idx = -1; - ch = gl(argc, argv, "19bf:i:hW;", longopts, &idx); + ch = gl(argc, argv, "19bf:i:hW;-", longopts, &idx); if (ch == -1) break; switch (ch) { @@ -76,6 +76,7 @@ main(int argc, char **argv) case '9': case 'h': case 'b': + case '-': if (idx != -1) { if (goggles == 42) printf("option %s, arg %s\n", diff --git a/src/regress/lib/libc/getopt_long/test.ok b/src/regress/lib/libc/getopt_long/test.ok index 124422f964..9782087f40 100644 --- a/src/regress/lib/libc/getopt_long/test.ok +++ b/src/regress/lib/libc/getopt_long/test.ok @@ -10,10 +10,11 @@ option illiterate option i, arg foo.in remaining ARGV: onefile twofile threefile -getopt_long: -1bfast +getopt_long: -1bfast - option 1 option b option f, arg ast +option - getopt_long: --fast --drinking=guiness -i foo.in somefile option fast @@ -27,10 +28,11 @@ remaining ARGV: myfile --force -f infile -9 getopt_long (POSIXLY_CORRECT): onefile twofile --best -Williterate -i foo.in threefile remaining ARGV: onefile twofile --best -Williterate -i foo.in threefile -getopt_long (POSIXLY_CORRECT): -1bfast +getopt_long (POSIXLY_CORRECT): -1bfast - option 1 option b option f, arg ast +option - getopt_long (POSIXLY_CORRECT): --fast --drinking=guiness -i foo.in somefile option fast @@ -50,10 +52,11 @@ option illiterate option i, arg foo.in remaining ARGV: onefile twofile threefile -getopt_long_only: -1bfast +getopt_long_only: -1bfast - option 1 option b option fast +option - getopt_long_only: --fast -drinking=guiness -i foo.in somefile option fast @@ -67,10 +70,11 @@ remaining ARGV: myfile -force -f infile -9 getopt_long_only (POSIXLY_CORRECT): onefile twofile -best -Williterate -i foo.in threefile remaining ARGV: onefile twofile -best -Williterate -i foo.in threefile -getopt_long_only (POSIXLY_CORRECT): -1bfast +getopt_long_only (POSIXLY_CORRECT): -1bfast - option 1 option b option fast +option - getopt_long_only (POSIXLY_CORRECT): --fast -drinking=guiness -i foo.in somefile option fast -- cgit v1.2.3-55-g6feb