Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/stdlib Tidy up the second example too.



details:   https://anonhg.NetBSD.org/src/rev/60d6e1ec1081
branches:  trunk
changeset: 818883:60d6e1ec1081
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Fri Nov 04 20:18:23 2016 +0000

description:
Tidy up the second example too.

diffstat:

 lib/libc/stdlib/strtol.3 |  12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diffs (28 lines):

diff -r 9e8e9fc00b07 -r 60d6e1ec1081 lib/libc/stdlib/strtol.3
--- a/lib/libc/stdlib/strtol.3  Fri Nov 04 20:16:18 2016 +0000
+++ b/lib/libc/stdlib/strtol.3  Fri Nov 04 20:18:23 2016 +0000
@@ -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 @@
 
 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



Home | Main Index | Thread Index | Old Index