cmake: remove unused configure checks
This commit is contained in:
parent
1dcf5303e1
commit
f5b23ab1bf
@ -213,9 +213,6 @@ check_include_file(dlfcn.h HAVE_DLFCN_H)
|
||||
check_include_file(fcntl.h HAVE_FCNTL_H)
|
||||
check_include_file(inttypes.h HAVE_INTTYPES_H)
|
||||
check_include_file(io.h HAVE_IO_H)
|
||||
check_include_file(limits.h HAVE_LIMITS_H)
|
||||
check_include_file(malloc.h HAVE_MALLOC_H)
|
||||
check_include_file(memory.h HAVE_MEMORY_H)
|
||||
check_include_file(search.h HAVE_SEARCH_H)
|
||||
check_include_file(stdint.h HAVE_STDINT_H)
|
||||
check_include_file(string.h HAVE_STRING_H)
|
||||
@ -271,8 +268,6 @@ int main(void){
|
||||
|
||||
# Check type sizes
|
||||
# NOTE: Could be replaced with C99 <stdint.h>
|
||||
check_type_size("signed short" SIZEOF_SIGNED_SHORT)
|
||||
check_type_size("unsigned short" SIZEOF_UNSIGNED_SHORT)
|
||||
check_type_size("signed int" SIZEOF_SIGNED_INT)
|
||||
check_type_size("unsigned int" SIZEOF_UNSIGNED_INT)
|
||||
check_type_size("signed long" SIZEOF_SIGNED_LONG)
|
||||
@ -388,34 +383,10 @@ endif()
|
||||
# TIFF_SSIZE_T TIFF_SSIZE_FORMAT
|
||||
# TIFF_PTRDIFF_T TIFF_PTRDIFF_FORMAT)
|
||||
|
||||
# Nonstandard int types
|
||||
check_type_size(INT8 int8)
|
||||
set(HAVE_INT8 ${INT8})
|
||||
check_type_size(INT16 int16)
|
||||
set(HAVE_INT16 ${INT16})
|
||||
check_type_size(INT32 int32)
|
||||
set(HAVE_INT32 ${INT32})
|
||||
|
||||
# Check functions
|
||||
set(CMAKE_REQUIRED_LIBRARIES_SAVE ${CMAKE_REQUIRED_LIBRARIES})
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${M_LIBRARY})
|
||||
check_function_exists(floor HAVE_FLOOR)
|
||||
check_function_exists(pow HAVE_POW)
|
||||
check_function_exists(sqrt HAVE_SQRT)
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_SAVE})
|
||||
|
||||
check_function_exists(isascii HAVE_ISASCII)
|
||||
check_function_exists(memmove HAVE_MEMMOVE)
|
||||
check_function_exists(memset HAVE_MEMSET)
|
||||
check_function_exists(mmap HAVE_MMAP)
|
||||
check_function_exists(setmode HAVE_SETMODE)
|
||||
check_function_exists(strcasecmp HAVE_STRCASECMP)
|
||||
check_function_exists(strchr HAVE_STRCHR)
|
||||
check_function_exists(strrchr HAVE_STRRCHR)
|
||||
check_function_exists(strstr HAVE_STRSTR)
|
||||
check_function_exists(strtol HAVE_STRTOL)
|
||||
check_function_exists(strtol HAVE_STRTOUL)
|
||||
check_function_exists(strtoull HAVE_STRTOULL)
|
||||
check_function_exists(getopt HAVE_GETOPT)
|
||||
check_function_exists(lfind HAVE_LFIND)
|
||||
|
||||
|
21
configure.ac
21
configure.ac
@ -174,7 +174,7 @@ case "${host_os}" in
|
||||
esac
|
||||
|
||||
dnl Checks for header files.
|
||||
AC_CHECK_HEADERS([assert.h fcntl.h io.h limits.h malloc.h search.h sys/time.h unistd.h])
|
||||
AC_CHECK_HEADERS([assert.h fcntl.h io.h search.h unistd.h])
|
||||
|
||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_C_CONST
|
||||
@ -196,12 +196,6 @@ dnl ---------------------------------------------------------------------------
|
||||
dnl Compute sized types for current CPU and compiler options
|
||||
dnl ---------------------------------------------------------------------------
|
||||
|
||||
# Obtain size of an 'signed short' and define as SIZEOF_SIGNED_SHORT
|
||||
AC_CHECK_SIZEOF(signed short)
|
||||
|
||||
# Obtain size of an 'unsigned short' and define as SIZEOF_UNSIGNED_SHORT
|
||||
AC_CHECK_SIZEOF(unsigned short)
|
||||
|
||||
# Obtain size of an 'signed int' and define as SIZEOF_SIGNED_INT
|
||||
AC_CHECK_SIZEOF(signed int)
|
||||
|
||||
@ -412,24 +406,15 @@ AC_MSG_RESULT($PTRDIFF_T)
|
||||
AC_DEFINE_UNQUOTED(TIFF_PTRDIFF_T,$PTRDIFF_T,[Pointer difference type])
|
||||
AC_DEFINE_UNQUOTED(TIFF_PTRDIFF_FORMAT,$PTRDIFF_FORMAT,[Pointer difference type formatter])
|
||||
|
||||
dnl Some compilers (IBM VisualAge) has these types defined, so check it here:
|
||||
AC_CHECK_TYPES([int8, int16, int32],,,
|
||||
[
|
||||
#if HAVE_INTTYPES_H
|
||||
# include <inttypes.h>
|
||||
#endif
|
||||
])
|
||||
|
||||
dnl Checks for library functions.
|
||||
AC_CHECK_FUNCS([floor isascii memmove memset mmap pow setmode snprintf sqrt \
|
||||
strchr strrchr strstr strtol strtoul strtoull])
|
||||
AC_CHECK_FUNCS([mmap setmode snprintf \
|
||||
strtoul])
|
||||
|
||||
dnl Will use local replacements for unavailable functions
|
||||
AC_REPLACE_FUNCS(getopt)
|
||||
AC_REPLACE_FUNCS(snprintf)
|
||||
AC_REPLACE_FUNCS(strcasecmp)
|
||||
AC_REPLACE_FUNCS(strtoul)
|
||||
AC_REPLACE_FUNCS(strtoull)
|
||||
AC_REPLACE_FUNCS(lfind)
|
||||
|
||||
dnl ---------------------------------------------------------------------------
|
||||
|
@ -26,9 +26,6 @@
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#cmakedefine HAVE_FCNTL_H 1
|
||||
|
||||
/* Define to 1 if you have the `floor' function. */
|
||||
#cmakedefine HAVE_FLOOR 1
|
||||
|
||||
/* Define to 1 if you have the `getopt' function. */
|
||||
#cmakedefine HAVE_GETOPT 1
|
||||
|
||||
@ -50,30 +47,12 @@
|
||||
/* Define to 1 if you have the <io.h> header file. */
|
||||
#cmakedefine HAVE_IO_H 1
|
||||
|
||||
/* Define to 1 if you have the `isascii' function. */
|
||||
#cmakedefine HAVE_ISASCII 1
|
||||
|
||||
/* Define to 1 if you have the `jbg_newlen' function. */
|
||||
#cmakedefine HAVE_JBG_NEWLEN 1
|
||||
|
||||
/* Define to 1 if you have the `lfind' function. */
|
||||
#cmakedefine HAVE_LFIND 1
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#cmakedefine HAVE_LIMITS_H 1
|
||||
|
||||
/* Define to 1 if you have the <malloc.h> header file. */
|
||||
#cmakedefine HAVE_MALLOC_H 1
|
||||
|
||||
/* Define to 1 if you have the `memmove' function. */
|
||||
#cmakedefine HAVE_MEMMOVE 1
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#cmakedefine HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the `memset' function. */
|
||||
#cmakedefine HAVE_MEMSET 1
|
||||
|
||||
/* Define to 1 if you have the `mmap' function. */
|
||||
#cmakedefine HAVE_MMAP 1
|
||||
|
||||
@ -83,9 +62,6 @@
|
||||
/* Define to 1 if you have the <OpenGL/gl.h> header file. */
|
||||
#cmakedefine HAVE_OPENGL_GL_H 1
|
||||
|
||||
/* Define to 1 if you have the `pow' function. */
|
||||
#cmakedefine HAVE_POW 1
|
||||
|
||||
/* Define to 1 if you have the <search.h> header file. */
|
||||
#cmakedefine HAVE_SEARCH_H 1
|
||||
|
||||
@ -95,39 +71,21 @@
|
||||
/* Define to 1 if you have the `snprintf' function. */
|
||||
#cmakedefine HAVE_SNPRINTF 1
|
||||
|
||||
/* Define to 1 if you have the `sqrt' function. */
|
||||
#cmakedefine HAVE_SQRT 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#cmakedefine HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the `strcasecmp' function. */
|
||||
#cmakedefine HAVE_STRCASECMP 1
|
||||
|
||||
/* Define to 1 if you have the `strchr' function. */
|
||||
#cmakedefine HAVE_STRCHR 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#cmakedefine HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#cmakedefine HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the `strrchr' function. */
|
||||
#cmakedefine HAVE_STRRCHR 1
|
||||
|
||||
/* Define to 1 if you have the `strstr' function. */
|
||||
#cmakedefine HAVE_STRSTR 1
|
||||
|
||||
/* Define to 1 if you have the `strtol' function. */
|
||||
#cmakedefine HAVE_STRTOL 1
|
||||
|
||||
/* Define to 1 if you have the `strtoul' function. */
|
||||
#cmakedefine HAVE_STRTOUL 1
|
||||
|
||||
/* Define to 1 if you have the `strtoull' function. */
|
||||
#cmakedefine HAVE_STRTOULL 1
|
||||
|
||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
#cmakedefine HAVE_SYS_TIME_H 1
|
||||
|
||||
@ -176,9 +134,6 @@
|
||||
/* The size of `signed long long', as computed by sizeof. */
|
||||
#define SIZEOF_SIGNED_LONG_LONG @SIZEOF_SIGNED_LONG_LONG@
|
||||
|
||||
/* The size of `signed short', as computed by sizeof. */
|
||||
#define SIZEOF_SIGNED_SHORT @SIZEOF_SIGNED_SHORT@
|
||||
|
||||
/* The size of `unsigned char *', as computed by sizeof. */
|
||||
#define SIZEOF_UNSIGNED_CHAR_P @SIZEOF_UNSIGNED_CHAR_P@
|
||||
|
||||
|
@ -37,9 +37,6 @@
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#undef HAVE_FCNTL_H
|
||||
|
||||
/* Define to 1 if you have the `floor' function. */
|
||||
#undef HAVE_FLOOR
|
||||
|
||||
/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
|
||||
#undef HAVE_FSEEKO
|
||||
|
||||
@ -62,45 +59,18 @@
|
||||
machine */
|
||||
#undef HAVE_IEEEFP
|
||||
|
||||
/* Define to 1 if the system has the type `int16'. */
|
||||
#undef HAVE_INT16
|
||||
|
||||
/* Define to 1 if the system has the type `int32'. */
|
||||
#undef HAVE_INT32
|
||||
|
||||
/* Define to 1 if the system has the type `int8'. */
|
||||
#undef HAVE_INT8
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the <io.h> header file. */
|
||||
#undef HAVE_IO_H
|
||||
|
||||
/* Define to 1 if you have the `isascii' function. */
|
||||
#undef HAVE_ISASCII
|
||||
|
||||
/* Define to 1 if you have the `jbg_newlen' function. */
|
||||
#undef HAVE_JBG_NEWLEN
|
||||
|
||||
/* Define to 1 if you have the `lfind' function. */
|
||||
#undef HAVE_LFIND
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#undef HAVE_LIMITS_H
|
||||
|
||||
/* Define to 1 if you have the <malloc.h> header file. */
|
||||
#undef HAVE_MALLOC_H
|
||||
|
||||
/* Define to 1 if you have the `memmove' function. */
|
||||
#undef HAVE_MEMMOVE
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 if you have the `memset' function. */
|
||||
#undef HAVE_MEMSET
|
||||
|
||||
/* Define to 1 if you have the `mmap' function. */
|
||||
#undef HAVE_MMAP
|
||||
|
||||
@ -110,9 +80,6 @@
|
||||
/* Define to 1 if you have the <OpenGL/gl.h> header file. */
|
||||
#undef HAVE_OPENGL_GL_H
|
||||
|
||||
/* Define to 1 if you have the `pow' function. */
|
||||
#undef HAVE_POW
|
||||
|
||||
/* Define if you have POSIX threads libraries and header files. */
|
||||
#undef HAVE_PTHREAD
|
||||
|
||||
@ -125,9 +92,6 @@
|
||||
/* Define to 1 if you have the `snprintf' function. */
|
||||
#undef HAVE_SNPRINTF
|
||||
|
||||
/* Define to 1 if you have the `sqrt' function. */
|
||||
#undef HAVE_SQRT
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
@ -137,36 +101,18 @@
|
||||
/* Define to 1 if you have the `strcasecmp' function. */
|
||||
#undef HAVE_STRCASECMP
|
||||
|
||||
/* Define to 1 if you have the `strchr' function. */
|
||||
#undef HAVE_STRCHR
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
|
||||
/* Define to 1 if you have the `strrchr' function. */
|
||||
#undef HAVE_STRRCHR
|
||||
|
||||
/* Define to 1 if you have the `strstr' function. */
|
||||
#undef HAVE_STRSTR
|
||||
|
||||
/* Define to 1 if you have the `strtol' function. */
|
||||
#undef HAVE_STRTOL
|
||||
|
||||
/* Define to 1 if you have the `strtoul' function. */
|
||||
#undef HAVE_STRTOUL
|
||||
|
||||
/* Define to 1 if you have the `strtoull' function. */
|
||||
#undef HAVE_STRTOULL
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
#undef HAVE_SYS_TIME_H
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
@ -259,9 +205,6 @@
|
||||
/* The size of `signed long long', as computed by sizeof. */
|
||||
#undef SIZEOF_SIGNED_LONG_LONG
|
||||
|
||||
/* The size of `signed short', as computed by sizeof. */
|
||||
#undef SIZEOF_SIGNED_SHORT
|
||||
|
||||
/* The size of `size_t', as computed by sizeof. */
|
||||
#undef SIZEOF_SIZE_T
|
||||
|
||||
@ -277,9 +220,6 @@
|
||||
/* The size of `unsigned long long', as computed by sizeof. */
|
||||
#undef SIZEOF_UNSIGNED_LONG_LONG
|
||||
|
||||
/* The size of `unsigned short', as computed by sizeof. */
|
||||
#undef SIZEOF_UNSIGNED_SHORT
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
|
@ -7,15 +7,6 @@
|
||||
#ifndef _TIFFCONF_
|
||||
#define _TIFFCONF_
|
||||
|
||||
/* Define to 1 if the system has the type `int16'. */
|
||||
//#define HAVE_INT16
|
||||
|
||||
/* Define to 1 if the system has the type `int32'. */
|
||||
//#define HAVE_INT32
|
||||
|
||||
/* Define to 1 if the system has the type `int8'. */
|
||||
//#define HAVE_INT8
|
||||
|
||||
/* The size of a `int', as computed by sizeof. */
|
||||
#define SIZEOF_INT 4
|
||||
|
||||
|
@ -40,15 +40,6 @@
|
||||
/* Pointer difference type */
|
||||
#define TIFF_PTRDIFF_T @TIFF_PTRDIFF_T@
|
||||
|
||||
/* Define to 1 if the system has the type `int16'. */
|
||||
#cmakedefine HAVE_INT16 1
|
||||
|
||||
/* Define to 1 if the system has the type `int32'. */
|
||||
#cmakedefine HAVE_INT32 1
|
||||
|
||||
/* Define to 1 if the system has the type `int8'. */
|
||||
#cmakedefine HAVE_INT8 1
|
||||
|
||||
/* Compatibility stuff. */
|
||||
|
||||
/* Define as 0 or 1 according to the floating point format suported by the
|
||||
|
@ -37,15 +37,6 @@
|
||||
/* Pointer difference type */
|
||||
#undef TIFF_PTRDIFF_T
|
||||
|
||||
/* Define to 1 if the system has the type `int16'. */
|
||||
#undef HAVE_INT16
|
||||
|
||||
/* Define to 1 if the system has the type `int32'. */
|
||||
#undef HAVE_INT32
|
||||
|
||||
/* Define to 1 if the system has the type `int8'. */
|
||||
#undef HAVE_INT8
|
||||
|
||||
/* Compatibility stuff. */
|
||||
|
||||
/* Define as 0 or 1 according to the floating point format suported by the
|
||||
|
@ -7,15 +7,6 @@
|
||||
#ifndef _TIFFCONF_
|
||||
#define _TIFFCONF_
|
||||
|
||||
/* Define to 1 if the system has the type `int16'. */
|
||||
/* #undef HAVE_INT16 */
|
||||
|
||||
/* Define to 1 if the system has the type `int32'. */
|
||||
/* #undef HAVE_INT32 */
|
||||
|
||||
/* Define to 1 if the system has the type `int8'. */
|
||||
/* #undef HAVE_INT8 */
|
||||
|
||||
/* The size of a `int', as computed by sizeof. */
|
||||
#define SIZEOF_INT 4
|
||||
|
||||
|
@ -25,15 +25,6 @@
|
||||
#ifndef _TIFFCONF_
|
||||
#define _TIFFCONF_
|
||||
|
||||
/* Define to 1 if the system has the type `int16'. */
|
||||
/* #undef HAVE_INT16 */
|
||||
|
||||
/* Define to 1 if the system has the type `int32'. */
|
||||
/* #undef HAVE_INT32 */
|
||||
|
||||
/* Define to 1 if the system has the type `int8'. */
|
||||
/* #undef HAVE_INT8 */
|
||||
|
||||
/* The size of a `int', as computed by sizeof. */
|
||||
#define SIZEOF_INT 4
|
||||
|
||||
|
@ -28,8 +28,7 @@ set(port_optional_SOURCES
|
||||
getopt.c
|
||||
lfind.c
|
||||
strcasecmp.c
|
||||
strtoul.c
|
||||
strtoull.c)
|
||||
strtoul.c)
|
||||
|
||||
set(port_USED_FILES ${port_SOURCES} ${port_HEADERS})
|
||||
|
||||
@ -48,9 +47,6 @@ endif()
|
||||
if(NOT HAVE_STRTOUL)
|
||||
list(APPEND port_USED_FILES strtoul.c)
|
||||
endif()
|
||||
if(NOT HAVE_STRTOULL)
|
||||
list(APPEND port_USED_FILES strtoull.c)
|
||||
endif()
|
||||
|
||||
add_library(port STATIC ${port_USED_FILES})
|
||||
|
||||
|
116
port/strtoull.c
116
port/strtoull.c
@ -1,116 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 1992, 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. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. 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 <limits.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/*
|
||||
* Convert a string to an unsigned long long integer.
|
||||
*
|
||||
* Assumes that the upper and lower case
|
||||
* alphabets and digits are each contiguous.
|
||||
*/
|
||||
unsigned long long
|
||||
strtoull(const char *nptr, char **endptr, int base)
|
||||
{
|
||||
const char *s;
|
||||
unsigned long long acc;
|
||||
char c;
|
||||
unsigned long long cutoff;
|
||||
int neg, any, cutlim;
|
||||
|
||||
/*
|
||||
* See strtoq for comments as to the logic used.
|
||||
*/
|
||||
s = nptr;
|
||||
do {
|
||||
c = *s++;
|
||||
} while (isspace((unsigned char)c));
|
||||
if (c == '-') {
|
||||
neg = 1;
|
||||
c = *s++;
|
||||
} else {
|
||||
neg = 0;
|
||||
if (c == '+')
|
||||
c = *s++;
|
||||
}
|
||||
if ((base == 0 || base == 16) &&
|
||||
c == '0' && (*s == 'x' || *s == 'X') &&
|
||||
((s[1] >= '0' && s[1] <= '9') ||
|
||||
(s[1] >= 'A' && s[1] <= 'F') ||
|
||||
(s[1] >= 'a' && s[1] <= 'f'))) {
|
||||
c = s[1];
|
||||
s += 2;
|
||||
base = 16;
|
||||
}
|
||||
if (base == 0)
|
||||
base = c == '0' ? 8 : 10;
|
||||
acc = any = 0;
|
||||
if (base < 2 || base > 36)
|
||||
goto noconv;
|
||||
|
||||
cutoff = ULLONG_MAX / base;
|
||||
cutlim = ULLONG_MAX % base;
|
||||
for ( ; ; c = *s++) {
|
||||
if (c >= '0' && c <= '9')
|
||||
c -= '0';
|
||||
else if (c >= 'A' && c <= 'Z')
|
||||
c -= 'A' - 10;
|
||||
else if (c >= 'a' && c <= 'z')
|
||||
c -= '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 = ULLONG_MAX;
|
||||
errno = ERANGE;
|
||||
} else if (!any) {
|
||||
noconv:
|
||||
errno = EINVAL;
|
||||
} else if (neg)
|
||||
acc = -acc;
|
||||
if (endptr != NULL)
|
||||
*endptr = (char *)(any ? s - 1 : nptr);
|
||||
return (acc);
|
||||
}
|
Loading…
Reference in New Issue
Block a user