Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/stdlib Update strtoul(3) example to reflect clarifi...
details: https://anonhg.NetBSD.org/src/rev/afcd957f6198
branches: trunk
changeset: 348753:afcd957f6198
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sat Nov 05 20:57:31 2016 +0000
description:
Update strtoul(3) example to reflect clarifications in strtol(3).
diffstat:
lib/libc/stdlib/strtoul.3 | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diffs (27 lines):
diff -r b294e3ce39c3 -r afcd957f6198 lib/libc/stdlib/strtoul.3
--- a/lib/libc/stdlib/strtoul.3 Sat Nov 05 20:03:15 2016 +0000
+++ b/lib/libc/stdlib/strtoul.3 Sat Nov 05 20:57:31 2016 +0000
@@ -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 @@
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
Home |
Main Index |
Thread Index |
Old Index