OSDN Git Service

(split) Convert release and draft pages to UTF-8.
[linuxjm/LDP_man-pages.git] / draft / man3 / memchr.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\" and Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
3 .\"     <mtk.manpages@gmail.com>
4 .\"
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein.  The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\"
25 .\" Modified Mon Apr 12 12:49:57 1993, David Metcalfe
26 .\" Modified Sat Jul 24 18:56:22 1993, Rik Faith (faith@cs.unc.edu)
27 .\" Modified Wed Feb 20 21:09:36 2002, Ian Redfern (redferni@logica.com)
28 .\" 2008-07-09, mtk, add rawmemchr()
29 .\"
30 .\" Japanese Version Copyright (c) 1997 HIROFUMI Nishizuka
31 .\"     all rights reserved.
32 .\" Translated 1997-12-16, HIROFUMI Nishizuka <nishi@rpts.cl.nec.co.jp>
33 .\" Updated & Modified 2002-03-24, Yuichi SATO <ysato@h4.dion.ne.jp>
34 .\" Updated & Modified 2003-11-27, Yuichi SATO <ysato444@yahoo.co.jp>
35 .\" Updated 2008-08-11, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
36 .\"
37 .TH MEMCHR 3  2009-12-04 "" "Linux Programmer's Manual"
38 .\"O .SH NAME
39 .SH 名前
40 .\"O memchr, memrchr, rawmemchr \- scan memory for a character
41 memchr, memrchr, rawmemchr \- 文字を探すためにメモリをスキャンする
42 .\"O .SH SYNOPSIS
43 .SH 書式
44 .nf
45 .B #include <string.h>
46
47 .BI "void *memchr(const void *" s ", int " c ", size_t " n );
48
49 .BI "void *memrchr(const void *" s ", int " c ", size_t " n );
50
51 .BI "void *rawmemchr(const void *" s ", int " c );
52 .fi
53 .sp
54 .in -4n
55 .\"O Feature Test Macro Requirements for glibc (see
56 .\"O .BR feature_test_macros (7)):
57 glibc 向けの機能検査マクロの要件
58 .RB ( feature_test_macros (7)
59 参照):
60 .in
61 .sp
62 .BR memrchr ():
63 .BR rawmemchr ():
64 _GNU_SOURCE
65 .\"O .SH DESCRIPTION
66 .SH 説明
67 .\"O The
68 .\"O .BR memchr ()
69 .\"O function scans the first \fIn\fP bytes of the memory
70 .\"O area pointed to by \fIs\fP for the character \fIc\fP.
71 .\"O The first byte to
72 .\"O match \fIc\fP (interpreted as an unsigned character) stops the operation.
73 .BR memchr ()
74 関数は、ポインタ \fIs\fP が指し示すメモリブロックの
75 先頭の \fIn\fP バイトから文字 \fIc\fP を探す。
76 最初に \fIc\fP (unsigned char と解釈される) が見つかった時点で動作が停止する。
77 .PP
78 .\"O The
79 .\"O .BR memrchr ()
80 .\"O function is like the
81 .\"O .BR memchr ()
82 .\"O function,
83 .\"O except that it searches backward from the end of the \fIn\fP bytes
84 .\"O pointed to by \fIs\fP instead of forward from the beginning.
85 .BR memrchr ()
86 関数は
87 .BR memchr ()
88 関数に似ているが、
89 先頭から順方向に探すのではなく、
90 ポインタ \fIs\fP が指し示す \fIn\fP バイトのメモリブロックの
91 末尾から逆向きに探す。
92
93 .\"O The
94 .\"O .BR rawmemchr ()
95 .\"O function is similar to
96 .\"O .BR memchr ():
97 .\"O it assumes (i.e., the programmer knows for certain)
98 .\"O that the character
99 .\"O .I c
100 .\"O lies somewhere in the string
101 .\"O .IR s ,
102 .\"O and so performs an optimized search
103 .\"O for the character
104 .\"O .IR c
105 .\"O (i.e., no checking for the terminating null byte, or use of an argument,
106 .\"O .IR n ,
107 .\"O to limit the range of the search).
108 .BR rawmemchr ()
109 関数は
110 .BR memchr ()
111 と同様だが、
112 文字
113 .I c
114 が文字列
115 .I s
116 内のどこかにあることを前提にして
117 (つまり、プログラマはそのことを知っている)、
118 最適化した方法で文字
119 .I c
120 の検索を実行する
121 (すなわち、終端の NULL バイトのチェックも行われないし、
122 検索範囲の上限を示す引き数
123 .I n
124 も使用されない)。
125 .\"O If the character
126 .\"O .I c
127 .\"O is not in the string
128 .\"O .IR s ,
129 .\"O then
130 .\"O .BR rawmemchr ()
131 .\"O may proceed to search beyond the end of the string,
132 .\"O and the result is unspecified.
133 文字
134 .I c
135 が文字列
136 .I s
137 内にない場合、
138 .BR rawmemchr ()
139 は文字列末尾を越えて検索を実行するかもしれず、結果は不定である。
140 .\"O The following call is a fast means of locating a string's
141 .\"O terminating null byte:
142 次に示す呼び出しは、文字列終端の NULL バイトの位置を特定する
143 高速な手段である。
144 .in +4n
145 .nf
146
147 char *p = rawmemchr(s,\ \(aq\\0\(aq);
148 .fi
149 .in
150 .\"O .SH "RETURN VALUE"
151 .SH 返り値
152 .\"O The
153 .\"O .BR memchr ()
154 .\"O and
155 .\"O .BR memrchr ()
156 .\"O functions return a pointer
157 .\"O to the matching byte or NULL if the character does not occur in
158 .\"O the given memory area.
159 .BR memchr ()
160 関数と
161 .BR memrchr ()
162 関数は一致する文字へのポインタを返し、
163 もし文字が指定メモリ領域に現れない場合は NULL を返す。
164
165 .\"O The
166 .\"O .BR rawmemchr ()
167 .\"O function returns a pointer to the matching byte, if one is found.
168 .\"O If no matching byte is found, the result is unspecified.
169 .BR rawmemchr ()
170 関数はマッチするバイトが見つかった場合はマッチしたバイトへのポインタを返す。
171 マッチするバイトが見つからなかった場合、結果は不定である。
172 .\"O .SH VERSIONS
173 .SH バージョン
174 .\"O .BR rawmemchr ()
175 .\"O first appeared in glibc in version 2.1.
176 .BR rawmemchr ()
177 は glibc バージョン 2.1 で初めて登場した。
178
179 .\"O .BR memrchr ()
180 .\"O first appeared in glibc in version 2.2.
181 .BR memrchr ()
182 は glibc バージョン 2.2 で初めて登場した。
183 .\"O .SH "CONFORMING TO"
184 .SH 準拠
185 .\"O The
186 .\"O .BR memchr ()
187 .\"O function conforms to SVr4, 4.3BSD, C89, C99, POSIX.1-2001.
188 .BR memchr ()
189 関数は SVr4, 4.3BSD, C89, C99, POSIX.1-2001 に準拠する。
190
191 .\"O The
192 .\"O .BR memrchr ()
193 .\"O function is a GNU extension, available since glibc 2.1.91.
194 .BR memrchr ()
195 関数は GNU 拡張であり、glibc 2.1.91 から使用可能である。
196
197 .\"O The
198 .\"O .BR rawmemchr ()
199 .\"O function is a GNU extension, available since glibc 2.1.
200 .BR rawmemchr ()
201 関数は GNU 拡張であり、glibc 2.1 から使用可能である。
202 .\"O .SH "SEE ALSO"
203 .SH 関連項目
204 .BR ffs (3),
205 .BR index (3),
206 .BR rindex (3),
207 .BR strchr (3),
208 .BR strpbrk (3),
209 .BR strrchr (3),
210 .BR strsep (3),
211 .BR strspn (3),
212 .BR strstr (3),
213 .BR wmemchr (3)