summaryrefslogtreecommitdiff
path: root/usr/src/lib/libresolv2/common/bsd/strtoul.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/lib/libresolv2/common/bsd/strtoul.c')
-rw-r--r--usr/src/lib/libresolv2/common/bsd/strtoul.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/usr/src/lib/libresolv2/common/bsd/strtoul.c b/usr/src/lib/libresolv2/common/bsd/strtoul.c
index 41e23c1124..b37ff72729 100644
--- a/usr/src/lib/libresolv2/common/bsd/strtoul.c
+++ b/usr/src/lib/libresolv2/common/bsd/strtoul.c
@@ -1,11 +1,6 @@
-/*
- * Copyright 2003 by Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
#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 8.5 2002/07/06 02:35:04 marka Exp $";
+static const char rcsid[] = "$Id: strtoul.c,v 1.4 2008/02/18 03:49:08 marka Exp $";
#endif /* LIBC_SCCS and not lint */
/*
@@ -41,9 +36,6 @@ static const char rcsid[] = "$Id: strtoul.c,v 8.5 2002/07/06 02:35:04 marka Exp
* SUCH DAMAGE.
*/
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include "port_before.h"
#include <sys/types.h>
@@ -60,7 +52,7 @@ static const char rcsid[] = "$Id: strtoul.c,v 8.5 2002/07/06 02:35:04 marka Exp
int __strtoul_unneeded__;
#else
-/*
+/*%
* Convert a string to an unsigned long integer.
*
* Ignores `locale' stuff. Assumes that the upper and lower case
@@ -78,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;
@@ -95,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))
@@ -104,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;
@@ -118,8 +110,10 @@ 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);
}
#endif /*NEED_STRTOUL*/
+
+/*! \file */