diff options
author | millert <> | 2004-08-03 19:38:01 +0000 |
---|---|---|
committer | millert <> | 2004-08-03 19:38:01 +0000 |
commit | ea13120433234de14cfef017f9b900c5d4e3874e (patch) | |
tree | fc9dbf4911b0ec70447a27591743adde8f6b908c /src/lib/libc/stdlib/strtonum.3 | |
parent | 14931f8ab7a337e1d1f0d6ff78c8d42ffeaf0189 (diff) | |
download | openbsd-ea13120433234de14cfef017f9b900c5d4e3874e.tar.gz openbsd-ea13120433234de14cfef017f9b900c5d4e3874e.tar.bz2 openbsd-ea13120433234de14cfef017f9b900c5d4e3874e.zip |
It's not really possible to make strtonum() deal with unsigned long
long values properly so don't bother trying. This greatly simplifies
the code. tedu@ OK with input from otto@ and others.
Diffstat (limited to 'src/lib/libc/stdlib/strtonum.3')
-rw-r--r-- | src/lib/libc/stdlib/strtonum.3 | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/lib/libc/stdlib/strtonum.3 b/src/lib/libc/stdlib/strtonum.3 index 7a8d7faf6d..3e3e255e55 100644 --- a/src/lib/libc/stdlib/strtonum.3 +++ b/src/lib/libc/stdlib/strtonum.3 | |||
@@ -1,4 +1,4 @@ | |||
1 | .\" $OpenBSD: strtonum.3,v 1.5 2004/05/06 06:19:01 tedu Exp $ | 1 | .\" $OpenBSD: strtonum.3,v 1.6 2004/08/03 19:38:01 millert Exp $ |
2 | .\" | 2 | .\" |
3 | .\" Copyright (c) 2004 Ted Unangst | 3 | .\" Copyright (c) 2004 Ted Unangst |
4 | .\" | 4 | .\" |
@@ -23,11 +23,11 @@ | |||
23 | .Sh SYNOPSIS | 23 | .Sh SYNOPSIS |
24 | .Fd #include <stdlib.h> | 24 | .Fd #include <stdlib.h> |
25 | .Fd #include <limits.h> | 25 | .Fd #include <limits.h> |
26 | .Ft unsigned long long | 26 | .Ft long long |
27 | .Fo strtonum | 27 | .Fo strtonum |
28 | .Fa "const char *nptr" | 28 | .Fa "const char *nptr" |
29 | .Fa "long long minval" | 29 | .Fa "long long minval" |
30 | .Fa "unsigned long long maxval" | 30 | .Fa "long long maxval" |
31 | .Fa "const char **errstr" | 31 | .Fa "const char **errstr" |
32 | .Fc | 32 | .Fc |
33 | .Sh DESCRIPTION | 33 | .Sh DESCRIPTION |
@@ -35,10 +35,9 @@ The | |||
35 | .Fn strtonum | 35 | .Fn strtonum |
36 | function converts the string in | 36 | function converts the string in |
37 | .Fa nptr | 37 | .Fa nptr |
38 | to an | 38 | to a |
39 | .Li unsigned long long | 39 | .Li long long |
40 | value. | 40 | value. |
41 | Negative values may be obtained by casting the result. | ||
42 | The | 41 | The |
43 | .Fn strtonum | 42 | .Fn strtonum |
44 | function was designed to facilitate safe, robust programming | 43 | function was designed to facilitate safe, robust programming |
@@ -57,8 +56,8 @@ or | |||
57 | .Ql - | 56 | .Ql - |
58 | sign. | 57 | sign. |
59 | .Pp | 58 | .Pp |
60 | The remainder of the string is converted to an | 59 | The remainder of the string is converted to a |
61 | .Li unsigned long long | 60 | .Li long long |
62 | value according to base 10. | 61 | value according to base 10. |
63 | .Pp | 62 | .Pp |
64 | The value obtained is then checked against the provided | 63 | The value obtained is then checked against the provided |
@@ -102,6 +101,10 @@ The above example will guarantee that the value of iterations is between | |||
102 | The given string was out of range. | 101 | The given string was out of range. |
103 | .It Bq Er EINVAL | 102 | .It Bq Er EINVAL |
104 | The given string did not consist solely of digit characters. | 103 | The given string did not consist solely of digit characters. |
104 | .It Bq Er EINVAL | ||
105 | .Ar minval | ||
106 | was larger than | ||
107 | .Ar maxval . | ||
105 | .El | 108 | .El |
106 | .Pp | 109 | .Pp |
107 | If an error occurs, errstr will be set to one of the following strings. | 110 | If an error occurs, errstr will be set to one of the following strings. |