summaryrefslogtreecommitdiff
path: root/lib/libc/stdlib
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2005-09-13 01:44:08 +0000
committerchristos <christos@NetBSD.org>2005-09-13 01:44:08 +0000
commit5b84b3983f71fd20a534cfa5d1556623a8aaa717 (patch)
treefad789da59c711b66df8a9c0e736401235cb4803 /lib/libc/stdlib
parentba2a95bba7b049026b06a80bb9785a47f18c06ae (diff)
compat core reorg.
Diffstat (limited to 'lib/libc/stdlib')
-rw-r--r--lib/libc/stdlib/Makefile.inc5
-rw-r--r--lib/libc/stdlib/__unsetenv13.c102
-rw-r--r--lib/libc/stdlib/_strtoimax.c13
-rw-r--r--lib/libc/stdlib/_strtoll.c13
-rw-r--r--lib/libc/stdlib/_strtoull.c13
-rw-r--r--lib/libc/stdlib/_strtoumax.c13
-rw-r--r--lib/libc/stdlib/unsetenv.c82
7 files changed, 99 insertions, 142 deletions
diff --git a/lib/libc/stdlib/Makefile.inc b/lib/libc/stdlib/Makefile.inc
index d8626b6a47f..049ca1b9dda 100644
--- a/lib/libc/stdlib/Makefile.inc
+++ b/lib/libc/stdlib/Makefile.inc
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.59 2005/07/06 14:43:24 drochner Exp $
+# $NetBSD: Makefile.inc,v 1.60 2005/09/13 01:44:10 christos Exp $
# from: @(#)Makefile.inc 8.3 (Berkeley) 2/4/95
# stdlib sources
@@ -16,8 +16,7 @@ SRCS+= _rand48.c _strtoimax.c _strtoumax.c _strtoll.c _strtoull.c \
seed48.c setenv.c srand48.c strsuftoll.c strtod.c \
strtoimax.c strtol.c strtoll.c strtoq.c strtoul.c strtoull.c \
strtoumax.c strtouq.c system.c tdelete.c tfind.c tsearch.c twalk.c \
- __unsetenv13.c unsetenv.c \
- strfmon.c
+ unsetenv.c strfmon.c
# machine-dependent stdlib sources
# m-d Makefile.inc must include sources for:
diff --git a/lib/libc/stdlib/__unsetenv13.c b/lib/libc/stdlib/__unsetenv13.c
deleted file mode 100644
index 247cd9af335..00000000000
--- a/lib/libc/stdlib/__unsetenv13.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/* $NetBSD: __unsetenv13.c,v 1.3 2003/08/07 16:43:37 agc Exp $ */
-
-/*
- * Copyright (c) 1987, 1993
- * 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[] = "from: @(#)setenv.c 8.1 (Berkeley) 6/4/93";
-#else
-__RCSID("$NetBSD: __unsetenv13.c,v 1.3 2003/08/07 16:43:37 agc Exp $");
-#endif
-#endif /* LIBC_SCCS and not lint */
-
-#include "namespace.h"
-
-#include <assert.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include "local.h"
-#include "reentrant.h"
-
-#ifdef __weak_alias
-#ifdef __LIBC12_SOURCE__
-__weak_alias(unsetenv,_unsetenv)
-#endif
-#endif
-
-#ifdef _REENTRANT
-extern rwlock_t __environ_lock;
-#endif
-
-#ifdef __LIBC12_SOURCE__
-__warn_references(unsetenv,
- "warning: reference to compatibility unsetenv();"
- " include <stdlib.h> for correct reference")
-#endif
-
-extern char **environ;
-
-/*
- * unsetenv(name) --
- * Delete environmental variable "name".
- */
-#ifdef __LIBC12_SOURCE__
-void
-#else
-int
-#endif
-unsetenv(name)
- const char *name;
-{
- char **p;
- int offset;
-
- _DIAGASSERT(name != NULL);
-
-#ifndef __LIBC12_SOURCE__
- if (name == NULL || *name == '\0' || strchr(name, '=') != NULL) {
- errno = EINVAL;
- return (-1);
- }
-#endif
-
- rwlock_wrlock(&__environ_lock);
- while (__findenv(name, &offset)) /* if set multiple times */
- for (p = &environ[offset];; ++p)
- if (!(*p = *(p + 1)))
- break;
- rwlock_unlock(&__environ_lock);
-
-#ifndef __LIBC12_SOURCE__
- return (0);
-#endif
-}
diff --git a/lib/libc/stdlib/_strtoimax.c b/lib/libc/stdlib/_strtoimax.c
index bc496a0f84b..ea8c3997e28 100644
--- a/lib/libc/stdlib/_strtoimax.c
+++ b/lib/libc/stdlib/_strtoimax.c
@@ -1,4 +1,4 @@
-/* $NetBSD: _strtoimax.c,v 1.3 2005/07/30 15:21:20 christos Exp $ */
+/* $NetBSD: _strtoimax.c,v 1.4 2005/09/13 01:44:10 christos Exp $ */
/*
* Copyright (c) 1996 Christos Zoulas. All rights reserved.
@@ -31,21 +31,18 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: _strtoimax.c,v 1.3 2005/07/30 15:21:20 christos Exp $");
+__RCSID("$NetBSD: _strtoimax.c,v 1.4 2005/09/13 01:44:10 christos Exp $");
#endif /* LIBC_SCCS and not lint */
-#if defined(__indr_reference) && !defined(__lint__)
+#if defined(__indr_reference)
__indr_reference(_strtoimax, strtoimax)
#else
#include <inttypes.h>
-intmax_t _strtoimax __P((const char *, char **, int)); /* XXX */
+intmax_t _strtoimax(const char *, char **, int);
intmax_t
-strtoimax(nptr, endptr, base)
- const char *nptr;
- char **endptr;
- int base;
+strtoimax(const char *nptr, char **endptr, int base)
{
return _strtoimax(nptr, endptr, base);
diff --git a/lib/libc/stdlib/_strtoll.c b/lib/libc/stdlib/_strtoll.c
index 2617b91ef85..07bc564d6d8 100644
--- a/lib/libc/stdlib/_strtoll.c
+++ b/lib/libc/stdlib/_strtoll.c
@@ -1,4 +1,4 @@
-/* $NetBSD: _strtoll.c,v 1.4 2005/07/30 15:21:20 christos Exp $ */
+/* $NetBSD: _strtoll.c,v 1.5 2005/09/13 01:44:10 christos Exp $ */
/*
* Copyright (c) 1996 Christos Zoulas. All rights reserved.
@@ -31,23 +31,20 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: _strtoll.c,v 1.4 2005/07/30 15:21:20 christos Exp $");
+__RCSID("$NetBSD: _strtoll.c,v 1.5 2005/09/13 01:44:10 christos Exp $");
#endif /* LIBC_SCCS and not lint */
-#if defined(__indr_reference) && !defined(__lint__)
+#if defined(__indr_reference)
__indr_reference(_strtoll, strtoll)
#else
#include <stdlib.h>
/* LONGLONG */
-long long int _strtoll __P((const char *, char **, int)); /* XXX */
+long long int _strtoll(const char *, char **, int);
/* LONGLONG */
long long int
-strtoll(nptr, endptr, base)
- const char *nptr;
- char **endptr;
- int base;
+strtoll(const char *nptr, char **endptr, int base)
{
return _strtoll(nptr, endptr, base);
diff --git a/lib/libc/stdlib/_strtoull.c b/lib/libc/stdlib/_strtoull.c
index d2904c08239..4061723a6e5 100644
--- a/lib/libc/stdlib/_strtoull.c
+++ b/lib/libc/stdlib/_strtoull.c
@@ -1,4 +1,4 @@
-/* $NetBSD: _strtoull.c,v 1.4 2005/07/30 15:21:20 christos Exp $ */
+/* $NetBSD: _strtoull.c,v 1.5 2005/09/13 01:44:10 christos Exp $ */
/*
* Copyright (c) 1996 Christos Zoulas. All rights reserved.
@@ -31,23 +31,20 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: _strtoull.c,v 1.4 2005/07/30 15:21:20 christos Exp $");
+__RCSID("$NetBSD: _strtoull.c,v 1.5 2005/09/13 01:44:10 christos Exp $");
#endif /* LIBC_SCCS and not lint */
-#if defined(__indr_reference) && !defined(__lint__)
+#if defined(__indr_reference)
__indr_reference(_strtoull, strtoull)
#else
#include <stdlib.h>
/* LONGLONG */
-unsigned long long int _strtoull __P((const char *, char **, int)); /* XXX */
+unsigned long long int _strtoull(const char *, char **, int);
/* LONGLONG */
unsigned long long int
-strtoull(nptr, endptr, base)
- const char *nptr;
- char **endptr;
- int base;
+strtoull(const char *nptr, char **endptr, int base)
{
return _strtoull(nptr, endptr, base);
diff --git a/lib/libc/stdlib/_strtoumax.c b/lib/libc/stdlib/_strtoumax.c
index d1f6b1b6145..40579716ff4 100644
--- a/lib/libc/stdlib/_strtoumax.c
+++ b/lib/libc/stdlib/_strtoumax.c
@@ -1,4 +1,4 @@
-/* $NetBSD: _strtoumax.c,v 1.3 2005/07/30 15:21:20 christos Exp $ */
+/* $NetBSD: _strtoumax.c,v 1.4 2005/09/13 01:44:10 christos Exp $ */
/*
* Copyright (c) 1996 Christos Zoulas. All rights reserved.
@@ -31,21 +31,18 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: _strtoumax.c,v 1.3 2005/07/30 15:21:20 christos Exp $");
+__RCSID("$NetBSD: _strtoumax.c,v 1.4 2005/09/13 01:44:10 christos Exp $");
#endif /* LIBC_SCCS and not lint */
-#if defined(__indr_reference) && !defined(__lint__)
+#if defined(__indr_reference)
__indr_reference(_strtoumax, strtoumax)
#else
#include <inttypes.h>
-uintmax_t _strtoumax __P((const char *, char **, int)); /* XXX */
+uintmax_t _strtoumax(const char *, char **, int);
uintmax_t
-strtoumax(nptr, endptr, base)
- const char *nptr;
- char **endptr;
- int base;
+strtoumax(const char *nptr, char **endptr, int base)
{
return _strtoumax(nptr, endptr, base);
diff --git a/lib/libc/stdlib/unsetenv.c b/lib/libc/stdlib/unsetenv.c
index 049ab72dad7..902ec25e41a 100644
--- a/lib/libc/stdlib/unsetenv.c
+++ b/lib/libc/stdlib/unsetenv.c
@@ -1,10 +1,82 @@
-/* $NetBSD: unsetenv.c,v 1.2 2003/07/26 19:24:54 salo Exp $ */
+/* $NetBSD: unsetenv.c,v 1.3 2005/09/13 01:44:10 christos Exp $ */
/*
- * Written by Klaus Klein <kleink@NetBSD.org>, April 1, 2003.
- * Public domain.
+ * Copyright (c) 1987, 1993
+ * 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.
*/
-#define __LIBC12_SOURCE__
+#include <sys/cdefs.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+static char sccsid[] = "from: @(#)setenv.c 8.1 (Berkeley) 6/4/93";
+#else
+__RCSID("$NetBSD: unsetenv.c,v 1.3 2005/09/13 01:44:10 christos Exp $");
+#endif
+#endif /* LIBC_SCCS and not lint */
-#include "__unsetenv13.c"
+#include "namespace.h"
+
+#include <assert.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include "local.h"
+#include "reentrant.h"
+
+#ifdef _REENTRANT
+extern rwlock_t __environ_lock;
+#endif
+
+extern char **environ;
+
+/*
+ * unsetenv(name) --
+ * Delete environmental variable "name".
+ */
+int
+unsetenv(name)
+ const char *name;
+{
+ char **p;
+ int offset;
+
+ _DIAGASSERT(name != NULL);
+
+ if (name == NULL || *name == '\0' || strchr(name, '=') != NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ rwlock_wrlock(&__environ_lock);
+ while (__findenv(name, &offset)) /* if set multiple times */
+ for (p = &environ[offset];; ++p)
+ if (!(*p = *(p + 1)))
+ break;
+ rwlock_unlock(&__environ_lock);
+
+ return 0;
+}