Commit efd613e8 authored by Ondřej Surý's avatar Ondřej Surý

memmove, strtoul, and strcasestr functions are part of ISO C90, remove the compatibility shim

parent 1e1804bb
......@@ -29,7 +29,6 @@
#include <isc/string.h>
#include <isc/util.h>
#include <isc/task.h>
#include <isc/stdlib.h>
#include <dns/byaddr.h>
#include <dns/fixedname.h>
......
......@@ -49,7 +49,6 @@
#include <isc/serial.h>
#include <isc/safe.h>
#include <isc/stdio.h>
#include <isc/stdlib.h>
#include <isc/string.h>
#include <isc/task.h>
#include <isc/time.h>
......
......@@ -32,7 +32,6 @@
#include <isc/rwlock.h>
#include <isc/serial.h>
#include <isc/stdio.h>
#include <isc/stdlib.h>
#include <isc/string.h>
#include <isc/time.h>
#include <isc/util.h>
......
......@@ -12,11 +12,11 @@
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <isc/print.h>
#include <isc/serial.h>
#include <isc/stdlib.h>
int
main() {
......
......@@ -2014,20 +2014,6 @@ AC_SUBST(ISC_PLATFORM_HAVETFO)
#
# Check for some other useful functions that are not ever-present.
#
AC_CHECK_FUNC(memmove,
[ISC_PLATFORM_NEEDMEMMOVE="#undef ISC_PLATFORM_NEEDMEMMOVE"],
[ISC_PLATFORM_NEEDMEMMOVE="#define ISC_PLATFORM_NEEDMEMMOVE 1"])
AC_SUBST(ISC_PLATFORM_NEEDMEMMOVE)
AC_CHECK_FUNC(strtoul,
[ISC_PLATFORM_NEEDSTRTOUL="#undef ISC_PLATFORM_NEEDSTRTOUL"
GENRANDOMLIB=""],
[ISC_PLATFORM_NEEDSTRTOUL="#define ISC_PLATFORM_NEEDSTRTOUL 1"
GENRANDOMLIB='${ISCLIBS}'])
AC_SUBST(ISC_PLATFORM_NEEDSTRTOUL)
AC_SUBST(GENRANDOMLIB)
AC_CHECK_FUNC(strlcpy,
[ISC_PLATFORM_NEEDSTRLCPY="#undef ISC_PLATFORM_NEEDSTRLCPY"],
[ISC_PLATFORM_NEEDSTRLCPY="#define ISC_PLATFORM_NEEDSTRLCPY 1"])
......@@ -2038,11 +2024,6 @@ AC_CHECK_FUNC(strlcat,
[ISC_PLATFORM_NEEDSTRLCAT="#define ISC_PLATFORM_NEEDSTRLCAT 1"])
AC_SUBST(ISC_PLATFORM_NEEDSTRLCAT)
AC_CHECK_FUNC(strcasestr,
[ISC_PLATFORM_NEEDSTRCASESTR="#undef ISC_PLATFORM_NEEDSTRCASESTR"],
[ISC_PLATFORM_NEEDSTRCASESTR="#define ISC_PLATFORM_NEEDSTRCASESTR 1"])
AC_SUBST(ISC_PLATFORM_NEEDSTRCASESTR)
AC_SUBST(READLINE_LIB)
AC_ARG_WITH(readline,
AS_HELP_STRING([--with-readline[=LIBSPEC]],
......
......@@ -19,7 +19,6 @@
#ifdef USE_DNSRPS
#include <isc/mem.h>
#include <isc/stdlib.h>
#include <isc/string.h>
#include <isc/util.h>
......
......@@ -15,6 +15,7 @@
#include <ctype.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdlib.h>
#include <isc/buffer.h>
#include <isc/parseint.h>
......@@ -22,7 +23,6 @@
#include <isc/region.h>
#include <isc/result.h>
#include <isc/stdio.h>
#include <isc/stdlib.h>
#include <isc/string.h>
#include <isc/types.h>
#include <isc/util.h>
......
......@@ -25,7 +25,6 @@
#include <isc/parseint.h>
#include <isc/print.h>
#include <isc/string.h>
#include <isc/stdlib.h>
#include <isc/util.h>
#include <dns/callbacks.h>
......
......@@ -22,7 +22,6 @@
#include <isc/netaddr.h>
#include <isc/print.h>
#include <isc/rwlock.h>
#include <isc/stdlib.h>
#include <isc/string.h>
#include <isc/task.h>
#include <isc/util.h>
......
......@@ -57,7 +57,7 @@ OBJS = pk11.@O@ pk11_result.@O@ \
ratelimiter.@O@ refcount.@O@ region.@O@ regex.@O@ result.@O@ \
rwlock.@O@ \
serial.@O@ sha1.@O@ sha2.@O@ sockaddr.@O@ stats.@O@ \
string.@O@ strtoul.@O@ symtab.@O@ task.@O@ taskpool.@O@ \
string.@O@ symtab.@O@ task.@O@ taskpool.@O@ \
tm.@O@ timer.@O@ version.@O@ \
${UNIXOBJS} ${NLSOBJS} ${THREADOBJS}
SYMTBLOBJS = backtrace-emptytbl.@O@
......@@ -74,7 +74,7 @@ SRCS = pk11.c pk11_result.c \
parseint.c portset.c quota.c radix.c random.c \
ratelimiter.c refcount.c region.c regex.c result.c rwlock.c \
serial.c sha1.c sha2.c sockaddr.c stats.c string.c \
strtoul.c symtab.c task.c taskpool.c timer.c \
symtab.c task.c taskpool.c timer.c \
tm.c version.c
LIBS = @OPENSSL_LIBS@ @LIBS@
......
......@@ -91,21 +91,6 @@
*/
@ISC_PLATFORM_NEEDSTRLCAT@
/*
* Define if this system needs strtoul.
*/
@ISC_PLATFORM_NEEDSTRTOUL@
/*
* Define if this system needs memmove.
*/
@ISC_PLATFORM_NEEDMEMMOVE@
/*
* Define if this system needs strcasestr.
*/
@ISC_PLATFORM_NEEDSTRCASESTR@
/***
*** Miscellaneous.
***/
......
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
*/
#ifndef ISC_STDLIB_H
#define ISC_STDLIB_H 1
/*! \file isc/stdlib.h */
#include <stdlib.h>
#include <isc/lang.h>
#include <isc/platform.h>
#ifdef ISC_PLATFORM_NEEDSTRTOUL
#define strtoul isc_strtoul
#endif
ISC_LANG_BEGINDECLS
unsigned long isc_strtoul(const char *, char **, int);
ISC_LANG_ENDDECLS
#endif
......@@ -18,10 +18,10 @@
#include <errno.h>
#include <limits.h>
#include <inttypes.h>
#include <stdlib.h>
#include <isc/parseint.h>
#include <isc/result.h>
#include <isc/stdlib.h>
isc_result_t
isc_parse_uint32(uint32_t *uip, const char *string, int base) {
......
/*
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* See the COPYRIGHT file distributed with this work for additional
* information regarding copyright ownership.
*/
#include <config.h>
/*
* 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:
* 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.
*/
/*! \file */
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)strtoul.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
#include <limits.h>
#include <ctype.h>
#include <errno.h>
#include <isc/stdlib.h>
#include <isc/util.h>
/*!
* Convert a string to an unsigned long integer.
*
* Ignores `locale' stuff. Assumes that the upper and lower case
* alphabets and digits are each contiguous.
*/
unsigned long
isc_strtoul(const char *nptr, char **endptr, int base) {
const char *s = nptr;
unsigned long acc;
unsigned char c;
unsigned long cutoff;
int neg = 0, any, cutlim;
/*
* See strtol for comments as to the logic used.
*/
do {
c = *s++;
} while (isspace(c));
if (c == '-') {
neg = 1;
c = *s++;
} else if (c == '+')
c = *s++;
if ((base == 0 || base == 16) &&
c == '0' && (*s == 'x' || *s == 'X')) {
c = s[1];
s += 2;
base = 16;
}
if (base == 0)
base = c == '0' ? 8 : 10;
cutoff = (unsigned long)ULONG_MAX / (unsigned long)base;
cutlim = (unsigned long)ULONG_MAX % (unsigned long)base;
for (acc = 0, any = 0;; c = *s++) {
if (!isascii(c))
break;
if (isdigit(c))
c -= '0';
else if (isalpha(c))
c -= isupper(c) ? 'A' - 10 : 'a' - 10;
else
break;
if (c >= base)
break;
if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
any = -1;
else {
any = 1;
acc *= base;
acc += c;
}
}
if (any < 0) {
acc = ULONG_MAX;
errno = ERANGE;
} else if (neg)
acc = -acc;
if (endptr != 0)
DE_CONST(any ? s - 1 : nptr, *endptr);
return (acc);
}
......@@ -38,7 +38,6 @@
#include <isc/hmacsha.h>
#include <isc/print.h>
#include <isc/safe.h>
#include <isc/stdlib.h>
#include <pk11/site.h>
......
......@@ -3438,7 +3438,6 @@
./lib/isc/include/isc/socket.h C 1998,1999,2000,2001,2002,2004,2005,2006,2007,2008,2009,2011,2012,2013,2014,2016,2018
./lib/isc/include/isc/stats.h C 2009,2012,2016,2018
./lib/isc/include/isc/stdio.h C 2000,2001,2004,2005,2006,2007,2013,2016,2018
./lib/isc/include/isc/stdlib.h C 2003,2004,2005,2006,2007,2016,2018
./lib/isc/include/isc/string.h C 2000,2001,2003,2004,2005,2006,2007,2014,2016,2018
./lib/isc/include/isc/symtab.h C 1996,1997,1998,1999,2000,2001,2004,2005,2006,2007,2009,2011,2012,2013,2016,2018
./lib/isc/include/isc/task.h C 1998,1999,2000,2001,2003,2004,2005,2006,2007,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment