Module Name:    src
Committed By:   riastradh
Date:           Sat Nov  5 20:57:31 UTC 2016

Modified Files:
        src/lib/libc/stdlib: strtoul.3

Log Message:
Update strtoul(3) example to reflect clarifications in strtol(3).


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/lib/libc/stdlib/strtoul.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/stdlib/strtoul.3
diff -u src/lib/libc/stdlib/strtoul.3:1.35 src/lib/libc/stdlib/strtoul.3:1.36
--- src/lib/libc/stdlib/strtoul.3:1.35	Sun May  1 21:28:21 2016
+++ src/lib/libc/stdlib/strtoul.3	Sat Nov  5 20:57:31 2016
@@ -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

Reply via email to