Module Name:    src
Committed By:   dholland
Date:           Thu Jul 23 02:54:27 UTC 2009

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

Log Message:
Clarify the description of the errno behavior, based on the recent
thread in tech-userlevel.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/lib/libc/stdlib/strtol.3
cvs rdiff -u -r1.21 -r1.22 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/strtol.3
diff -u src/lib/libc/stdlib/strtol.3:1.24 src/lib/libc/stdlib/strtol.3:1.25
--- src/lib/libc/stdlib/strtol.3:1.24	Thu May 21 09:13:35 2009
+++ src/lib/libc/stdlib/strtol.3	Thu Jul 23 02:54:27 2009
@@ -1,4 +1,4 @@
-.\"	$NetBSD: strtol.3,v 1.24 2009/05/21 09:13:35 wiz Exp $
+.\"	$NetBSD: strtol.3,v 1.25 2009/07/23 02:54:27 dholland Exp $
 .\"
 .\" Copyright (c) 1990, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -193,17 +193,22 @@
 is set to
 .Er EINVAL
 and the functions return 0.
+.Pp
+If no error occurs,
+.Va errno
+is left unchanged.
+This behavior (which is unlike most library functions) is guaranteed
+by the pertinent standards.
 .Sh EXAMPLES
-Ensuring that a string is a valid number (i.e., in range and containing no
-trailing characters) requires clearing
+Because the return value of
+.Fn strtol
+cannot be used unambiguously to detect an error,
 .Va errno
-beforehand explicitly since
+is left unchanged after a successful call.
+To ensure that a string is a valid number (i.e., in range and containing no
+trailing characters), clear
 .Va errno
-is not changed on a successful call to
-.Fn strtol ,
-and the return value of
-.Fn strtol
-cannot be used unambiguously to signal an error:
+beforehand explicitly, then check it afterwards:
 .Bd -literal -offset indent
 char *ep;
 long lval;

Index: src/lib/libc/stdlib/strtoul.3
diff -u src/lib/libc/stdlib/strtoul.3:1.21 src/lib/libc/stdlib/strtoul.3:1.22
--- src/lib/libc/stdlib/strtoul.3:1.21	Thu May 21 09:13:35 2009
+++ src/lib/libc/stdlib/strtoul.3	Thu Jul 23 02:54:27 2009
@@ -1,4 +1,4 @@
-.\"	$NetBSD: strtoul.3,v 1.21 2009/05/21 09:13:35 wiz Exp $
+.\"	$NetBSD: strtoul.3,v 1.22 2009/07/23 02:54:27 dholland Exp $
 .\"
 .\" Copyright (c) 1990, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -191,17 +191,22 @@
 is set to
 .Er EINVAL
 and the functions return 0.
+.Pp
+If no error occurs,
+.Va errno
+is left unchanged.
+This behavior (which is unlike most library functions) is guaranteed
+by the pertinent standards.
 .Sh EXAMPLES
-Ensuring that a string is a valid number (i.e., in range and containing no
-trailing characters) requires clearing
+Because the return value of
+.Fn strtoul
+cannot be used unambiguously to detect an error,
 .Va errno
-beforehand explicitly since
+is left unchanged after a successful call.
+To ensure that a string is a valid number (i.e., in range and containing no
+trailing characters), clear
 .Va errno
-is not changed on a successful call to
-.Fn strtoul ,
-and the return value of
-.Fn strtoul
-cannot be used unambiguously to signal an error:
+beforehand explicitly, then check it afterwards:
 .Bd -literal -offset indent
 char *ep;
 unsigned long ulval;

Reply via email to