There are two instances of getsubopt.c, one in gen, which came by the

ways of 386BSD, and one in stdlib, which is from Lite-2.  The former was
picked up by the build process and has seen a little more maintenance
while the latter's location is "right", so bring the latter up to par
with the former and dispose of the (now) latter.

Reported by David A. Holland in PR lib/25160, which is worded in a
far less mind-boggling fashion than the above.
This commit is contained in:
kleink 2004-05-09 19:34:11 +00:00
parent b706bc6de5
commit f379d2c8ac
3 changed files with 11 additions and 119 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile.inc,v 1.129 2004/04/21 01:05:32 christos Exp $
# $NetBSD: Makefile.inc,v 1.130 2004/05/09 19:34:11 kleink Exp $
# from: @(#)Makefile.inc 8.6 (Berkeley) 5/4/95
# gen sources
@ -12,7 +12,7 @@ SRCS+= _errno.c alarm.c arc4random.c assert.c basename.c clock.c closedir.c \
getdomainname.c getgrent.c getgrouplist.c gethostname.c \
getloadavg.c getlogin.c getmntinfo.c __getmntinfo13.c \
getnetgrent.c getpagesize.c \
getpass.c getprogname.c getpwent.c getsubopt.c getttyent.c \
getpass.c getprogname.c getpwent.c getttyent.c \
getusershell.c __glob13.c glob.c humanize_number.c initgroups.c \
isascii.c isatty.c isctype.c lockf.c nice.c nlist.c nlist_aout.c \
nlist_coff.c nlist_ecoff.c nlist_elf32.c nlist_elf64.c opendir.c \

View File

@ -1,114 +0,0 @@
/* $NetBSD: getsubopt.c,v 1.12 2003/08/07 16:42:50 agc Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char *sccsid = "@(#)getsubopt.c 5.2 (Berkeley) 2/24/91";
#else
__RCSID("$NetBSD: getsubopt.c,v 1.12 2003/08/07 16:42:50 agc Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#ifdef __weak_alias
__weak_alias(getsubopt,_getsubopt)
#endif
/*
* 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(optionp, tokens, valuep)
char **optionp, **valuep;
char * const *tokens;
{
int cnt;
char *p;
_DIAGASSERT(optionp != NULL);
_DIAGASSERT(tokens != NULL);
_DIAGASSERT(valuep != NULL);
suboptarg = *valuep = NULL;
if (!optionp || !*optionp)
return(-1);
/* skip leading white-space, commas */
for (p = *optionp; *p && (*p == ',' || *p == ' ' || *p == '\t'); ++p);
if (!*p) {
*optionp = p;
return(-1);
}
/* save the start of the token, and skip the rest of the token. */
for (suboptarg = p;
*++p && *p != ',' && *p != '=' && *p != ' ' && *p != '\t';);
if (*p) {
/*
* If there's an equals sign, set the value pointer, and
* skip over the value part of the token. Terminate the
* token.
*/
if (*p == '=') {
*p = '\0';
for (*valuep = ++p;
*p && *p != ',' && *p != ' ' && *p != '\t'; ++p);
if (*p)
*p++ = '\0';
} else
*p++ = '\0';
/* Skip any whitespace or commas after this token. */
for (; *p && (*p == ',' || *p == ' ' || *p == '\t'); ++p);
}
/* set optionp for next round. */
*optionp = p;
for (cnt = 0; *tokens; ++tokens, ++cnt)
if (!strcmp(suboptarg, *tokens))
return(cnt);
return(-1);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: getsubopt.c,v 1.7 2003/08/07 16:43:40 agc Exp $ */
/* $NetBSD: getsubopt.c,v 1.8 2004/05/09 19:34:11 kleink Exp $ */
/*-
* Copyright (c) 1990, 1993
@ -34,15 +34,21 @@
#if 0
static char sccsid[] = "@(#)getsubopt.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: getsubopt.c,v 1.7 2003/08/07 16:43:40 agc Exp $");
__RCSID("$NetBSD: getsubopt.c,v 1.8 2004/05/09 19:34:11 kleink Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#ifdef __weak_alias
__weak_alias(getsubopt,_getsubopt)
#endif
/*
* The SVID interface to getsubopt provides no way of figuring out which
* part of the suboptions list wasn't matched. This makes error messages
@ -59,8 +65,8 @@ getsubopt(optionp, tokens, valuep)
int cnt;
char *p;
_DIAGASSERT(valuep != NULL);
_DIAGASSERT(tokens != NULL);
_DIAGASSERT(valuep != NULL);
/* optionp is tested below */
suboptarg = *valuep = NULL;