summaryrefslogtreecommitdiff
path: root/lib/bind/bsd/strtoul.c
diff options
context:
space:
mode:
authorDoug Barton <dougb@FreeBSD.org>2008-12-23 18:35:21 +0000
committerDoug Barton <dougb@FreeBSD.org>2008-12-23 18:35:21 +0000
commit2fabdf5789e562f51310270bef3cb863c0dc920b (patch)
treed25d756be8550df073eb3ed4e5b39831380291b5 /lib/bind/bsd/strtoul.c
parente086bf114fd88cb7f882d66afe4492fe5659bcf2 (diff)
Notes
Diffstat (limited to 'lib/bind/bsd/strtoul.c')
-rw-r--r--lib/bind/bsd/strtoul.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/bind/bsd/strtoul.c b/lib/bind/bsd/strtoul.c
index f419227e9878..c2efeda197cf 100644
--- a/lib/bind/bsd/strtoul.c
+++ b/lib/bind/bsd/strtoul.c
@@ -1,6 +1,6 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)strtoul.c 8.1 (Berkeley) 6/4/93";
-static const char rcsid[] = "$Id: strtoul.c,v 1.2.164.1 2005/04/27 05:00:47 sra Exp $";
+static const char rcsid[] = "$Id: strtoul.c,v 1.2.164.2 2008/02/18 04:04:06 marka Exp $";
#endif /* LIBC_SCCS and not lint */
/*
@@ -70,7 +70,7 @@ strtoul(const char *nptr, char **endptr, int base) {
* See strtol for comments as to the logic used.
*/
do {
- c = *(unsigned char *)s++;
+ c = *(const unsigned char *)s++;
} while (isspace(c));
if (c == '-') {
neg = 1;
@@ -87,7 +87,7 @@ strtoul(const char *nptr, char **endptr, int base) {
base = c == '0' ? 8 : 10;
cutoff = (u_long)ULONG_MAX / (u_long)base;
cutlim = (u_long)ULONG_MAX % (u_long)base;
- for (acc = 0, any = 0;; c = *(unsigned char*)s++) {
+ for (acc = 0, any = 0;; c = *(const unsigned char*)s++) {
if (isdigit(c))
c -= '0';
else if (isalpha(c))
@@ -96,7 +96,7 @@ strtoul(const char *nptr, char **endptr, int base) {
break;
if (c >= base)
break;
- if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim)
+ if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
any = -1;
else {
any = 1;
@@ -110,7 +110,7 @@ strtoul(const char *nptr, char **endptr, int base) {
} else if (neg)
acc = -acc;
if (endptr != 0)
- *endptr = (char *)(any ? s - 1 : nptr);
+ DE_CONST((any ? s - 1 : nptr), *endptr);
return (acc);
}