]> git.saurik.com Git - apple/libc.git/blame - string/FreeBSD/strcasecmp.3
Libc-1081.1.3.tar.gz
[apple/libc.git] / string / FreeBSD / strcasecmp.3
CommitLineData
5b2abdfb 1.\" Copyright (c) 1990, 1991, 1993
e9ce8d39
A
2.\" The Regents of the University of California. All rights reserved.
3.\"
5b2abdfb
A
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek.
e9ce8d39
A
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\" notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\" notice, this list of conditions and the following disclaimer in the
13.\" documentation and/or other materials provided with the distribution.
e9ce8d39
A
14.\" 4. Neither the name of the University nor the names of its contributors
15.\" may be used to endorse or promote products derived from this software
16.\" without specific prior written permission.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE.
29.\"
5b2abdfb 30.\" @(#)strcasecmp.3 8.1 (Berkeley) 6/9/93
1f2f436a 31.\" $FreeBSD: src/lib/libc/string/strcasecmp.3,v 1.13 2009/04/07 13:42:53 trasz Exp $
e9ce8d39 32.\"
5b2abdfb
A
33.Dd June 9, 1993
34.Dt STRCASECMP 3
e9ce8d39
A
35.Os
36.Sh NAME
5b2abdfb 37.Nm strcasecmp ,
ad3c9f2a
A
38.Nm strcasecmp_l ,
39.Nm strncasecmp ,
40.Nm strncasecmp_l
5b2abdfb 41.Nd compare strings, ignoring case
e9ce8d39
A
42.Sh LIBRARY
43.Lb libc
44.Sh SYNOPSIS
9385eb3d 45.In strings.h
e9ce8d39 46.Ft int
ad3c9f2a
A
47.Fo strcasecmp
48.Fa "const char *s1"
49.Fa "const char *s2"
50.Fc
5b2abdfb 51.Ft int
ad3c9f2a
A
52.Fo strncasecmp
53.Fa "const char *s1"
54.Fa "const char *s2"
55.Fa "size_t n"
56.Fc
57.In strings.h
58.In xlocale.h
59.Ft int
60.Fo strcasecmp_l
61.Fa "const char *s1"
62.Fa "const char *s2"
63.Fa "locale_t loc"
64.Fc
65.Ft int
66.Fo strncasecmp_l
67.Fa "const char *s1"
68.Fa "const char *s2"
69.Fa "size_t n"
70.Fa "locale_t loc"
71.Fc
e9ce8d39
A
72.Sh DESCRIPTION
73The
5b2abdfb 74.Fn strcasecmp
e9ce8d39 75and
5b2abdfb
A
76.Fn strncasecmp
77functions
78compare the null-terminated strings
79.Fa s1
80and
81.Fa s2 .
82.Pp
e9ce8d39 83The
5b2abdfb
A
84.Fn strncasecmp
85compares at most
ad3c9f2a 86.Fa n
5b2abdfb 87characters.
ad3c9f2a
A
88.Pp
89Although the
90.Fn strcasecmp
91and
92.Fn strncasecmp
93functions use the current locale, the
94.Fn strcasecmp_l
95and
96.Fn strncasecmp_l
97functions may be passed locales directly. See
98.Xr xlocale 3
99for more information.
5b2abdfb
A
100.Sh RETURN VALUES
101The
102.Fn strcasecmp
103and
104.Fn strncasecmp
105return an integer greater than, equal to, or less than 0,
106according as
107.Fa s1
108is lexicographically greater than, equal to, or less than
109.Fa s2
110after translation of each corresponding character to lower-case.
111The strings themselves are not modified.
112The comparison is done using unsigned characters, so that
113.Sq Li \e200
114is greater than
115.Ql \e0 .
e9ce8d39 116.Sh SEE ALSO
5b2abdfb
A
117.Xr bcmp 3 ,
118.Xr memcmp 3 ,
119.Xr strcmp 3 ,
120.Xr strcoll 3 ,
121.Xr strxfrm 3 ,
1f2f436a 122.Xr tolower 3 ,
ad3c9f2a 123.Xr xlocale 3
e9ce8d39
A
124.Sh HISTORY
125The
5b2abdfb
A
126.Fn strcasecmp
127and
128.Fn strncasecmp
129functions first appeared in
e9ce8d39 130.Bx 4.4 .
9385eb3d 131Their prototypes existed previously in
3d9156a7 132.In string.h
9385eb3d 133before they were moved to
3d9156a7 134.In strings.h
9385eb3d
A
135for
136.St -p1003.1-2001
137compliance.