Module Name: src Committed By: riastradh Date: Fri Nov 4 20:14:31 UTC 2016
Modified Files: src/lib/libc/stdlib: strtol.3 Log Message: Distinguish invalid syntax from trailing garbage cases. Clarify. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 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.35 src/lib/libc/stdlib/strtol.3:1.36 --- src/lib/libc/stdlib/strtol.3:1.35 Fri Nov 13 16:00:32 2015 +++ src/lib/libc/stdlib/strtol.3 Fri Nov 4 20:14:31 2016 @@ -1,4 +1,4 @@ -.\" $NetBSD: strtol.3,v 1.35 2015/11/13 16:00:32 christos Exp $ +.\" $NetBSD: strtol.3,v 1.36 2016/11/04 20:14:31 riastradh Exp $ .\" .\" Copyright (c) 1990, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -225,8 +225,10 @@ long lval; errno = 0; lval = strtol(buf, \*[Am]ep, 10); -if (buf[0] == '\e0' || *ep != '\e0') +if (ep == buf) goto not_a_number; +if (*ep != '\e0') + goto trailing_garbage; if (errno == ERANGE \*[Am]\*[Am] (lval == LONG_MAX || lval == LONG_MIN)) goto out_of_range; .Ed