]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Use new strtoi changes.
authorRoy Marples <roy@marples.name>
Wed, 22 Mar 2017 15:27:45 +0000 (15:27 +0000)
committerRoy Marples <roy@marples.name>
Wed, 22 Mar 2017 15:27:45 +0000 (15:27 +0000)
compat/strtoi.c
compat/strtoi.h
configure

index 701d57b37979179df403bdce4f4b70a3a5ca019c..e1cd972c0c330465d77e1277ec49f48151d337a9 100644 (file)
@@ -1,8 +1,10 @@
-/*
- * dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2015 Roy Marples <roy@marples.name>
- * 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:
  * 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 <errno.h>
-#include <inttypes.h>
-#include <stdlib.h>
-
-#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 <sys/param.h>
+#include <sys/types.h>
+#include <lib/libkern/libkern.h>
+#elif defined(_STANDALONE)
+#include <sys/param.h>
+#include <sys/types.h>
+#include <lib/libkern/libkern.h>
+#include <lib/libsa/stand.h>
+#else
+#include <stddef.h>
+#include <assert.h>
+#include <errno.h>
+#include <inttypes.h>
+#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
index 4b0c878c31913a2472f866f7a1c2cf4b5d24fbc0..bd976fcf3ca389f8401283395fdf2cac675f3bc3 100644 (file)
@@ -1,8 +1,7 @@
-/*
- * dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2015 Roy Marples <roy@marples.name>
- * 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:
  * 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)
  * 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
index abcb2ea42e36f54d86c3d15d10edd4055aece675..114ba5b57b50594272c25fc821f16660fc8b18b5 100755 (executable)
--- 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