OSDN Git Service

(split) Apply minor changes from v3.32 to v3.35 in the upstream.
[linuxjm/LDP_man-pages.git] / draft / man3 / strtoul.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.  The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" References consulted:
24 .\"     Linux libc source code
25 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
26 .\"     386BSD man pages
27 .\" Modified Sun Jul 25 10:54:03 1993 by Rik Faith (faith@cs.unc.edu)
28 .\" Fixed typo, aeb, 950823
29 .\" 2002-02-22, joey, mihtjel: Added strtoull()
30 .\"
31 .\" Japanese Version Copyright (c) 1999 AKAMATSU, Kazuo
32 .\"                            and 2006 Akihiro MOTOKI
33 .\"         all rights reserved.
34 .\" Translated Thu Jan 31 18:00:00 JST 1999
35 .\"         by AKAMATSU, Kazuo
36 .\" Updated & Modified 2006-07-20,
37 .\"         Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.36
38 .\"
39 .\" WORD:       base            ´ð¿ô
40 .\"
41 .TH STRTOUL 3  2011-09-15 "GNU" "Linux Programmer's Manual"
42 .SH Ì¾Á°
43 .\"O strtoul, strtoull, strtouq \- convert a string to an unsigned long integer
44 strtoul, strtoull, strtouq \- Ê¸»úÎó¤ò unsigned long int ¤ËÊÑ´¹¤¹¤ë
45 .SH ½ñ¼°
46 .nf
47 .B #include <stdlib.h>
48 .sp
49 .BI "unsigned long int strtoul(const char *" nptr ", char **" endptr \
50 ", int " base );
51 .sp
52 .BI "unsigned long long int strtoull(const char *" nptr ", char **" endptr ,
53 .BI "                                int " base );
54 .fi
55 .sp
56 .in -4n
57 .\"O Feature Test Macro Requirements for glibc (see
58 .\"O .BR feature_test_macros (7)):
59 glibc ¸þ¤±¤Îµ¡Ç½¸¡ºº¥Þ¥¯¥í¤ÎÍ×·ï
60 .RB ( feature_test_macros (7)
61 »²¾È):
62 .in
63 .sp
64 .ad l
65 .BR strtoull ():
66 .RS 4
67 XOPEN_SOURCE\ >=\ 600 || _BSD_SOURCE || _SVID_SOURCE || _ISOC99_SOURCE ||
68 _POSIX_C_SOURCE\ >=\ 200112L;
69 .br
70 or
71 .I cc\ -std=c99
72 .RE
73 .ad
74 .SH ÀâÌÀ
75 .\"O The
76 .\"O .BR strtoul ()
77 .\"O function converts the initial part of the string
78 .\"O in \fInptr\fP to an
79 .\"O .I "unsigned long int"
80 .\"O value according to the
81 .\"O given \fIbase\fP, which must be between 2 and 36 inclusive, or be
82 .\"O the special value 0.
83 .BR strtoul ()
84 ´Ø¿ô¤Ï¡¢ \fInptr\fP ¤Îʸ»úÎó¤ÎºÇ½é¤ÎÉôʬ¤ò¡¢
85 \fIbase\fP ¤ò´ð¿ô¤È¤·¤Æ
86 .I "unsigned long int"
87 ¤ËÊÑ´¹¤¹¤ë¡£
88 ¤³¤Î \fIbase\fP ¤Ï 2 ¤«¤é 36 ¤Þ¤Ç¤ÎÃÍ
89 ¤¢¤ë¤¤¤ÏÆÃÊ̤ʰÕÌ£¤ò»ý¤ÄÃÍ 0 ¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
90 .PP
91 .\"O The string may begin with an arbitrary amount of white space (as
92 .\"O determined by
93 .\"O .BR isspace (3))
94 .\"O followed by a single optional \(aq+\(aq or \(aq\-\(aq
95 .\"O sign.
96 .\"O If \fIbase\fP is zero or 16, the string may then include a
97 .\"O "0x" prefix, and the number will be read in base 16; otherwise, a
98 .\"O zero \fIbase\fP is taken as 10 (decimal) unless the next character
99 .\"O is \(aq0\(aq, in which case it is taken as 8 (octal).
100 ʸ»úÎó¤ÎÀèƬ¤Ë¤Ï¡¢Ç¤°Õ¤Î¿ô¤Î¶õÇò¤¬¤¢¤Ã¤Æ¤â¤è¤¯ (¶õÇò¤Ï
101 .BR ( isspace (3)
102 ¤ÇȽÄꤵ¤ì¤ë) ¡¢¤Þ¤¿¿ô»ú¤ÎľÁ°¤Ë¤Ï \(aq+\(aq ¤« \(aq\-\(aq ¤Î
103 Éä¹æ¤¬¤¢¤Ã¤Æ¤â¤è¤¤¡£
104 \fIbase\fP ¤¬ 0 ¤Þ¤¿¤Ï 16 ¤Î¾ì¹ç¤Ë¤Ï¡¢ Ê¸»úÎó¤ÎÀèƬ¤Ë "0x" ¤òÃÖ¤¯¤³¤È¤¬
105 ¤Ç¤­¡¢¤½¤Î¾ì¹ç¤Ë¤Ïʸ»úÎó¤Ï 16¿Ê¿ô¤È¤·¤Æ°·¤ï¤ì¤ë¡£
106 ¤³¤ì°Ê³°¤Îʸ»úÎó¤Ç \fIbase\fP ¤¬ 0 ¤Î¾ì¹ç¤Ï¡¢
107 ʸ»úÎ󤬠\(aq0\(aq ¤Ç»Ï¤Þ¤ë¤È¤­¤Ï 8¿Ê¿ô¤È¤·¤Æ¡¢
108 ¤½¤ì°Ê³°¤Î¤È¤­¤Ï 10¿Ê¿ô¤È¤·¤Æ°·¤ï¤ì¤ë¡£
109 .PP
110 .\"O The remainder of the string is converted to an
111 .\"O .I "unsigned long int"
112 .\"O value in the obvious manner,
113 .\"O stopping at the first character which is not a
114 .\"O valid digit in the given base.
115 .\"O (In bases above 10, the letter \(aqA\(aq in
116 .\"O either upper or lower case represents 10, \(aqB\(aq represents 11, and so
117 .\"O forth, with \(aqZ\(aq representing 35.)
118 ʸ»úÎó¤Î»Ä¤ê¤ÎÉôʬ¤Ï
119 .I "unsigned long int"
120 ¤ËÊÑ´¹¤µ¤ì¤ë¤¬¡¢´ð¿ô¤ËÂФ·¤Æ
121 Í­¸ú¤Ç¤Ê¤¤¿ô»ú¤¬¸½¤ì¤¿»þÅÀ¤ÇÊÑ´¹¤Ï½ªÎ»¤¹¤ë¡£(11¿Ê¿ô°Ê¾å¤Ç¤Ï \(aqA\(aq ¤Ï
122 Âçʸ»ú¡¦¾®Ê¸»ú¤Ë´Ø¤ï¤é¤º 10 ¤òɽ¤·¡¢ \(aqB\(aq ¤Ï 11 ¤òɽ¸½¤·,
123 °Ê²¼Æ±Íͤˡ¢ \(aqZ\(aq ¤Ï 35 ¤òɽ¤¹¡£)
124 .PP
125 .\"O If \fIendptr\fP is not NULL,
126 .\"O .BR strtoul ()
127 .\"O stores the address of the
128 .\"O first invalid character in \fI*endptr\fP.
129 .\"O If there were no digits at
130 .\"O all,
131 .\"O .BR strtoul ()
132 .\"O stores the original value of \fInptr\fP in
133 .\"O \fI*endptr\fP (and returns 0).
134 .\"O In particular, if \fI*nptr\fP is not \(aq\\0\(aq but \fI**endptr\fP
135 .\"O is \(aq\\0\(aq on return, the entire string is valid.
136 \fIendptr\fP ¤¬¥Ì¥ëÃÍ (NULL) ¤Ç¤Ê¤¤¾ì¹ç¡¢
137 .BR strtoul ()
138 ¤ÏºÇ½é¤ËÉÔÀµ¤Êʸ»ú¤¬¸½¤ì¤¿¥¢¥É¥ì¥¹¤ò
139 \fI*endptr\fP ¤Ë³ÊǼ¤·¤Æ¤¤¤ë¡£
140 ʸ»úÎó¤ËÍ­¸ú¤Ê¿ô»ú¤¬¤Ò¤È¤Ä¤â¤Ê¤±¤ì¤Ð¡¢
141 .BR strtoul ()
142 ¤Ï \fInptr\fP
143 ¤Î¸µ¤ÎÃͤò \fI*endptr\fP ¤ËÂåÆþ¤¹¤ë(¤½¤·¤Æ 0 ¤òÊÖ¤¹)¡£
144 Æäˡ¢ \fI*nptr\fP ¤¬ \(aq\\0\(aq °Ê³°¤Ç¡¢ÊÖ¤µ¤ì¤¿ \fI**endptr\fP ¤¬
145 \(aq\\0\(aq ¤Ê¤é¤Ð¡¢Ê¸»úÎóÁ´ÂΤ¬Í­¸ú¤À¤Ã¤¿¤³¤È¤Ë¤Ê¤ë¡£
146 .PP
147 .\"O The
148 .\"O .BR strtoull ()
149 .\"O function works just like the
150 .\"O .BR strtoul ()
151 .\"O function but returns an
152 .\"O .I "unsigned long long int"
153 .\"O value.
154 .BR strtoull ()
155 ´Ø¿ô¤Ï
156 .BR strtoul ()
157 ´Ø¿ô¤ÈƱÍͤÀ¤¬¡¢
158 .I "unsigned long long int"
159 ·¿¤ÎÃͤòÊÖ¤¹¡£
160 .SH ÊÖ¤êÃÍ
161 .\"O The
162 .\"O .BR strtoul ()
163 .\"O function returns either the result of the conversion
164 .\"O or, if there was a leading minus sign, the negation of the result of the
165 .\"O conversion represented as an unsigned value,
166 .\"O unless the original (nonnegated) value would overflow; in
167 .\"O the latter case,
168 .\"O .BR strtoul ()
169 .\"O returns
170 .\"O .B ULONG_MAX
171 .\"O and sets \fIerrno\fP to
172 .\"O .BR ERANGE .
173 .BR strtoul ()
174 ´Ø¿ô¤ÏÊÑ´¹·ë²Ì¤òÊÖ¤¹¡£Ê¸»úÎ󤬥ޥ¤¥Ê¥¹Éä¹æ¤«¤é»Ï¤Þ¤Ã¤Æ¤¤¤¿¾ì
175 ¹ç¤Ï¡¢(Éä¹æȿžÁ°¤ÎÃͤ¬¥ª¡¼¥Ð¡¼¥Õ¥í¡¼¤·¤Æ¤¤¤Ê¤±¤ì¤Ð) ÊÑ´¹·ë²Ì¤òÉä¹æȿž¤·¤¿
176 Ãͤò unsigned ·¿¤ÇÊÖ¤¹¡£ÊÑ´¹¤Ç¥ª¡¼¥Ð¡¼¥Õ¥í¡¼¤¬È¯À¸¤·¤¿¾ì¹ç¤Ï
177 .B ULONG_MAX
178 ¤òÊÖ¤·¡¢
179 .I errno
180 ¤Ë
181 .B ERANGE
182 ¤òÀßÄꤹ¤ë¡£
183 .\"O Precisely the same holds for
184 .\"O .BR strtoull ()
185 .\"O (with
186 .\"O .B ULLONG_MAX
187 .\"O instead of
188 .\"O .BR ULONG_MAX ).
189 .RB ( ULONG_MAX
190 ¤ò
191 .B ULLONG_MAX
192 ¤ÈÆɤßÂؤ¨¤ì¤Ð)
193 .BR strtoull ()
194 ¤Ï
195 .BR strtoul ()
196 ¤ÈÁ´¤¯Æ±¤¸¤Ç¤¢¤ë¡£
197 .SH ¥¨¥é¡¼
198 .TP
199 .B EINVAL
200 .\"O (not in C99)
201 .\"O The given
202 .\"O .I base
203 .\"O contains an unsupported value.
204 (C99 ¤Ë¤Ï¤Ê¤¤)
205 Í¿¤¨¤é¤ì¤¿
206 .I base
207 ¤¬¥µ¥Ý¡¼¥È¤µ¤ì¤Æ¤¤¤Ê¤¤ÃͤǤ¢¤ë¡£
208 .TP
209 .B ERANGE
210 .\"O The resulting value was out of range.
211 ʸ»úÎ󤬿ôÃͤÎɽ¸½Èϰϳ°¤Ç¤¢¤ë¡£
212 .LP
213 .\"O The implementation may also set \fIerrno\fP to \fBEINVAL\fP in case
214 .\"O no conversion was performed (no digits seen, and 0 returned).
215 ¼ÂÁõ¤Ë¤è¤Ã¤Æ¤Ï¡¢Á´¤¯ÊÑ´¹¤¬¹Ô¤ï¤ì¤Ê¤«¤Ã¤¿¾ì¹ç(Á´¤¯¿ô»ú¤¬¸½¤ì¤º¡¢
216 0 ¤¬ÊÖ¤µ¤ì¤ë)¡¢\fIerrno\fP ¤Ë \fBEINVAL\fP ¤¬¥»¥Ã¥È¤µ¤ì¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
217 .\"O .SH "CONFORMING TO"
218 .SH ½àµò
219 .\"O .BR strtoul ()
220 .\"O conforms to SVr4, C89, C99 and POSIX-2001, and
221 .\"O .BR strtoull ()
222 .\"O to C99 and POSIX.1-2001.
223 .BR strtoul ()
224 ¤Ï SVr4, C89, C99 ¤È POSIX-2001 ¤Ë½àµò¤·¤Æ¤¤¤ë¡£
225 .BR strtoull ()
226 ¤Ï C99 ¤È POSIX.1-2001 ¤Ë½àµò¤·¤Æ¤¤¤ë¡£
227 .\"O .SH NOTES
228 .SH Ãí°Õ
229 .\"O Since
230 .\"O .BR strtoul ()
231 .\"O can legitimately return 0 or
232 .\"O .B ULONG_MAX
233 .\"O .RB ( ULLONG_MAX
234 .\"O for
235 .\"O .BR strtoull ())
236 .\"O on both success and failure, the calling program should set
237 .\"O .I errno
238 .\"O to 0 before the call,
239 .\"O and then determine if an error occurred by checking whether
240 .\"O .I errno
241 .\"O has a nonzero value after the call.
242 .B strtoul ()
243 ¤«¤é¤ÏÀ®¸ù¡¢¼ºÇԤɤÁ¤é¤Î¾ì¹ç¤Ç¤â 0 ¤ä
244 .B ULONG_MAX
245 .RB ( strtoull ()
246 ¤Ç¤Ï
247 .BR ULLONG_MAX )
248 ¤¬ÊÖ¤ë²ÄǽÀ­¤¬¤¢¤ë¤Î¤Ç¡¢
249 ¥×¥í¥°¥é¥à¤Ï´Ø¿ô¤ò¸Æ¤Ó½Ð¤¹Á°¤Ë
250 .I errno
251 ¤ò 0 ¤ËÀßÄꤷ¡¢¸Æ¤Ó½Ð¤·¸å¤Ë
252 .I errno
253 ¤¬ 0 °Ê³°¤ÎÃͤ«¤É¤¦¤«¤ò³Îǧ¤·¥¨¥é¡¼¤¬È¯À¸¤·¤¿¤«¤É¤¦¤«¤òȽÃǤ¹¤ë
254 ɬÍפ¬¤¢¤ë¡£
255
256 .\"O In locales other than the "C" locale, other strings may be accepted.
257 "C" °Ê³°¤Î¥í¥±¡¼¥ë¤Î¾ì¹ç¡¢¤½¤Î¾¤Îʸ»úÎó¤â¼õ¤±ÉÕ¤±¤é¤ì¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
258 .\"O (For example, the thousands separator of the current locale may be
259 .\"O supported.)
260 (Î㤨¤Ð¡¢¸½ºß¤Î¥í¥±¡¼¥ë¤Î 1000 Ëè¤Î¶èÀÚ¤êʸ»ú¤ËÂбþ¤·¤Æ¤¤¤ë¤«¤â¤·¤ì¤Ê¤¤¡£)
261 .LP
262 .\"O BSD also has
263 BSD ¤Ë¤Ï¡¢
264 .sp
265 .in +4n
266 .nf
267 .BI "u_quad_t strtouq(const char *" nptr ", char **" endptr ", int " base );
268 .sp
269 .in -4n
270 .fi
271 .\"O with completely analogous definition.
272 ¤È¤¤¤¦´°Á´¤ËƱÍͤÎÄêµÁ¤ò»ý¤Ä´Ø¿ô¤¬¤¢¤ë¡£
273 .\"O Depending on the wordsize of the current architecture, this
274 .\"O may be equivalent to
275 .\"O .BR strtoull ()
276 .\"O or to
277 .\"O .BR strtoul ().
278 »ÈÍÑÃæ¤Î¥¢¡¼¥­¥Æ¥¯¥Á¥ã¤Î¥ï¡¼¥ÉĹ¼¡Âè¤Ç¤¢¤ë¤¬¡¢¤³¤Î´Ø¿ô¤Ï
279 .BR strtoull ()
280 ¤ä
281 .BR stroul ()
282 ¤ÈÅù²Á¤Ê¾ì¹ç¤â¤¢¤ê¤¨¤ë¡£
283
284 .\"O Negative values are considered valid input and are
285 .\"O silently converted to the equivalent
286 .\"O .I "unsigned long int"
287 .\"O value.
288 Éé¤ÎÃͤâÀµÅö¤ÊÆþÎϤȤߤʤµ¤ì¡¢¥¨¥é¡¼¤â¤Ê¤¯¡¢
289 Âбþ¤¹¤ë
290 .I "unsigned long int"
291 ·¿¤ÎÃͤËÊÑ´¹¤µ¤ì¤ë¡£
292 .\"O .SH EXAMPLE
293 .SH Îã
294 .\"O See the example on the
295 .\"O .BR strtol (3)
296 .\"O manual page;
297 .\"O the use of the functions described in this manual page is similar.
298 .BR strtol (3)
299 ¤Î¥Þ¥Ë¥å¥¢¥ë¥Ú¡¼¥¸¤ÎÎã¤ò»²¾È¡£
300 ¤³¤Î¥Ú¡¼¥¸¤ÇÀâÌÀ¤·¤¿´Ø¿ô¤Î»ÈÍÑÊýË¡¤âƱÍͤǤ¢¤ë¡£
301 .\"O .SH "SEE ALSO"
302 .SH ´ØÏ¢¹àÌÜ
303 .BR atof (3),
304 .BR atoi (3),
305 .BR atol (3),
306 .BR strtod (3),
307 .BR strtol (3)