From: Roy Marples Date: Wed, 22 Mar 2017 15:27:45 +0000 (+0000) Subject: Use new strtoi changes. X-Git-Tag: v7.0.0-beta1~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=635e46756d959486c8496b21aa5aab0109cd5466;p=thirdparty%2Fdhcpcd.git Use new strtoi changes. --- diff --git a/compat/strtoi.c b/compat/strtoi.c index 701d57b3..e1cd972c 100644 --- a/compat/strtoi.c +++ b/compat/strtoi.c @@ -1,8 +1,10 @@ -/* - * dhcpcd - DHCP client daemon - * Copyright (c) 2006-2015 Roy Marples - * All rights reserved +/* $NetBSD: strtoi.c,v 1.2 2015/05/01 14:17:56 christos Exp $ */ +/*- + * Copyright (c) 2005 The DragonFly Project. All rights reserved. + * Copyright (c) 2003 Citrus Project, + * All rights reserved. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -23,90 +25,42 @@ * 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. + * + * Created by Kamil Rytarowski, based on ID: + * NetBSD: src/common/lib/libc/stdlib/strtoul.c,v 1.3 2008/08/20 19:58:34 oster Exp */ -#include -#include -#include - -#include "strtoi.h" - -intmax_t -strtoi(const char * __restrict nptr, char ** __restrict endptr, int base, - intmax_t lo, intmax_t hi, int *rstatus) -{ - int serrno; - intmax_t r; - char *ep; - int rep; +#if HAVE_NBTOOL_CONFIG_H +#include "nbtool_config.h" +#endif - if (endptr == NULL) - endptr = &ep; - if (rstatus == NULL) - rstatus = &rep; +#ifdef _LIBC +#include "namespace.h" +#endif - serrno = errno; - errno = 0; - r = strtoimax(nptr, endptr, base); - *rstatus = errno; - errno = serrno; - - if (*rstatus == 0) { - if (nptr == *endptr) - *rstatus = ECANCELED; - else if (**endptr != '\0') - *rstatus = ENOTSUP; - } - - if (r < lo) { - if (*rstatus == 0) - *rstatus = ERANGE; - return lo; - } - if (r > hi) { - if (*rstatus == 0) - *rstatus = ERANGE; - return hi; - } - return r; -} - -uintmax_t -strtou(const char * __restrict nptr, char ** __restrict endptr, int base, - uintmax_t lo, uintmax_t hi, int *rstatus) -{ - int serrno; - uintmax_t r; - char *ep; - int rep; - - if (endptr == NULL) - endptr = &ep; - if (rstatus == NULL) - rstatus = &rep; +#if defined(_KERNEL) +#include +#include +#include +#elif defined(_STANDALONE) +#include +#include +#include +#include +#else +#include +#include +#include +#include +#endif - serrno = errno; - errno = 0; - r = strtoumax(nptr, endptr, base); - *rstatus = errno; - errno = serrno; +#define _FUNCNAME strtoi +#define __TYPE intmax_t +#define __WRAPPED strtoimax - if (*rstatus == 0) { - if (nptr == *endptr) - *rstatus = ECANCELED; - else if (**endptr != '\0') - *rstatus = ENOTSUP; - } +#include "_strtoi.h" - if (r < lo) { - if (*rstatus == 0) - *rstatus = ERANGE; - return lo; - } - if (r > hi) { - if (*rstatus == 0) - *rstatus = ERANGE; - return hi; - } - return r; -} +#ifdef _LIBC +__weak_alias(strtoi, _strtoi) +__weak_alias(strtoi_l, _strtoi_l) +#endif diff --git a/compat/strtoi.h b/compat/strtoi.h index 4b0c878c..bd976fcf 100644 --- a/compat/strtoi.h +++ b/compat/strtoi.h @@ -1,8 +1,7 @@ -/* - * dhcpcd - DHCP client daemon - * Copyright (c) 2006-2015 Roy Marples - * All rights reserved - +/*- + * Copyright (c) 1990, 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: @@ -11,11 +10,14 @@ * 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 AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * 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 AUTHOR OR CONTRIBUTORS BE LIABLE + * 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) @@ -23,6 +25,12 @@ * 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. + * + * Original version ID: + * NetBSD: src/lib/libc/locale/_wcstoul.h,v 1.2 2003/08/07 16:43:03 agc Exp + * + * Created by Kamil Rytarowski, based on ID: + * NetBSD: src/common/lib/libc/stdlib/_strtoul.h,v 1.7 2013/05/17 12:55:56 joerg Exp */ #ifndef STRTOI_H diff --git a/configure b/configure index abcb2ea4..114ba5b5 100755 --- a/configure +++ b/configure @@ -809,7 +809,7 @@ EOF rm -f _strtoi.c _strtoi fi if [ "$STRTOI" = no ]; then - echo "COMPAT_SRCS+= compat/strtoi.c" >>$CONFIG_MK + echo "COMPAT_SRCS+= compat/strtoi.c compat/strtou.c" >>$CONFIG_MK echo "#include \"compat/strtoi.h\"" >>$CONFIG_H fi