OSDN Git Service

(split) LDP: Translation snapshots for ja.po.
[linuxjm/LDP_man-pages.git] / draft / man3 / gets.3
1 .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
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 .\" License.
23 .\" Modified Wed Jul 28 11:12:07 1993 by Rik Faith (faith@cs.unc.edu)
24 .\"
25 .\" Japanese Version Copyright (c) 1997 IMAMURA Nobutaka
26 .\"         all rights reserved.
27 .\" Translated 1997-02-14, IMAMURA Nobutaka <imamura@spp.hpc.fujitsu.co.jp>
28 .\" Updated 1999-08-29, Kentaro Shirakata <argrath@ub32.org>
29 .\" Updated 2001-11-02, Kentaro Shirakata <argrath@ub32.org>
30 .\" Updated 2005-09-06, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
31 .\"
32 .TH GETS 3  2011-09-28 "GNU" "Linux Programmer's Manual"
33 .\"O .SH NAME
34 .SH 名前
35 .\"O fgetc, fgets, getc, getchar, gets, ungetc \- input of characters and strings
36 fgetc, fgets, getc, getchar, gets, ungetc \- 文字と文字列の入力
37 .\"O .SH SYNOPSIS
38 .SH 書式
39 .nf
40 .B #include <stdio.h>
41 .sp
42 .BI "int fgetc(FILE *" stream );
43
44 .BI "char *fgets(char *" "s" ", int " "size" ", FILE *" "stream" );
45
46 .BI "int getc(FILE *" stream );
47
48 .B "int getchar(void);"
49
50 .BI "char *gets(char *" "s" );
51
52 .BI "int ungetc(int " c ", FILE *" stream );
53 .fi
54 .\"O .SH DESCRIPTION
55 .SH 説明
56 .\"O .BR fgetc ()
57 .\"O reads the next character from
58 .\"O .I stream
59 .\"O and returns it as an
60 .\"O .I unsigned char
61 .\"O cast to an
62 .\"O .IR int ,
63 .\"O or
64 .\"O .B EOF
65 .\"O on end of file or error.
66 .BR fgetc ()
67 は、
68 .I stream
69 から次の文字を
70 .I unsigned char
71 として読み、
72 .I int
73 にキャストして返す。ファイルの終わりやエラーとなった場合は
74 .B EOF
75 を返す。
76 .PP
77 .\"O .BR getc ()
78 .\"O is equivalent to
79 .\"O .BR fgetc ()
80 .\"O except that it may be implemented as a macro which evaluates
81 .\"O .I stream
82 .\"O more than once.
83 .BR getc ()
84
85 .BR fgetc ()
86 と同様だが、
87 .I stream
88 を複数回評価するマクロとして実装されているかもしれない。
89 .PP
90 .\"O .BR getchar ()
91 .\"O is equivalent to
92 .\"O .BI "getc(" stdin ) \fR.
93 .BR getchar ()
94
95 .BI "getc(" stdin ) \fR
96 と同じである。
97 .PP
98 .\"O .BR gets ()
99 .\"O reads a line from
100 .\"O .I stdin
101 .\"O into the buffer pointed to by
102 .\"O .I s
103 .\"O until either a terminating newline or
104 .\"O .BR EOF ,
105 .\"O which it replaces with a null byte (\(aq\e0\(aq).
106 .BR gets ()
107 は、改行文字か
108 .B EOF
109 までの 1行を
110 .I stdin
111 から読み込み
112 .I s
113 が指すバッファに格納する
114 (末尾の改行文字や
115 .B EOF
116 は NULL バイト (\(aq\e0\(aq) に置き換えられる)。
117 .\"O No check for buffer overrun is performed (see BUGS below).
118 バッファ・オーバーランのチェックは行われない (下記の「バグ」を参照)。
119 .PP
120 .\"O .BR fgets ()
121 .\"O reads in at most one less than
122 .\"O .I size
123 .\"O characters from
124 .\"O .I stream
125 .\"O and stores them into the buffer pointed to by
126 .\"O .IR s .
127 .\"O Reading stops after an
128 .\"O .B EOF
129 .\"O or a newline.
130 .\"O If a newline is read, it is stored into the buffer.
131 .\"O A terminating null byte (\(aq\e0\(aq)
132 .\"O is stored after the last character in the buffer.
133 .BR fgets ()
134
135 .I stream
136 から最大で
137 .IR size " - 1"
138 個の文字を読み込み、
139 .I s
140 が指すバッファに格納する。読み込みは
141 .B EOF
142 または改行文字を読み込んだ後で停止する。
143 読み込まれた改行文字はバッファに格納される。
144 終端の NULL バイト (\(aq\e0\(aq)
145 が一つバッファの中の最後の文字の後に書き込まれる。
146 .PP
147 .\"O .BR ungetc ()
148 .\"O pushes
149 .\"O .I c
150 .\"O back to
151 .\"O .IR stream ,
152 .\"O cast to
153 .\"O .IR "unsigned char" ,
154 .\"O where it is available for subsequent read operations.
155 .\"O Pushed-back characters
156 .\"O will be returned in reverse order; only one pushback is guaranteed.
157 .BR ungetc ()
158 は、後の read 操作で読めるように、
159 .I c
160
161 .I "unsigned char"
162 にキャストして
163 .I stream
164 に書き戻す。
165 書き戻された文字は逆順に戻される;
166 書き戻しとして保証されているのは、一文字だけである。
167 .PP
168 .\"O Calls to the functions described here can be mixed with each other and with
169 .\"O calls to other input functions from the
170 .\"O .I stdio
171 .\"O library for the same input stream.
172 ここで述べた関数や
173 .I stdio
174 ライブラリの入力関数を同じ入力ストリームに対して互いに混ぜて使うことができる。
175 .PP
176 .\"O For nonlocking counterparts, see
177 .\"O .BR unlocked_stdio (3).
178 これらの処理をロックせずに行いたいときは、
179 .BR unlocked_stdio (3)
180 を参照のこと。
181 .\"O .SH "RETURN VALUES"
182 .SH 返り値
183 .\"O .BR fgetc (),
184 .\"O .BR getc ()
185 .\"O and
186 .\"O .BR getchar ()
187 .\"O return the character read as an
188 .\"O .I unsigned char
189 .\"O cast to an
190 .\"O .I int
191 .\"O or
192 .\"O .B EOF
193 .\"O on end of file or error.
194 .BR fgetc (),
195 .BR getc (),
196 .BR getchar ()
197 は、文字を
198 .I unsigned char
199 として読んで
200 .I int
201 にキャストして返す。ファイルの終わりやエラーの場合は
202 .B EOF
203 を返す。
204 .PP
205 .\"O .BR gets ()
206 .\"O and
207 .\"O .BR fgets ()
208 .\"O return
209 .\"O .I s
210 .\"O on success, and NULL
211 .\"O on error or when end of file occurs while no characters have been read.
212 .BR gets ()
213
214 .BR fgets ()
215 は、成功すると
216 .I s
217 を返し、エラーや 1 文字も読み込んでいないのにファイルの終わりになった
218 場合に NULL を返す。
219 .PP
220 .\"O .BR ungetc ()
221 .\"O returns
222 .\"O .I c
223 .\"O on success, or
224 .\"O .B EOF
225 .\"O on error.
226 .BR ungetc ()
227 は成功すると
228 .I c
229 を返し、エラーの場合は
230 .B EOF
231 を返す。
232 .\"O .SH "CONFORMS TO"
233 .SH 準拠
234 C89, C99, POSIX.1-2001.
235 .\"O LSB deprecates
236 .\"O .BR gets ().
237 LSB では
238 .BR gets ()
239 は非推奨である。
240 .\"O POSIX.1-2008 marks
241 .\"O .BR gets ()
242 .\"O obsolescent.
243 POSIX.1-2008 では
244 .BR gets ()
245 は廃止予定であるとされている。
246 .\"O .SH "BUGS"
247 .SH バグ
248 .\"O Never use
249 .\"O .BR gets ().
250 .\"O Because it is impossible to tell without knowing the data in advance how many
251 .\"O characters
252 .\"O .BR gets ()
253 .\"O will read, and because
254 .\"O .BR gets ()
255 .\"O will continue to store characters past the end of the buffer,
256 .\"O it is extremely dangerous to use.
257 .\"O It has been used to break computer security.
258 .\"O Use
259 .\"O .BR fgets ()
260 .\"O instead.
261 .BR gets ()
262 は絶対に使用してはならない。
263 前もってデータを知ることなしに
264 .BR gets ()
265 が何文字読むかを知ることはできず、
266 .BR gets ()
267 がバッファの終わりを越えて書き込み続けるため、
268 .BR gets ()
269 を使うのは極めて危険である。
270 これを利用してコンピュータのセキュリティが破られてきた。
271 代わりに
272 .BR fgets ()
273 を使うこと。
274 .PP
275 .\"O It is not advisable to mix calls to input functions from the
276 .\"O .I stdio
277 .\"O library with low-level calls to
278 .\"O .BR read (2)
279 .\"O for the file descriptor associated with the input stream; the results
280 .\"O will be undefined and very probably not what you want.
281 入力ストリームのファイルディスクリプタに対して、
282 .I stdio
283 ライブラリの入力関数と、低レベル呼び出しの
284 .BR read (2)
285 を混ぜて呼び出す事は勧められない。
286 結果がどうなるかは分からず、おそらくあなたの
287 望んでいる結果にはならないだろう。
288 .\"O .SH "SEE ALSO"
289 .SH 関連項目
290 .BR read (2),
291 .BR write (2),
292 .BR ferror (3),
293 .BR fgetwc (3),
294 .BR fgetws (3),
295 .BR fopen (3),
296 .BR fread (3),
297 .BR fseek (3),
298 .BR getline (3),
299 .BR getwchar (3),
300 .BR puts (3),
301 .BR scanf (3),
302 .BR ungetwc (3),
303 .BR unlocked_stdio (3)