diff options
-rw-r--r-- | compat_getsubopt.c | 10 | ||||
-rwxr-xr-x | configure | 4 | ||||
-rw-r--r-- | test-getsubopt.c | 23 |
3 files changed, 22 insertions, 15 deletions
diff --git a/compat_getsubopt.c b/compat_getsubopt.c index 3a4a7d4a..7f675749 100644 --- a/compat_getsubopt.c +++ b/compat_getsubopt.c @@ -6,6 +6,7 @@ int dummy; #else +/* $Id$ */ /* $OpenBSD: getsubopt.c,v 1.4 2005/08/08 08:05:36 espie Exp $ */ /*- @@ -41,18 +42,11 @@ int dummy; #include <stdlib.h> #include <string.h> -/* - * The SVID interface to getsubopt provides no way of figuring out which - * part of the suboptions list wasn't matched. This makes error messages - * tricky... The extern variable suboptarg is a pointer to the token - * which didn't match. - */ -char *suboptarg; - int getsubopt(char **optionp, char * const *tokens, char **valuep) { int cnt; + char *suboptarg; char *p; suboptarg = *valuep = NULL; @@ -305,10 +305,8 @@ __HEREDOC__ [ ${HAVE_FGETLN} -eq 0 ] && \ echo "extern char *fgetln(FILE *, size_t *);" -if [ ${HAVE_GETSUBOPT} -eq 0 ]; then +[ ${HAVE_GETSUBOPT} -eq 0 ] && \ echo "extern int getsubopt(char **, char * const *, char **);" - echo "extern char *suboptarg;" -fi [ ${HAVE_REALLOCARRAY} -eq 0 ] && \ echo "extern void *reallocarray(void *, size_t, size_t);" diff --git a/test-getsubopt.c b/test-getsubopt.c index 2da98238..1a29d3e4 100644 --- a/test-getsubopt.c +++ b/test-getsubopt.c @@ -1,11 +1,26 @@ +/* $Id$ */ +/* + * Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv> + * + * 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. + */ + #if defined(__linux__) || defined(__MINT__) -# define _GNU_SOURCE /* getsubopt() */ +#define _GNU_SOURCE /* getsubopt() */ #endif #include <stdlib.h> -extern char *suboptarg; - int main(void) { @@ -15,5 +30,5 @@ main(void) char *const tokens[] = { token0, NULL }; char *value = NULL; return( ! (0 == getsubopt(&options, tokens, &value) - && suboptarg == buf && value == buf+2 && options == buf+3)); + && value == buf+2 && options == buf+3)); } |