summaryrefslogtreecommitdiff
path: root/src/lib/libc/stdlib/strtol.3
diff options
context:
space:
mode:
authoraaron <>2000-04-20 13:50:03 +0000
committeraaron <>2000-04-20 13:50:03 +0000
commita4336f357f9e30dffdfad4909b24bd2e82c096a2 (patch)
treec79a224a41eb2c48668c4b4eda84163d7daadf64 /src/lib/libc/stdlib/strtol.3
parent92b3e44bedaf5a5f85880565a47206cdbf9bfa2a (diff)
downloadopenbsd-a4336f357f9e30dffdfad4909b24bd2e82c096a2.tar.gz
openbsd-a4336f357f9e30dffdfad4909b24bd2e82c096a2.tar.bz2
openbsd-a4336f357f9e30dffdfad4909b24bd2e82c096a2.zip
Flesh out stdlib function man pages.
Diffstat (limited to 'src/lib/libc/stdlib/strtol.3')
-rw-r--r--src/lib/libc/stdlib/strtol.334
1 files changed, 13 insertions, 21 deletions
diff --git a/src/lib/libc/stdlib/strtol.3 b/src/lib/libc/stdlib/strtol.3
index df696b7b85..fdc02b20b8 100644
--- a/src/lib/libc/stdlib/strtol.3
+++ b/src/lib/libc/stdlib/strtol.3
@@ -33,7 +33,7 @@
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE. 34.\" SUCH DAMAGE.
35.\" 35.\"
36.\" $OpenBSD: strtol.3,v 1.7 2000/03/04 22:19:31 aaron Exp $ 36.\" $OpenBSD: strtol.3,v 1.8 2000/04/20 13:50:03 aaron Exp $
37.\" 37.\"
38.Dd June 25, 1992 38.Dd June 25, 1992
39.Dt STRTOL 3 39.Dt STRTOL 3
@@ -46,7 +46,7 @@
46.Fd #include <limits.h> 46.Fd #include <limits.h>
47.Ft long 47.Ft long
48.Fn strtol "const char *nptr" "char **endptr" "int base" 48.Fn strtol "const char *nptr" "char **endptr" "int base"
49 49.Pp
50.Fd #include <sys/types.h> 50.Fd #include <sys/types.h>
51.Fd #include <stdlib.h> 51.Fd #include <stdlib.h>
52.Fd #include <limits.h> 52.Fd #include <limits.h>
@@ -55,24 +55,21 @@
55.Sh DESCRIPTION 55.Sh DESCRIPTION
56The 56The
57.Fn strtol 57.Fn strtol
58function 58function converts the string in
59converts the string in
60.Fa nptr 59.Fa nptr
61to a 60to a
62.Li long 61.Li long
63value. 62value.
64The 63The
65.Fn strtoq 64.Fn strtoq
66function 65function converts the string in
67converts the string in
68.Fa nptr 66.Fa nptr
69to a 67to a
70.Li quad_t 68.Li quad_t
71value. 69value.
72The conversion is done according to the given 70The conversion is done according to the given
73.Fa base , 71.Fa base ,
74which must be a number between 2 and 36 inclusive 72which must be a number between 2 and 36 inclusive or the special value 0.
75or the special value 0.
76.Pp 73.Pp
77The string may begin with an arbitrary amount of whitespace 74The string may begin with an arbitrary amount of whitespace
78(as determined by 75(as determined by
@@ -84,11 +81,9 @@ or
84sign. 81sign.
85If 82If
86.Fa base 83.Fa base
87is zero or 16, 84is zero or 16, the string may then include a
88the string may then include a
89.Ql 0x 85.Ql 0x
90prefix, 86prefix, and the number will be read in base 16; otherwise, a zero
91and the number will be read in base 16; otherwise, a zero
92.Fa base 87.Fa base
93is taken as 10 (decimal) unless the next character is 88is taken as 10 (decimal) unless the next character is
94.Ql 0 , 89.Ql 0 ,
@@ -101,8 +96,7 @@ stopping at the first character which is not a valid digit
101in the given base. 96in the given base.
102(In bases above 10, the letter 97(In bases above 10, the letter
103.Ql A 98.Ql A
104in either upper or lower case 99in either upper or lower case represents 10,
105represents 10,
106.Ql B 100.Ql B
107represents 11, and so forth, with 101represents 11, and so forth, with
108.Ql Z 102.Ql Z
@@ -110,7 +104,7 @@ representing 35.)
110.Pp 104.Pp
111If 105If
112.Fa endptr 106.Fa endptr
113is non nil, 107is non-null,
114.Fn strtol 108.Fn strtol
115stores the address of the first invalid character in 109stores the address of the first invalid character in
116.Fa *endptr . 110.Fa *endptr .
@@ -132,8 +126,7 @@ on return, the entire string was valid.)
132.Sh RETURN VALUES 126.Sh RETURN VALUES
133The 127The
134.Fn strtol 128.Fn strtol
135function 129function returns the result of the conversion,
136returns the result of the conversion,
137unless the value would underflow or overflow. 130unless the value would underflow or overflow.
138If an underflow occurs, 131If an underflow occurs,
139.Fn strtol 132.Fn strtol
@@ -191,8 +184,8 @@ error checking is further complicated because the desired return value is an
191.Li int 184.Li int
192rather than a 185rather than a
193.Li long ; 186.Li long ;
194however, on some architectures integers and long integers are the same 187however, on some architectures integers and long integers are the same size.
195size. Thus the following is necessary: 188Thus the following is necessary:
196.Bd -literal -offset indent 189.Bd -literal -offset indent
197char *ep; 190char *ep;
198int ival; 191int ival;
@@ -224,8 +217,7 @@ The given string was out of range; the value converted has been clamped.
224.Sh STANDARDS 217.Sh STANDARDS
225The 218The
226.Fn strtol 219.Fn strtol
227function 220function conforms to
228conforms to
229.St -ansiC . 221.St -ansiC .
230.Sh BUGS 222.Sh BUGS
231Ignores the current locale. 223Ignores the current locale.