From bf5a45de679b25f8a9d0f22f34dbeeac1b5dce07 Mon Sep 17 00:00:00 2001 From: Roger Leigh Date: Fri, 23 Mar 2018 23:18:09 +0000 Subject: [PATCH] port: Clean up NetBSD sources and headers to build standalone --- .appveyor.yml | 7 ++++++ port/_strtol.h | 63 ++++--------------------------------------------- port/_strtoul.h | 59 ++++----------------------------------------- port/strtol.c | 3 ++- port/strtoll.c | 4 ++-- port/strtoul.c | 3 ++- port/strtoull.c | 3 ++- 7 files changed, 25 insertions(+), 117 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index f469afe4..bcc0d1a0 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -32,6 +32,10 @@ environment: shared: OFF - compiler: vc14-nmake configuration: Release + - compiler: vc9-cmake + configuration: Debug + generator: Visual Studio 9 2008 + shared: ON cache: - 'c:\projects\download -> appveyor.yml' @@ -68,6 +72,7 @@ before_build: - 'if %compiler%==cygwin-cmake bash -c "cmake -G \"%generator%\" -DCMAKE_INSTALL_PREFIX:PATH=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_CMAKE_ARGS% %AV_TIFF_CMAKE_SOURCE%"' - 'if %compiler%==mingw64-cmake cmake -G "%generator%" -DCMAKE_INSTALL_PREFIX:PATH=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_CMAKE_ARGS% %AV_TIFF_CMAKE_SOURCE%' - 'if %compiler%==vc14-cmake cmake -G "%generator%" -DCMAKE_INSTALL_PREFIX:PATH=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_CMAKE_ARGS% %AV_TIFF_CMAKE_SOURCE%' + - 'if %compiler%==vc9-cmake cmake -G "%generator%" -DCMAKE_INSTALL_PREFIX:PATH=%AV_TIFF_CMAKE_INSTALL% -DCMAKE_BUILD_TYPE=%configuration% %AV_CMAKE_ARGS% %AV_TIFF_CMAKE_SOURCE%' build_script: - if NOT %compiler%==vc14-nmake cd %AV_TIFF_BUILD% @@ -75,6 +80,7 @@ build_script: - 'if %compiler%==cygwin-cmake bash -c "cmake --build . --config %configuration% --target install"' - 'if %compiler%==mingw64-cmake cmake --build . --config %configuration% --target install' - 'if %compiler%==vc14-cmake cmake --build . --config %configuration% --target install' + - 'if %compiler%==vc9-cmake cmake --build . --config %configuration% --target install' - 'if %compiler%==vc14-nmake nmake /f Makefile.vc EXTRAFLAGS=/DHAVE_SNPRINTF=1' - 'if %compiler%==vc14-nmake mkdir %AV_TIFF_INSTALL%' - 'if %compiler%==vc14-nmake mkdir %AV_TIFF_INSTALL%\bin' @@ -100,6 +106,7 @@ before_test: - 'if %compiler%==cygwin-cmake bash -c "ctest -V -C %configuration%"' - 'if %compiler%==mingw64-cmake ctest -V -C %configuration%' - 'if %compiler%==vc14-cmake ctest -V -C %configuration%' + - 'if %compiler%==vc9-cmake ctest -V -C %configuration%' # vc14-nmake does not support unit tests # AppVeyor don't yet have a configurable retention policy, so this will diff --git a/port/_strtol.h b/port/_strtol.h index 51c71490..73a10063 100644 --- a/port/_strtol.h +++ b/port/_strtol.h @@ -32,6 +32,8 @@ * NetBSD: src/lib/libc/locale/_wcstol.h,v 1.2 2003/08/07 16:43:03 agc Exp */ +#include + /* * function template for strtol, strtoll and strtoimax. * @@ -41,39 +43,24 @@ * __INT_MIN : lower limit of the return type * __INT_MAX : upper limit of the return type */ -#if defined(_KERNEL) || defined(_STANDALONE) || defined(HAVE_NBTOOL_CONFIG_H) || defined(BCS_ONLY) __INT _FUNCNAME(const char *nptr, char **endptr, int base) -#else -#include -#include "setlocale_local.h" -#define INT_FUNCNAME_(pre, name, post) pre ## name ## post -#define INT_FUNCNAME(pre, name, post) INT_FUNCNAME_(pre, name, post) - -static __INT -INT_FUNCNAME(_int_, _FUNCNAME, _l)(const char *nptr, char **endptr, - int base, locale_t loc) -#endif { const char *s; __INT acc, cutoff; unsigned char c; int i, neg, any, cutlim; - _DIAGASSERT(nptr != NULL); + assert(nptr != NULL); /* endptr may be NULL */ /* check base value */ if (base && (base < 2 || base > 36)) { -#if !defined(_KERNEL) && !defined(_STANDALONE) errno = EINVAL; if (endptr != NULL) /* LINTED interface specification */ - *endptr = __UNCONST(nptr); + *endptr = (char *)(nptr); return 0; -#else - panic("%s: invalid base %d", __func__, base); -#endif } /* @@ -82,16 +69,9 @@ INT_FUNCNAME(_int_, _FUNCNAME, _l)(const char *nptr, char **endptr, * assume decimal; if base is already 16, allow 0x. */ s = nptr; -#if defined(_KERNEL) || defined(_STANDALONE) || \ - defined(HAVE_NBTOOL_CONFIG_H) || defined(BCS_ONLY) do { c = *s++; } while (isspace(c)); -#else - do { - c = *s++; - } while (isspace_l(c, loc)); -#endif if (c == '-') { neg = 1; c = *s++; @@ -108,14 +88,6 @@ INT_FUNCNAME(_int_, _FUNCNAME, _l)(const char *nptr, char **endptr, c = s[1]; s += 2; base = 16; -#if 0 - } else if ((base == 0 || base == 2) && - c == '0' && (*s == 'b' || *s == 'B') && - (s[1] >= '0' && s[1] <= '1')) { - c = s[1]; - s += 2; - base = 2; -#endif } else if (base == 0) base = (c == '0' ? 8 : 10); @@ -162,13 +134,8 @@ INT_FUNCNAME(_int_, _FUNCNAME, _l)(const char *nptr, char **endptr, if (neg) { if (acc < cutoff || (acc == cutoff && i > cutlim)) { acc = __INT_MIN; -#if !defined(_KERNEL) && !defined(_STANDALONE) any = -1; errno = ERANGE; -#else - any = 0; - break; -#endif } else { any = 1; acc *= base; @@ -177,13 +144,8 @@ INT_FUNCNAME(_int_, _FUNCNAME, _l)(const char *nptr, char **endptr, } else { if (acc > cutoff || (acc == cutoff && i > cutlim)) { acc = __INT_MAX; -#if !defined(_KERNEL) && !defined(_STANDALONE) any = -1; errno = ERANGE; -#else - any = 0; - break; -#endif } else { any = 1; acc *= base; @@ -193,21 +155,6 @@ INT_FUNCNAME(_int_, _FUNCNAME, _l)(const char *nptr, char **endptr, } if (endptr != NULL) /* LINTED interface specification */ - *endptr = __UNCONST(any ? s - 1 : nptr); + *endptr = (char *)(any ? s - 1 : nptr); return(acc); } - -#if !defined(_KERNEL) && !defined(_STANDALONE) && \ - !defined(HAVE_NBTOOL_CONFIG_H) && !defined(BCS_ONLY) -__INT -_FUNCNAME(const char *nptr, char **endptr, int base) -{ - return INT_FUNCNAME(_int_, _FUNCNAME, _l)(nptr, endptr, base, _current_locale()); -} - -__INT -INT_FUNCNAME(, _FUNCNAME, _l)(const char *nptr, char **endptr, int base, locale_t loc) -{ - return INT_FUNCNAME(_int_, _FUNCNAME, _l)(nptr, endptr, base, loc); -} -#endif diff --git a/port/_strtoul.h b/port/_strtoul.h index 9b948fb9..5cb62168 100644 --- a/port/_strtoul.h +++ b/port/_strtoul.h @@ -32,6 +32,8 @@ * NetBSD: src/lib/libc/locale/_wcstoul.h,v 1.2 2003/08/07 16:43:03 agc Exp */ +#include + /* * function template for strtoul, strtoull and strtoumax. * @@ -40,40 +42,24 @@ * __UINT : return type * __UINT_MAX : upper limit of the return type */ -#if defined(_KERNEL) || defined(_STANDALONE) || \ - defined(HAVE_NBTOOL_CONFIG_H) || defined(BCS_ONLY) __UINT _FUNCNAME(const char *nptr, char **endptr, int base) -#else -#include -#include "setlocale_local.h" -#define INT_FUNCNAME_(pre, name, post) pre ## name ## post -#define INT_FUNCNAME(pre, name, post) INT_FUNCNAME_(pre, name, post) - -static __UINT -INT_FUNCNAME(_int_, _FUNCNAME, _l)(const char *nptr, char **endptr, - int base, locale_t loc) -#endif { const char *s; __UINT acc, cutoff; unsigned char c; int i, neg, any, cutlim; - _DIAGASSERT(nptr != NULL); + assert(nptr != NULL); /* endptr may be NULL */ /* check base value */ if (base && (base < 2 || base > 36)) { -#if !defined(_KERNEL) && !defined(_STANDALONE) errno = EINVAL; if (endptr != NULL) /* LINTED interface specification */ - *endptr = __UNCONST(nptr); + *endptr = (char *)(nptr); return 0; -#else - panic("%s: invalid base %d", __func__, base); -#endif } /* @@ -82,16 +68,9 @@ INT_FUNCNAME(_int_, _FUNCNAME, _l)(const char *nptr, char **endptr, * assume decimal; if base is already 16, allow 0x. */ s = nptr; -#if defined(_KERNEL) || defined(_STANDALONE) || \ - defined(HAVE_NBTOOL_CONFIG_H) || defined(BCS_ONLY) do { c = *s++; } while (isspace(c)); -#else - do { - c = *s++; - } while (isspace_l(c, loc)); -#endif if (c == '-') { neg = 1; c = *s++; @@ -108,14 +87,6 @@ INT_FUNCNAME(_int_, _FUNCNAME, _l)(const char *nptr, char **endptr, c = s[1]; s += 2; base = 16; -#if 0 - } else if ((base == 0 || base == 2) && - c == '0' && (*s == 'b' || *s == 'B') && - (s[1] >= '0' && s[1] <= '1')) { - c = s[1]; - s += 2; - base = 2; -#endif } else if (base == 0) base = (c == '0' ? 8 : 10); @@ -139,13 +110,8 @@ INT_FUNCNAME(_int_, _FUNCNAME, _l)(const char *nptr, char **endptr, continue; if (acc > cutoff || (acc == cutoff && i > cutlim)) { acc = __UINT_MAX; -#if !defined(_KERNEL) && !defined(_STANDALONE) any = -1; errno = ERANGE; -#else - any = 0; - break; -#endif } else { any = 1; acc *= (__UINT)base; @@ -156,21 +122,6 @@ INT_FUNCNAME(_int_, _FUNCNAME, _l)(const char *nptr, char **endptr, acc = -acc; if (endptr != NULL) /* LINTED interface specification */ - *endptr = __UNCONST(any ? s - 1 : nptr); + *endptr = (char *)(any ? s - 1 : nptr); return(acc); } - -#if !defined(_KERNEL) && !defined(_STANDALONE) && \ - !defined(HAVE_NBTOOL_CONFIG_H) && !defined(BCS_ONLY) -__UINT -_FUNCNAME(const char *nptr, char **endptr, int base) -{ - return INT_FUNCNAME(_int_, _FUNCNAME, _l)(nptr, endptr, base, _current_locale()); -} - -__UINT -INT_FUNCNAME(, _FUNCNAME, _l)(const char *nptr, char **endptr, int base, locale_t loc) -{ - return INT_FUNCNAME(_int_, _FUNCNAME, _l)(nptr, endptr, base, loc); -} -#endif diff --git a/port/strtol.c b/port/strtol.c index 8c5d7b42..a355dde9 100644 --- a/port/strtol.c +++ b/port/strtol.c @@ -27,13 +27,14 @@ * SUCH DAMAGE. */ +#if 0 __RCSID("$NetBSD: strtol.c,v 1.18 2008/08/20 12:42:26 joerg Exp $"); +#endif #include #include #include #include -#include #include #define _FUNCNAME strtol diff --git a/port/strtoll.c b/port/strtoll.c index 9a8c611d..4784b098 100644 --- a/port/strtoll.c +++ b/port/strtoll.c @@ -27,13 +27,13 @@ * SUCH DAMAGE. */ +#if 0 __RCSID("$NetBSD: strtol.c,v 1.18 2008/08/20 12:42:26 joerg Exp $"); +#endif #include #include #include -#include -#include #include #define _FUNCNAME strtoll diff --git a/port/strtoul.c b/port/strtoul.c index 0d3d2538..dbd44f16 100644 --- a/port/strtoul.c +++ b/port/strtoul.c @@ -27,13 +27,14 @@ * SUCH DAMAGE. */ +#if 0 __RCSID("$NetBSD: strtoul.c,v 1.3 2008/08/20 19:58:34 oster Exp $"); +#endif #include #include #include #include -#include #include #define _FUNCNAME strtoul diff --git a/port/strtoull.c b/port/strtoull.c index 29435f50..91e4ddfb 100644 --- a/port/strtoull.c +++ b/port/strtoull.c @@ -27,13 +27,14 @@ * SUCH DAMAGE. */ +#if 0 __RCSID("$NetBSD: strtoul.c,v 1.3 2008/08/20 19:58:34 oster Exp $"); +#endif #include #include #include #include -#include #include #define _FUNCNAME strtoull