From: Alejandro Colomar Date: Wed, 5 Feb 2025 17:42:21 +0000 (+0100) Subject: lib/string/strcmp/: strcaseeq(): Add function X-Git-Tag: 4.17.3~11 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=224466f603b8abbdbfd84bf67eae331e77b496cf;p=thirdparty%2Fshadow.git lib/string/strcmp/: strcaseeq(): Add function Signed-off-by: Alejandro Colomar --- diff --git a/lib/Makefile.am b/lib/Makefile.am index dc67df9e8..fe5032692 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -204,6 +204,8 @@ libshadow_la_SOURCES = \ string/strchr/strnul.h \ string/strchr/strrspn.c \ string/strchr/strrspn.h \ + string/strcmp/strcaseeq.c \ + string/strcmp/strcaseeq.h \ string/strcmp/streq.c \ string/strcmp/streq.h \ string/strcpy/stpecpy.c \ diff --git a/lib/string/strcmp/strcaseeq.c b/lib/string/strcmp/strcaseeq.c new file mode 100644 index 000000000..2abb3696a --- /dev/null +++ b/lib/string/strcmp/strcaseeq.c @@ -0,0 +1,12 @@ +// SPDX-FileCopyrightText: 2024-2025, Alejandro Colomar +// SPDX-License-Identifier: BSD-3-Clause + + +#include + +#include + +#include "string/strcmp/strcaseeq.h" + + +extern inline bool strcaseeq(const char *s1, const char *s2); diff --git a/lib/string/strcmp/strcaseeq.h b/lib/string/strcmp/strcaseeq.h new file mode 100644 index 000000000..e93b47702 --- /dev/null +++ b/lib/string/strcmp/strcaseeq.h @@ -0,0 +1,29 @@ +// SPDX-FileCopyrightText: 2024-2025, Alejandro Colomar +// SPDX-License-Identifier: BSD-3-Clause + + +#ifndef SHADOW_INCLUDE_LIB_STRING_STRCMP_STRCASEEQ_H_ +#define SHADOW_INCLUDE_LIB_STRING_STRCMP_STRCASEEQ_H_ + + +#include + +#include +#include + +#include "attr.h" + + +ATTR_STRING(1) ATTR_STRING(2) +inline bool strcaseeq(const char *s1, const char *s2); + + +// streq(), but case-insensitive. +inline bool +strcaseeq(const char *s1, const char *s2) +{ + return strcasecmp(s1, s2) == 0; +} + + +#endif // include guard