diff options
Diffstat (limited to 'src/lib/libc/stdlib/atoi.3')
| -rw-r--r-- | src/lib/libc/stdlib/atoi.3 | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/src/lib/libc/stdlib/atoi.3 b/src/lib/libc/stdlib/atoi.3 index 219ba73c00..070344a810 100644 --- a/src/lib/libc/stdlib/atoi.3 +++ b/src/lib/libc/stdlib/atoi.3 | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | .\" Copyright (c) 1990, 1991 The Regents of the University of California. | 1 | .\" Copyright (c) 1990, 1991, 1993 |
| 2 | .\" All rights reserved. | 2 | .\" The Regents of the University of California. All rights reserved. |
| 3 | .\" | 3 | .\" |
| 4 | .\" This code is derived from software contributed to Berkeley by | 4 | .\" This code is derived from software contributed to Berkeley by |
| 5 | .\" the American National Standards Committee X3, on Information | 5 | .\" the American National Standards Committee X3, on Information |
| @@ -13,11 +13,7 @@ | |||
| 13 | .\" 2. Redistributions in binary form must reproduce the above copyright | 13 | .\" 2. Redistributions in binary form must reproduce the above copyright |
| 14 | .\" notice, this list of conditions and the following disclaimer in the | 14 | .\" notice, this list of conditions and the following disclaimer in the |
| 15 | .\" documentation and/or other materials provided with the distribution. | 15 | .\" documentation and/or other materials provided with the distribution. |
| 16 | .\" 3. All advertising materials mentioning features or use of this software | 16 | .\" 3. Neither the name of the University nor the names of its contributors |
| 17 | .\" must display the following acknowledgement: | ||
| 18 | .\" This product includes software developed by the University of | ||
| 19 | .\" California, Berkeley and its contributors. | ||
| 20 | .\" 4. Neither the name of the University nor the names of its contributors | ||
| 21 | .\" may be used to endorse or promote products derived from this software | 17 | .\" may be used to endorse or promote products derived from this software |
| 22 | .\" without specific prior written permission. | 18 | .\" without specific prior written permission. |
| 23 | .\" | 19 | .\" |
| @@ -33,10 +29,9 @@ | |||
| 33 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 29 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 34 | .\" SUCH DAMAGE. | 30 | .\" SUCH DAMAGE. |
| 35 | .\" | 31 | .\" |
| 36 | .\" from: @(#)atoi.3 5.3 (Berkeley) 6/29/91 | 32 | .\" $OpenBSD: atoi.3,v 1.7 2003/06/02 20:18:37 millert Exp $ |
| 37 | .\" $Id: atoi.3,v 1.1.1.1 1995/10/18 08:42:16 deraadt Exp $ | ||
| 38 | .\" | 33 | .\" |
| 39 | .Dd June 29, 1991 | 34 | .Dd June 4, 1993 |
| 40 | .Dt ATOI 3 | 35 | .Dt ATOI 3 |
| 41 | .Os | 36 | .Os |
| 42 | .Sh NAME | 37 | .Sh NAME |
| @@ -52,13 +47,12 @@ string to integer | |||
| 52 | The | 47 | The |
| 53 | .Fn atoi | 48 | .Fn atoi |
| 54 | function converts the initial portion of the string pointed to by | 49 | function converts the initial portion of the string pointed to by |
| 55 | .Em nptr | 50 | .Fa nptr |
| 56 | to | 51 | to |
| 57 | .Em integer | 52 | .Li integer |
| 58 | representation. | 53 | representation. |
| 59 | .Pp | 54 | .Pp |
| 60 | It is equivalent to: | 55 | It is equivalent to: |
| 61 | .Pp | ||
| 62 | .Bd -literal -offset indent | 56 | .Bd -literal -offset indent |
| 63 | (int)strtol(nptr, (char **)NULL, 10); | 57 | (int)strtol(nptr, (char **)NULL, 10); |
| 64 | .Ed | 58 | .Ed |
| @@ -73,3 +67,15 @@ The | |||
| 73 | .Fn atoi | 67 | .Fn atoi |
| 74 | function conforms to | 68 | function conforms to |
| 75 | .St -ansiC . | 69 | .St -ansiC . |
| 70 | .Sh CAVEATS | ||
| 71 | .Nm | ||
| 72 | does no overflow checking, handles unsigned numbers poorly, | ||
| 73 | and handles strings containing trailing extra characters | ||
| 74 | (like | ||
| 75 | .Dq "123abc" ) | ||
| 76 | poorly. | ||
| 77 | Careful use of | ||
| 78 | .Xr strtol 3 | ||
| 79 | and | ||
| 80 | .Xr strtoul 3 | ||
| 81 | can alleviate these problems. | ||
