diff options
Diffstat (limited to 'src/lib/libc/string/strchr.3')
-rw-r--r-- | src/lib/libc/string/strchr.3 | 60 |
1 files changed, 37 insertions, 23 deletions
diff --git a/src/lib/libc/string/strchr.3 b/src/lib/libc/string/strchr.3 index 18b50301f3..6a9de9604e 100644 --- a/src/lib/libc/string/strchr.3 +++ b/src/lib/libc/string/strchr.3 | |||
@@ -13,11 +13,7 @@ | |||
13 | .\" 2. Redistributions in binary form must reproduce the above copyright | 13 | .\" 2. Redistributions in binary form must reproduce the above copyright |
14 | .\" notice, this list of conditions and the following disclaimer in the | 14 | .\" notice, this list of conditions and the following disclaimer in the |
15 | .\" documentation and/or other materials provided with the distribution. | 15 | .\" documentation and/or other materials provided with the distribution. |
16 | .\" 3. All advertising materials mentioning features or use of this software | 16 | .\" 3. Neither the name of the University nor the names of its contributors |
17 | .\" must display the following acknowledgement: | ||
18 | .\" This product includes software developed by the University of | ||
19 | .\" California, Berkeley and its contributors. | ||
20 | .\" 4. Neither the name of the University nor the names of its contributors | ||
21 | .\" may be used to endorse or promote products derived from this software | 17 | .\" may be used to endorse or promote products derived from this software |
22 | .\" without specific prior written permission. | 18 | .\" without specific prior written permission. |
23 | .\" | 19 | .\" |
@@ -33,29 +29,29 @@ | |||
33 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 29 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
34 | .\" SUCH DAMAGE. | 30 | .\" SUCH DAMAGE. |
35 | .\" | 31 | .\" |
36 | .\" from: @(#)strchr.3 5.4 (Berkeley) 6/29/91 | 32 | .\" $OpenBSD: strchr.3,v 1.9 2007/05/31 19:19:32 jmc Exp $ |
37 | .\" $Id: strchr.3,v 1.1.1.1 1995/10/18 08:42:22 deraadt Exp $ | ||
38 | .\" | 33 | .\" |
39 | .Dd June 29, 1991 | 34 | .Dd $Mdocdate: May 31 2007 $ |
40 | .Dt STRCHR 3 | 35 | .Dt STRCHR 3 |
41 | .Os | 36 | .Os |
42 | .Sh NAME | 37 | .Sh NAME |
43 | .Nm strchr | 38 | .Nm strchr , |
44 | .Nd locate character in string | 39 | .Nm index |
40 | .Nd locate first occurrence of a character in a string | ||
45 | .Sh SYNOPSIS | 41 | .Sh SYNOPSIS |
46 | .Fd #include <string.h> | 42 | .Fd #include <string.h> |
47 | .Ft char * | 43 | .Ft char * |
48 | .Fn strchr "const char *s" "int c" | 44 | .Fn strchr "const char *s" "int c" |
45 | .Ft char * | ||
46 | .Fn index "const char *s" "int c" | ||
49 | .Sh DESCRIPTION | 47 | .Sh DESCRIPTION |
50 | The | 48 | The |
51 | .Fn strchr | 49 | .Fn strchr |
52 | function locates the first occurrence of | 50 | function locates the first occurrence of the character |
53 | .Ar c | 51 | .Fa c |
54 | in the string pointed to by | 52 | in the string |
55 | .Ar s . | 53 | .Fa s . |
56 | The terminating | 54 | The terminating NUL character is considered part of the string. |
57 | .Dv NULL | ||
58 | character is considered part of the string. | ||
59 | If | 55 | If |
60 | .Fa c | 56 | .Fa c |
61 | is | 57 | is |
@@ -63,16 +59,31 @@ is | |||
63 | .Fn strchr | 59 | .Fn strchr |
64 | locates the terminating | 60 | locates the terminating |
65 | .Ql \e0 . | 61 | .Ql \e0 . |
62 | .Pp | ||
63 | The | ||
64 | .Fn index | ||
65 | function is an old synonym for | ||
66 | .Fn strchr . | ||
66 | .Sh RETURN VALUES | 67 | .Sh RETURN VALUES |
67 | The function | 68 | The |
68 | .Fn strchr | 69 | .Fn strchr |
69 | returns a pointer to the located character, or | 70 | function returns a pointer to the located character or |
70 | .Dv NULL | 71 | .Dv NULL |
71 | if the character does not appear in the string. | 72 | if the character does not appear in the string. |
73 | .Sh EXAMPLES | ||
74 | After the following call to | ||
75 | .Fn strchr , | ||
76 | .Va p | ||
77 | will point to the string | ||
78 | .Qq oobar : | ||
79 | .Bd -literal -offset indent | ||
80 | char *p; | ||
81 | char *s = "foobar"; | ||
82 | |||
83 | p = strchr(s, 'o'); | ||
84 | .Ed | ||
72 | .Sh SEE ALSO | 85 | .Sh SEE ALSO |
73 | .Xr index 3 , | ||
74 | .Xr memchr 3 , | 86 | .Xr memchr 3 , |
75 | .Xr rindex 3 , | ||
76 | .Xr strcspn 3 , | 87 | .Xr strcspn 3 , |
77 | .Xr strpbrk 3 , | 88 | .Xr strpbrk 3 , |
78 | .Xr strrchr 3 , | 89 | .Xr strrchr 3 , |
@@ -83,6 +94,9 @@ if the character does not appear in the string. | |||
83 | .Sh STANDARDS | 94 | .Sh STANDARDS |
84 | The | 95 | The |
85 | .Fn strchr | 96 | .Fn strchr |
86 | function | 97 | function conforms to |
87 | conforms to | ||
88 | .St -ansiC . | 98 | .St -ansiC . |
99 | .Pp | ||
100 | The | ||
101 | .Fn index | ||
102 | function is deprecated and shouldn't be used in new code. | ||