xref: /dflybsd-src/contrib/grep/lib/c-strcase.h (revision 91b9ed38d3db6a8a8ac5b66da1d43e6e331e259a)
195b7b453SJohn Marino /* Case-insensitive string comparison functions in C locale.
2*09d4459fSDaniel Fojt    Copyright (C) 1995-1996, 2001, 2003, 2005, 2009-2020 Free Software
395b7b453SJohn Marino    Foundation, Inc.
495b7b453SJohn Marino 
595b7b453SJohn Marino    This program is free software; you can redistribute it and/or modify
695b7b453SJohn Marino    it under the terms of the GNU General Public License as published by
795b7b453SJohn Marino    the Free Software Foundation; either version 3, or (at your option)
895b7b453SJohn Marino    any later version.
995b7b453SJohn Marino 
1095b7b453SJohn Marino    This program is distributed in the hope that it will be useful,
1195b7b453SJohn Marino    but WITHOUT ANY WARRANTY; without even the implied warranty of
1295b7b453SJohn Marino    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1395b7b453SJohn Marino    GNU General Public License for more details.
1495b7b453SJohn Marino 
1595b7b453SJohn Marino    You should have received a copy of the GNU General Public License
16*09d4459fSDaniel Fojt    along with this program; if not, see <https://www.gnu.org/licenses/>.  */
1795b7b453SJohn Marino 
1895b7b453SJohn Marino #ifndef C_STRCASE_H
1995b7b453SJohn Marino #define C_STRCASE_H
2095b7b453SJohn Marino 
2195b7b453SJohn Marino #include <stddef.h>
2295b7b453SJohn Marino 
2395b7b453SJohn Marino 
2495b7b453SJohn Marino /* The functions defined in this file assume the "C" locale and a character
2595b7b453SJohn Marino    set without diacritics (ASCII-US or EBCDIC-US or something like that).
2695b7b453SJohn Marino    Even if the "C" locale on a particular system is an extension of the ASCII
2795b7b453SJohn Marino    character set (like on BeOS, where it is UTF-8, or on AmigaOS, where it
2895b7b453SJohn Marino    is ISO-8859-1), the functions in this file recognize only the ASCII
2995b7b453SJohn Marino    characters.  More precisely, one of the string arguments must be an ASCII
3095b7b453SJohn Marino    string; the other one can also contain non-ASCII characters (but then
3195b7b453SJohn Marino    the comparison result will be nonzero).  */
3295b7b453SJohn Marino 
3395b7b453SJohn Marino 
3495b7b453SJohn Marino #ifdef __cplusplus
3595b7b453SJohn Marino extern "C" {
3695b7b453SJohn Marino #endif
3795b7b453SJohn Marino 
3895b7b453SJohn Marino 
3995b7b453SJohn Marino /* Compare strings S1 and S2, ignoring case, returning less than, equal to or
4095b7b453SJohn Marino    greater than zero if S1 is lexicographically less than, equal to or greater
4195b7b453SJohn Marino    than S2.  */
42cf28ed85SJohn Marino extern int c_strcasecmp (const char *s1, const char *s2) _GL_ATTRIBUTE_PURE;
4395b7b453SJohn Marino 
4495b7b453SJohn Marino /* Compare no more than N characters of strings S1 and S2, ignoring case,
4595b7b453SJohn Marino    returning less than, equal to or greater than zero if S1 is
4695b7b453SJohn Marino    lexicographically less than, equal to or greater than S2.  */
47cf28ed85SJohn Marino extern int c_strncasecmp (const char *s1, const char *s2, size_t n)
48cf28ed85SJohn Marino   _GL_ATTRIBUTE_PURE;
4995b7b453SJohn Marino 
5095b7b453SJohn Marino 
5195b7b453SJohn Marino #ifdef __cplusplus
5295b7b453SJohn Marino }
5395b7b453SJohn Marino #endif
5495b7b453SJohn Marino 
5595b7b453SJohn Marino 
5695b7b453SJohn Marino #endif /* C_STRCASE_H */
57