]>
Commit | Line | Data |
---|---|---|
fea681da MK |
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. | |
c13182ef | 11 | .\" |
fea681da MK |
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. | |
c13182ef | 19 | .\" |
fea681da MK |
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 | .\" 386BSD man pages | |
26 | .\" Modified Sat Jul 24 18:50:48 1993 by Rik Faith (faith@cs.unc.edu) | |
2b0fa182 | 27 | .\" Interchanged 'needle' and 'haystack'; added history, aeb, 980113. |
8461e2c7 | 28 | .TH MEMMEM 3 2008-12-05 "GNU" "Linux Programmer's Manual" |
fea681da MK |
29 | .SH NAME |
30 | memmem \- locate a substring | |
31 | .SH SYNOPSIS | |
32 | .nf | |
b80f966b | 33 | .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */" |
fea681da MK |
34 | .B #include <string.h> |
35 | .sp | |
36 | .BI "void *memmem(const void *" haystack ", size_t " haystacklen , | |
088a639b | 37 | .BI " const void *" needle ", size_t " needlelen ); |
fea681da MK |
38 | .fi |
39 | .SH DESCRIPTION | |
60a90ecd MK |
40 | The |
41 | .BR memmem () | |
42 | function finds the start of the first occurrence | |
fea681da MK |
43 | of the substring \fIneedle\fP of length \fIneedlelen\fP in the memory |
44 | area \fIhaystack\fP of length \fIhaystacklen\fP. | |
45 | .SH "RETURN VALUE" | |
60a90ecd MK |
46 | The |
47 | .BR memmem () | |
48 | function returns a pointer to the beginning of the | |
fea681da MK |
49 | substring, or NULL if the substring is not found. |
50 | .SH "CONFORMING TO" | |
51 | This function is a GNU extension. | |
52 | .SH BUGS | |
53 | This function was broken in Linux libraries up to and including libc 5.0.9; | |
2b0fa182 | 54 | there the \fIneedle\fP and \fIhaystack\fP arguments were interchanged, |
fea681da | 55 | and a pointer to the end of the first occurrence of \fIneedle\fP |
c13182ef | 56 | was returned. |
f84addeb | 57 | |
6a023229 | 58 | Both old and new libc's have the bug that if \fIneedle\fP is empty, |
e17aa487 | 59 | \fIhaystack\-1\fP (instead of \fIhaystack\fP) is returned. |
6a023229 | 60 | And glibc 2.0 makes it worse, returning a pointer to the |
2b0fa182 | 61 | last byte of \fIhaystack\fP. |
ca7b3c18 | 62 | This is fixed in glibc 2.1. |
fea681da | 63 | .SH "SEE ALSO" |
0a4f8b7b | 64 | .BR strstr (3) |