summaryrefslogtreecommitdiff
path: root/port
diff options
context:
space:
mode:
authorRoger Leigh <rleigh@codelibre.net>2018-03-23 23:18:09 +0000
committerRoger Leigh <rleigh@dundee.ac.uk>2018-03-26 14:20:21 +0100
commitbf5a45de679b25f8a9d0f22f34dbeeac1b5dce07 (patch)
tree6b2272eac3e809f3e6377207c581519fe411f904 /port
parent14f304998ef89f8ed7a15e72458467f9c23539a7 (diff)
downloadlibtiff-git-bf5a45de679b25f8a9d0f22f34dbeeac1b5dce07.tar.gz
port: Clean up NetBSD sources and headers to build standalone
Diffstat (limited to 'port')
-rw-r--r--port/_strtol.h63
-rw-r--r--port/_strtoul.h59
-rw-r--r--port/strtol.c3
-rw-r--r--port/strtoll.c4
-rw-r--r--port/strtoul.c3
-rw-r--r--port/strtoull.c3
6 files changed, 18 insertions, 117 deletions
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 <assert.h>
+
/*
* 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 <locale.h>
-#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 <assert.h>
+
/*
* 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 <locale.h>
-#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 <assert.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
-#include <stdint.h>
#include <stdlib.h>
#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 <assert.h>
#include <ctype.h>
#include <errno.h>
-#include <limits.h>
-#include <stdint.h>
#include <stdlib.h>
#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 <assert.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
-#include <stdint.h>
#include <stdlib.h>
#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 <assert.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
-#include <stdint.h>
#include <stdlib.h>
#define _FUNCNAME strtoull