xref: /netbsd-src/lib/libc/string/index.3 (revision cf2f172048b0ec98455634d1998367f568fafeac)
15f8a6c06Sperry.\" Copyright (c) 1990, 1991, 1993
25f8a6c06Sperry.\"	The Regents of the University of California.  All rights reserved.
361f28255Scgd.\"
461f28255Scgd.\" This code is derived from software contributed to Berkeley by
561f28255Scgd.\" Chris Torek.
661f28255Scgd.\" Redistribution and use in source and binary forms, with or without
761f28255Scgd.\" modification, are permitted provided that the following conditions
861f28255Scgd.\" are met:
961f28255Scgd.\" 1. Redistributions of source code must retain the above copyright
1061f28255Scgd.\"    notice, this list of conditions and the following disclaimer.
1161f28255Scgd.\" 2. Redistributions in binary form must reproduce the above copyright
1261f28255Scgd.\"    notice, this list of conditions and the following disclaimer in the
1361f28255Scgd.\"    documentation and/or other materials provided with the distribution.
14eb7c1594Sagc.\" 3. Neither the name of the University nor the names of its contributors
1561f28255Scgd.\"    may be used to endorse or promote products derived from this software
1661f28255Scgd.\"    without specific prior written permission.
1761f28255Scgd.\"
1861f28255Scgd.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1961f28255Scgd.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2061f28255Scgd.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2161f28255Scgd.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2261f28255Scgd.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2361f28255Scgd.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2461f28255Scgd.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2561f28255Scgd.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2661f28255Scgd.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2761f28255Scgd.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2861f28255Scgd.\" SUCH DAMAGE.
2961f28255Scgd.\"
305f8a6c06Sperry.\"     from: @(#)index.3	8.1 (Berkeley) 6/4/93
31*cf2f1720Sdholland.\"	$NetBSD: index.3,v 1.15 2012/05/05 21:18:43 dholland Exp $
3261f28255Scgd.\"
33*cf2f1720Sdholland.Dd May 5, 2012
3461f28255Scgd.Dt INDEX 3
3561f28255Scgd.Os
3661f28255Scgd.Sh NAME
3761f28255Scgd.Nm index
3861f28255Scgd.Nd locate character in string
39312aca53Sperry.Sh LIBRARY
40312aca53Sperry.Lb libc
4161f28255Scgd.Sh SYNOPSIS
42472351e1Swiz.In strings.h
4361f28255Scgd.Ft char *
4461f28255Scgd.Fn index "const char *s" "int c"
4561f28255Scgd.Sh DESCRIPTION
4661f28255ScgdThe
4761f28255Scgd.Fn index
4861f28255Scgdfunction
4961f28255Scgdlocates the first character matching
5061f28255Scgd.Fa c
5161f28255Scgd(converted to a
5261f28255Scgd.Em char )
531a64d82dSwizin the nul-terminated string
5461f28255Scgd.Fa s .
55aa368b88Sdholland.Pp
56aa368b88SdhollandThis function is obsolete.
57aa368b88SdhollandThe equivalent function
58aa368b88Sdholland.Xr strchr 3
59aa368b88Sdhollandshould be used instead.
6061f28255Scgd.Sh RETURN VALUES
615f8a6c06SperryA pointer to the character is returned if it is found; otherwise
6261f28255Scgd.Dv NULL
6361f28255Scgdis returned.
6461f28255ScgdIf
6561f28255Scgd.Fa c
6661f28255Scgdis '\e0',
6761f28255Scgd.Fn index
6861f28255Scgdlocates the terminating '\e0'.
6961f28255Scgd.Sh SEE ALSO
7061f28255Scgd.Xr memchr 3 ,
7161f28255Scgd.Xr rindex 3 ,
7261f28255Scgd.Xr strchr 3 ,
7361f28255Scgd.Xr strcspn 3 ,
7461f28255Scgd.Xr strpbrk 3 ,
7561f28255Scgd.Xr strrchr 3 ,
7661f28255Scgd.Xr strsep 3 ,
7761f28255Scgd.Xr strspn 3 ,
7861f28255Scgd.Xr strstr 3 ,
7961f28255Scgd.Xr strtok 3
80157d0c3eSjruoho.Sh STANDARDS
81157d0c3eSjruohoThe
82157d0c3eSjruoho.Fn index
83157d0c3eSjruohofunction conforms to
84157d0c3eSjruoho.St -p1003.1-2001 .
85157d0c3eSjruohoThe
86157d0c3eSjruoho.St -p1003.1-2004
87157d0c3eSjruohorevision marked it as legacy and recommended the use of
88157d0c3eSjruoho.Xr strchr 3
89157d0c3eSjruohoinstead.
90157d0c3eSjruohoThe
91157d0c3eSjruoho.St -p1003.1-2008
92157d0c3eSjruohorevision removed
93157d0c3eSjruoho.Fn index
94157d0c3eSjruohofrom the specification.
9561f28255Scgd.Sh HISTORY
96583fb063SmikelAn
9761f28255Scgd.Fn index
9861f28255Scgdfunction appeared in
9961f28255Scgd.At v6 .
100