summaryrefslogtreecommitdiff
path: root/lib/libc/stdlib
diff options
context:
space:
mode:
authorriastradh <riastradh@NetBSD.org>2016-11-05 20:57:31 +0000
committerriastradh <riastradh@NetBSD.org>2016-11-05 20:57:31 +0000
commit8d0a5f58596b93279e650c2fb1e0fe0b910e9cf3 (patch)
tree0a0734f71f244abcae93ae75754b380ee881d550 /lib/libc/stdlib
parentee131a63a578dba1f109c6d2339e4c7eef657f14 (diff)
Update strtoul(3) example to reflect clarifications in strtol(3).
Diffstat (limited to 'lib/libc/stdlib')
-rw-r--r--lib/libc/stdlib/strtoul.311
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/libc/stdlib/strtoul.3 b/lib/libc/stdlib/strtoul.3
index 1be9dce1ac0..1cb5b6d0fb2 100644
--- a/lib/libc/stdlib/strtoul.3
+++ b/lib/libc/stdlib/strtoul.3
@@ -1,4 +1,4 @@
-.\" $NetBSD: strtoul.3,v 1.35 2016/05/01 21:28:21 joerg Exp $
+.\" $NetBSD: strtoul.3,v 1.36 2016/11/05 20:57:31 riastradh Exp $
.\"
.\" Copyright (c) 1990, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -227,10 +227,15 @@ unsigned long ulval;
errno = 0;
ulval = strtoul(buf, \*[Am]ep, 10);
-if (buf[0] == '\e0' || *ep != '\e0')
+if (ep == buf)
goto not_a_number;
-if (errno == ERANGE \*[Am]\*[Am] ulval == ULONG_MAX)
+if (*ep != '\e0')
+ goto trailing_garbage;
+if (errno) {
+ assert(errno == ERANGE);
+ assert(ulval == ULONG_MAX);
goto out_of_range;
+}
.Ed
.Pp
This example will accept