8498 ficl: variable 'count' might be clobbered by 'longjmp' or 'vfork'
[unleashed.git] / share / man / man3c / wcstol.3c
blob465692221f37de2d1f9f9a8810daa82a702e69e7
1 '\" te
2 .\" Copyright (c) 1992, X/Open Company Limited.  All Rights Reserved.  Portions Copyright (c) 2003, Sun Microsystems, Inc.  All Rights Reserved.
3 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
4 .\" http://www.opengroup.org/bookstore/.
5 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
6 .\"  This notice shall appear on any product containing this material.
7 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
8 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
9 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
10 .TH WCSTOL 3C "Nov 1, 2003"
11 .SH NAME
12 wcstol, wcstoll, wstol, watol, watoll, watoi \- convert wide character string
13 to long integer
14 .SH SYNOPSIS
15 .LP
16 .nf
17 #include <wchar.h>
19 \fBlong\fR \fBwcstol\fR(\fBconst wchar_t *restrict\fR \fInptr\fR, \fBwchar_t **restrict\fR \fIendptr\fR,
20      \fBint\fR \fIbase\fR);
21 .fi
23 .LP
24 .nf
25 \fBlong long\fR \fBwcstoll\fR(\fBconst wchar_t *restrict\fR \fInptr\fR, \fBwchar_t **restrict\fR \fIendptr\fR,
26      \fBint\fR \fIbase\fR);
27 .fi
29 .LP
30 .nf
31 #include <widec.h>
33 \fBlong\fR \fBwstol\fR(\fBconst wchar_t *\fR\fInptr\fR, \fBwchar_t **\fR\fIendptr\fR, \fBint\fR \fIbase\fR);
34 .fi
36 .LP
37 .nf
38 \fBlong\fR \fBwatol\fR(\fBwchar_t *\fR\fInptr\fR);
39 .fi
41 .LP
42 .nf
43 \fBlong long\fR \fBwatoll\fR(\fBwchar_t *\fR\fInptr\fR);
44 .fi
46 .LP
47 .nf
48 \fBint\fR \fBwatoi\fR(\fBwchar_t *\fR\fInptr\fR);
49 .fi
51 .SH DESCRIPTION
52 .sp
53 .LP
54 The \fBwcstol()\fR and \fBwcstoll()\fR functions convert the initial portion of
55 the wide character string pointed to by \fInptr\fR to \fBlong\fR and \fBlong
56 long\fR representation, respectively. They first decompose the input string
57 into three parts:
58 .RS +4
59 .TP
61 an initial, possibly empty, sequence of white-space wide-character codes (as
62 specified by \fBiswspace\fR(3C))
63 .RE
64 .RS +4
65 .TP
67 a subject sequence interpreted as an integer represented in some radix
68 determined by the value of \fIbase\fR
69 .RE
70 .RS +4
71 .TP
73 a final wide character string of one or more unrecognised wide character
74 codes, including the terminating null wide-character code of the input wide
75 character string
76 .RE
77 .sp
78 .LP
79 They then attempt to convert the subject sequence to an integer, and return the
80 result.
81 .sp
82 .LP
83 If the value of \fIbase\fR is \fB0\fR, the expected form of the subject
84 sequence is that of a decimal constant, octal constant or hexadecimal constant,
85 any of which may be preceded by a `+' or `\(mi' sign. A decimal constant begins
86 with a non-zero digit, and consists of a sequence of decimal digits. An octal
87 constant consists of the prefix `0' optionally followed by a sequence of the
88 digits `0' to `7' only. A hexadecimal constant consists of the prefix `0x' or
89 `0X' followed by a sequence of the decimal digits and letters `a' (or `A') to
90 `f' (or `F') with values 10 to 15 respectively.
91 .sp
92 .LP
93 If the value of \fIbase\fR is between \fB2\fR and \fB36\fR, the expected form
94 of the subject sequence is a sequence of letters and digits representing an
95 integer with the radix specified by  \fIbase\fR, optionally preceded by a `+'
96 or `\(mi' sign, but not including an integer suffix. The letters from `a' (or
97 `A') to `z' (or `Z') inclusive  are ascribed the values 10 to 35; only letters
98 whose ascribed values are less than that of \fIbase\fR are permitted. If the
99 value of \fIbase\fR is \fB16\fR, the wide-character code representations of
100 `0x' or `0X' may optionally precede the sequence of letters and digits,
101 following the sign if present.
104 The subject sequence is defined as the longest initial subsequence of the input
105 wide character string, starting with the first non-white-space wide-character
106 code, that is of the expected form. The subject sequence contains no
107 wide-character codes if the input wide character string is empty or consists
108 entirely of white-space wide-character code, or if the first non-white-space
109 wide-character code is other than a sign or a permissible letter or digit.
112 If the subject sequence has the expected form and the value of \fIbase\fR is
113 \fB0\fR, the sequence of wide-character codes starting with the first digit is
114 interpreted as an integer constant. If the subject sequence has the expected
115 form and the value of \fIbase\fR is between \fB2\fR and \fB36\fR, it is used as
116 the base for conversion, ascribing to each letter its value as given above. If
117 the subject sequence begins with a minus sign (-), the value resulting from the
118 conversion is negated. A pointer to the final wide character string is stored
119 in the object pointed to by \fIendptr\fR, provided that  \fIendptr\fR is not a
120 null pointer.
123 If the subject sequence is empty or does not have the expected form, no
124 conversion is performed; the value of \fInptr\fR is stored in the object
125 pointed to by \fIendptr\fR, provided that  \fIendptr\fR is not a null pointer.
128 These functions do not change the setting of \fBerrno\fR if successful.
131 Since 0, {\fBLONG_MIN\fR} or {\fBLLONG_MIN\fR}, and {\fBLONG_MAX\fR} or
132 {\fBLLONG_MAX\fR} are returned on error and are also valid returns on success,
133 an application wanting to check for error situations should set \fBerrno\fR to
134 0, call one of these functions, then check \fBerrno\fR.
137 The \fBwstol()\fR function is equivalent to \fBwcstol()\fR.
140 The \fBwatol()\fR function is equivalent to \fBwstol(\fR\fIstr\fR\fB,(wchar_t
141 **)NULL, 10)\fR\fI\&.\fR
144 The \fBwatoll()\fR function is the long-long (double long) version of
145 \fBwatol()\fR.
148 The \fBwatoi()\fR function is equivalent to \fB(int)watol(\|)\fR.
149 .SH RETURN VALUES
152 Upon successful completion, these functions return the converted value, if any.
153 If no conversion could be performed, 0 is returned and \fBerrno\fR may be set
154 to indicate the error. If the correct value is outside the range of
155 representable values, {\fBLONG_MIN\fR}, {\fBLONG_MAX\fR}, {\fBLLONG_MIN\fR}, or
156 {\fBLLONG_MAX\fR} is returned (according to the sign of the value), and
157 \fBerrno\fR is set to \fBERANGE\fR.
158 .SH ERRORS
161 These functions will fail if:
163 .ne 2
165 \fB\fBEINVAL\fR\fR
167 .RS 10n
168 The value of \fIbase\fR is not supported.
172 .ne 2
174 \fB\fBERANGE\fR\fR
176 .RS 10n
177 The value to be returned is not representable.
182 These functions may fail if:
184 .ne 2
186 \fB\fBEINVAL\fR\fR
188 .RS 10n
189 No conversion could be performed.
192 .SH ATTRIBUTES
195 See \fBattributes\fR(5) for descriptions of the following attributes:
200 box;
201 l | l
202 l | l .
203 ATTRIBUTE TYPE  ATTRIBUTE VALUE
205 Interface Stability     \fBwcstol()\fR and \fBwcstoll()\fR are Standard.
207 MT-Level        MT-Safe
210 .SH SEE ALSO
213 \fBiswalpha\fR(3C), \fBiswspace\fR(3C), \fBscanf\fR(3C), \fBwcstod\fR(3C),
214 \fBattributes\fR(5), \fBstandards\fR(5)
215 .SH NOTES
218 Truncation from \fBlong long\fR to \fBlong\fR can take place upon assignment or
219 by an explicit cast.