diff options
Diffstat (limited to 'documentation/manual-pages/ja/man3/fgets.3')
-rw-r--r-- | documentation/manual-pages/ja/man3/fgets.3 | 155 |
1 files changed, 155 insertions, 0 deletions
diff --git a/documentation/manual-pages/ja/man3/fgets.3 b/documentation/manual-pages/ja/man3/fgets.3 new file mode 100644 index 0000000000..948e8a3c04 --- /dev/null +++ b/documentation/manual-pages/ja/man3/fgets.3 @@ -0,0 +1,155 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)fgets.3 8.1 (Berkeley) 6/4/93 +.\" +.\" %FreeBSD: src/lib/libc/stdio/fgets.3,v 1.6.2.6 2001/12/14 18:33:57 ru Exp % +.\" $FreeBSD$ +.\" +.Dd June 4, 1993 +.Dt FGETS 3 +.Os +.Sh 名称 +.Nm fgets , +.Nm gets +.Nd ストリームから行を取得 +.Sh ライブラリ +.Lb libc +.Sh 書式 +.In stdio.h +.Ft char * +.Fn fgets "char *str" "int size" "FILE *stream" +.Ft char * +.Fn gets "char *str" +.Sh 解説 +.Fn fgets +関数は、最大で +.Fa size +で指定された文字数より 1 だけ少ない数の文字を +.Fa stream +から読み込み、文字列 +.Fa str +に保存します。 +読込みは、改行文字が見つかったり、ファイルの終了 +あるいはエラーが見つかったりした場合に停止します。 +改行文字は、存在していれば保持されます。 +任意の文字を読み込んでエラーが発生しなかった場合、 +文字列の最後には +.Ql \e0 +文字が追加されます。 +.Pp +.Fn gets +関数は +.Fn fgets +関数で +.Fa size +を無限にし、 +.Em stdin +を +.Fa stream +にしたものと等価ですが、 +文字列中で改行文字が保存されない (改行文字が存在した場合) 点が +異なります。 +入力行が存在する場合、それが十分短く文字列に収まりきる +ことを保証するのは呼び出し側の責任です。 +.Sh 戻り値 +正常終了すると、 +.Fn fgets +と +.Fn gets +は文字列のポインタを戻します。 +キャラクタを読み込む前にファイルの終了に達すると、 +.Dv NULL +が戻されます。 +この場合、バッファの内容は変化しません。エラーが発生すると +.Dv NULL +が戻され、バッファの内容は不定になります。 +.Fn fgets +関数と +.Fn gets +関数はファイルの終了とエラーとを区別しません。 +ファイルの終了かエラーかを判断するには、呼び出し側が +.Xr feof 3 +と +.Xr ferror 3 +を使用しなくてはなりません。 +.Sh エラー +.Bl -tag -width Er +.It Bq Er EBADF +指定された +.Fa stream +が、読込み可能なストリームではありません。 +.El +.Pp +.Fn fgets +関数がエラーになると、ルーチン +.Xr fflush 3 , +.Xr fstat 2 , +.Xr read 2 , +.Xr malloc 3 +用に指定されたエラーのいずれかが +.Va errno +に設定される場合があります。 +.Pp +.Fn gets +関数がエラーになると、ルーチン +.Xr getchar 3 +用に指定されたエラーが +.Va errno +に設定される場合があります。 +.Sh 関連項目 +.Xr feof 3 , +.Xr ferror 3 , +.Xr fgetln 3 +.Sh 規格 +.Fn fgets +関数と +.Fn gets +関数は、 +.St -isoC +に適合しています。 +.Sh バグ +通常、次の入力行がある任意の長さより短いことを保証するのは +不可能であり、また入力バッファをオーバフローすると +ほぼ必ずセキュリティ違反となるため、 +プログラムでは +.Fn gets +を +.Em 絶対に +使用しないでください。 +.Fn gets +は、 +.St -isoC +に適合するためだけに存在しています。 |