From eb8dd9dca1228af0cd132f515509051ecfabf6f6 Mon Sep 17 00:00:00 2001 From: cvs2svn Date: Mon, 14 Apr 2025 17:32:06 +0000 Subject: This commit was manufactured by cvs2git to create tag 'tb_20250414'. --- src/regress/lib/libc/getopt/Makefile | 10 --- src/regress/lib/libc/getopt/getopt-test.c | 59 ------------- src/regress/lib/libc/getopt/getopt.sh | 136 ------------------------------ 3 files changed, 205 deletions(-) delete mode 100644 src/regress/lib/libc/getopt/Makefile delete mode 100644 src/regress/lib/libc/getopt/getopt-test.c delete mode 100644 src/regress/lib/libc/getopt/getopt.sh (limited to 'src/regress/lib/libc/getopt') diff --git a/src/regress/lib/libc/getopt/Makefile b/src/regress/lib/libc/getopt/Makefile deleted file mode 100644 index bdafc965fe..0000000000 --- a/src/regress/lib/libc/getopt/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# $OpenBSD: Makefile,v 1.1 2020/03/23 03:01:21 schwarze Exp $ - -REGRESS_TARGETS = getopt -PROG = getopt-test -MAN = - -getopt: ${PROG} - sh ${.CURDIR}/getopt.sh - -.include diff --git a/src/regress/lib/libc/getopt/getopt-test.c b/src/regress/lib/libc/getopt/getopt-test.c deleted file mode 100644 index 40901dcfcf..0000000000 --- a/src/regress/lib/libc/getopt/getopt-test.c +++ /dev/null @@ -1,59 +0,0 @@ -/* $OpenBSD: getopt-test.c,v 1.1 2020/03/23 03:01:21 schwarze Exp $ */ -/* - * Copyright (c) 2020 Ingo Schwarze - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ -#include -#include -#include - -/* - * Process command line options and arguments according to the - * optstring in the environment variable OPTS. Write: - * OPT(c) for an option "-c" without an option argument - * OPT(carg) for an option "-c" with an option argument "arg" - * ARG(arg) for a non-option argument "arg" - * NONE(arg) for a non-option argument "arg" processed with OPTS =~ ^- - * ERR(?c) for an invalid option "-c", or one lacking an argument - * ERR(:c) for an option "-c" lacking an argument while OPTS =~ ^: - */ -int -main(int argc, char *argv[]) -{ - char *optstring; - int ch; - - if ((optstring = getenv("OPTS")) == NULL) - optstring = ""; - - opterr = 0; - while ((ch = getopt(argc, argv, optstring)) != -1) { - switch (ch) { - case '\1': - printf("NONE(%s)", optarg); - break; - case ':': - case '?': - printf("ERR(%c%c)", ch, optopt); - break; - default: - printf("OPT(%c%s)", ch, optarg == NULL ? "" : optarg); - break; - } - } - while (optind < argc) - printf("ARG(%s)", argv[optind++]); - putchar('\n'); - return 0; -} diff --git a/src/regress/lib/libc/getopt/getopt.sh b/src/regress/lib/libc/getopt/getopt.sh deleted file mode 100644 index 6e02163d5b..0000000000 --- a/src/regress/lib/libc/getopt/getopt.sh +++ /dev/null @@ -1,136 +0,0 @@ -#!/bin/sh -# -# $OpenBSD: getopt.sh,v 1.2 2020/05/27 22:32:22 schwarze Exp $ -# -# Copyright (c) 2020 Ingo Schwarze -# -# Permission to use, copy, modify, and distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -# Run ./getopt-test once. -# Function arguments: -# 1. optstring argument for getopt(3) -# 2. space-separated command line arguments -# 3. expected output from ./getopt-test -test1_getopt() -{ - result=$(OPTS=$1 ./getopt-test $2) - test "$result" == "$3" && return - echo "OPTS=$1 ./getopt-test $2" - echo "expected: $3" - echo "result: $result" - irc=1 -} - -# Test both without and with the optstring modifier "+", -# verifying that it makes no difference. -test2_getopt() -{ - test1_getopt "$1" "$2" "$3" - test1_getopt "+$1" "$2" "$3" -} - -# Also test with the GNU "-" optstring modifier, -# veryfying that it only changes ARG() to NONE(). -# This test function is inadequate in two situations: -# a) options follow non-option arguments that terminate option processing -# b) or any arguments follow explicit "--". -# In these cases, use test2_getopt() plus a separate test1_getopt(-...). -test3_getopt() -{ - test2_getopt "$1" "$2" "$3" - test1_getopt "-$1" "$2" $(echo $3 | sed s/ARG/NONE/g) -} - -irc=0 - -# valid isolated options without arguments -test3_getopt ax '-a -x arg' 'OPT(a)OPT(x)ARG(arg)' -test3_getopt x- '- -x arg' 'OPT(-)OPT(x)ARG(arg)' - -# invalid isolated options without arguments -test3_getopt ax '-a -y arg' 'OPT(a)ERR(?y)ARG(arg)' -test1_getopt :ax '-a -y arg' 'OPT(a)ERR(?y)ARG(arg)' -test2_getopt x '- -x arg' 'ARG(-)ARG(-x)ARG(arg)' -test1_getopt -x '- -x arg' 'NONE(-)OPT(x)NONE(arg)' -test3_getopt a- '-a - -x arg' 'OPT(a)OPT(-)ERR(?x)ARG(arg)' -test1_getopt :a- '-a - -x arg' 'OPT(a)OPT(-)ERR(?x)ARG(arg)' - -# valid grouped options without arguments -test3_getopt ax '-ax arg' 'OPT(a)OPT(x)ARG(arg)' -test3_getopt ax- '-a- -x arg' 'OPT(a)OPT(-)OPT(x)ARG(arg)' -test3_getopt abx- '-a-b -x arg' 'OPT(a)OPT(-)OPT(b)OPT(x)ARG(arg)' -test3_getopt ax- '--a -x arg' 'OPT(-)OPT(a)OPT(x)ARG(arg)' - -# invalid grouped options without arguments -test3_getopt ax '-ay arg' 'OPT(a)ERR(?y)ARG(arg)' -test1_getopt :ax '-ay arg' 'OPT(a)ERR(?y)ARG(arg)' -test3_getopt ax '-a- -x arg' 'OPT(a)ERR(?-)OPT(x)ARG(arg)' -test1_getopt :ax '-a- -x arg' 'OPT(a)ERR(?-)OPT(x)ARG(arg)' -test3_getopt abx '-a-b -x arg' 'OPT(a)ERR(?-)OPT(b)OPT(x)ARG(arg)' -test1_getopt :abx '-a-b -x arg' 'OPT(a)ERR(?-)OPT(b)OPT(x)ARG(arg)' -test3_getopt ax '--a -x arg' 'ERR(?-)OPT(a)OPT(x)ARG(arg)' -test1_getopt :ax '--a -x arg' 'ERR(?-)OPT(a)OPT(x)ARG(arg)' - -# non-option arguments terminating option processing -test2_getopt ax '-a arg -x' 'OPT(a)ARG(arg)ARG(-x)' -test1_getopt -ax '-a arg1 -x arg2' 'OPT(a)NONE(arg1)OPT(x)NONE(arg2)' -test2_getopt ax '-a -- -x' 'OPT(a)ARG(-x)' -test1_getopt -ax '-a -- -x' 'OPT(a)ARG(-x)' -test2_getopt ax '-a - -x' 'OPT(a)ARG(-)ARG(-x)' -test1_getopt -ax '-a - -x arg' 'OPT(a)NONE(-)OPT(x)NONE(arg)' - -# the ':' option never works -test1_getopt ::a '-:a arg' 'ERR(?:)OPT(a)ARG(arg)' -test1_getopt :::a '-: arg -a' 'ERR(?:)ARG(arg)ARG(-a)' - -# isolated options with arguments -test3_getopt o: '-o' 'ERR(?o)' -test1_getopt :o: '-o' 'ERR(:o)' -test3_getopt o-: '-' 'ERR(?-)' -test1_getopt :-: '-' 'ERR(:-)' -test3_getopt o:x '-o arg -x arg' 'OPT(oarg)OPT(x)ARG(arg)' -test3_getopt o:x '-oarg -x arg' 'OPT(oarg)OPT(x)ARG(arg)' -test3_getopt o::x '-oarg -x arg' 'OPT(oarg)OPT(x)ARG(arg)' -test2_getopt o::x '-o arg -x' 'OPT(o)ARG(arg)ARG(-x)' -test1_getopt -o::x '-o arg1 -x arg2' 'OPT(o)NONE(arg1)OPT(x)NONE(arg2)' -test3_getopt o:x '-o -x arg' 'OPT(o-x)ARG(arg)' -test3_getopt o:x '-o -- -x arg' 'OPT(o--)OPT(x)ARG(arg)' -test3_getopt x-: '- arg -x arg' 'OPT(-arg)OPT(x)ARG(arg)' -test3_getopt x-: '--arg -x arg' 'OPT(-arg)OPT(x)ARG(arg)' -test3_getopt x-:: '--arg -x arg' 'OPT(-arg)OPT(x)ARG(arg)' -test2_getopt x-:: '- arg -x' 'OPT(-)ARG(arg)ARG(-x)' -test1_getopt --::x '- arg1 -x arg2' 'OPT(-)NONE(arg1)OPT(x)NONE(arg2)' -test3_getopt x-: '- -x arg' 'OPT(--x)ARG(arg)' -test3_getopt x-: '- -- -x arg' 'OPT(---)OPT(x)ARG(arg)' - -# grouped options with arguments -test3_getopt ao: '-ao' 'OPT(a)ERR(?o)' -test1_getopt :ao: '-ao' 'OPT(a)ERR(:o)' -test3_getopt a-: '-a-' 'OPT(a)ERR(?-)' -test1_getopt :a-: '-a-' 'OPT(a)ERR(:-)' -test3_getopt ao:x '-ao arg -x arg' 'OPT(a)OPT(oarg)OPT(x)ARG(arg)' -test3_getopt ao:x '-aoarg -x arg' 'OPT(a)OPT(oarg)OPT(x)ARG(arg)' -test3_getopt ao::x '-aoarg -x arg' 'OPT(a)OPT(oarg)OPT(x)ARG(arg)' -test2_getopt ao::x '-ao arg -x' 'OPT(a)OPT(o)ARG(arg)ARG(-x)' -test1_getopt -ao::x '-ao arg1 -x arg2' 'OPT(a)OPT(o)NONE(arg1)OPT(x)NONE(arg2)' -test3_getopt ao:x '-ao -x arg' 'OPT(a)OPT(o-x)ARG(arg)' -test3_getopt ao:x '-ao -- -x arg' 'OPT(a)OPT(o--)OPT(x)ARG(arg)' -test3_getopt a-:x '-a- arg -x arg' 'OPT(a)OPT(-arg)OPT(x)ARG(arg)' -test3_getopt a-:x '-a-arg -x arg' 'OPT(a)OPT(-arg)OPT(x)ARG(arg)' -test3_getopt a-::x '-a-arg -x arg' 'OPT(a)OPT(-arg)OPT(x)ARG(arg)' -test2_getopt a-::x '-a- arg -x' 'OPT(a)OPT(-)ARG(arg)ARG(-x)' -test1_getopt -a-::x '-a- arg1 -x arg2' 'OPT(a)OPT(-)NONE(arg1)OPT(x)NONE(arg2)' -test3_getopt a-:x '-a- -x arg' 'OPT(a)OPT(--x)ARG(arg)' -test3_getopt a-:x '-a- -- -x arg' 'OPT(a)OPT(---)OPT(x)ARG(arg)' - -exit $irc -- cgit v1.2.3-55-g6feb