OSDN Git Service

ee03b0b90c1f141145fe71c4dc704dc2c4512931
[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 .\" Japanese Version Copyright (c) 1997 HIROFUMI Nishizuka
6 .\"     all rights reserved.
7 .\" Translated 1997-12-16, HIROFUMI Nishizuka <nishi@rpts.cl.nec.co.jp>
8 .\" Updated & Modified 2002-03-24, Yuichi SATO <ysato@h4.dion.ne.jp>
9 .\" Updated & Modified 2003-11-27, Yuichi SATO <ysato444@yahoo.co.jp>
10 .\" Updated 2008-08-11, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
11 .\"
12 .\" Permission is granted to make and distribute verbatim copies of this
13 .\" manual provided the copyright notice and this permission notice are
14 .\" preserved on all copies.
15 .\"
16 .\" Permission is granted to copy and distribute modified versions of this
17 .\" manual under the conditions for verbatim copying, provided that the
18 .\" entire resulting derived work is distributed under the terms of a
19 .\" permission notice identical to this one.
20 .\"
21 .\" Since the Linux kernel and libraries are constantly changing, this
22 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
23 .\" responsibility for errors or omissions, or for damages resulting from
24 .\" the use of the information contained herein.  The author(s) may not
25 .\" have taken the same level of care in the production of this manual,
26 .\" which is licensed free of charge, as they might when working
27 .\" professionally.
28 .\"
29 .\" Formatted or processed versions of this manual, if unaccompanied by
30 .\" the source, must acknowledge the copyright and authors of this work.
31 .\"
32 .\" Modified Mon Apr 12 12:49:57 1993, David Metcalfe
33 .\" Modified Sat Jul 24 18:56:22 1993, Rik Faith (faith@cs.unc.edu)
34 .\" Modified Wed Feb 20 21:09:36 2002, Ian Redfern (redferni@logica.com)
35 .\" 2008-07-09, mtk, add rawmemchr()
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 folowing 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)