Module Name: src Committed By: riastradh Date: Fri Nov 4 20:18:23 UTC 2016
Modified Files: src/lib/libc/stdlib: strtol.3 Log Message: Tidy up the second example too. To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/lib/libc/stdlib/strtol.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.37 src/lib/libc/stdlib/strtol.3:1.38 --- src/lib/libc/stdlib/strtol.3:1.37 Fri Nov 4 20:16:18 2016 +++ src/lib/libc/stdlib/strtol.3 Fri Nov 4 20:18:23 2016 @@ -1,4 +1,4 @@ -.\" $NetBSD: strtol.3,v 1.37 2016/11/04 20:16:18 riastradh Exp $ +.\" $NetBSD: strtol.3,v 1.38 2016/11/04 20:18:23 riastradh Exp $ .\" .\" Copyright (c) 1990, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -266,11 +266,15 @@ long lval; errno = 0; lval = strtol(buf, \*[Am]ep, 10); -if (buf[0] == '\e0' || *ep != '\e0') +if (ep == buf) goto not_a_number; -if ((errno == ERANGE \*[Am]\*[Am] (lval == LONG_MAX || lval == LONG_MIN)) || - (lval \*[Gt] INT_MAX || lval \*[Lt] INT_MIN)) +if (*ep != '\e0') + goto trailing_garbage; +if (errno == ERANGE || lval < INT_MIN || INT_MAX < lval) goto out_of_range; +assert(errno == 0); +assert(INT_MIN <= lval); +assert(lval <= INT_MAX); ival = lval; .Ed .Sh ERRORS