From: Alejandro Colomar Date: Tue, 15 Oct 2024 11:21:17 +0000 (+0200) Subject: lib/string/strcmp/: streq(): Add function X-Git-Tag: 4.17.0-rc1~34 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=67c42427a0941a4b47c04e8a95322be9d069ff32;p=thirdparty%2Fshadow.git lib/string/strcmp/: streq(): Add function Signed-off-by: Alejandro Colomar --- diff --git a/lib/Makefile.am b/lib/Makefile.am index 4ea5ec4e5..96393354b 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -190,6 +190,8 @@ libshadow_la_SOURCES = \ string/strchr/strnul.h \ string/strchr/strrspn.c \ string/strchr/strrspn.h \ + string/strcmp/streq.c \ + string/strcmp/streq.h \ string/strcpy/stpecpy.c \ string/strcpy/stpecpy.h \ string/strcpy/strncat.c \ diff --git a/lib/string/strcmp/streq.c b/lib/string/strcmp/streq.c new file mode 100644 index 000000000..52057ed84 --- /dev/null +++ b/lib/string/strcmp/streq.c @@ -0,0 +1,12 @@ +// SPDX-FileCopyrightText: 2024, Alejandro Colomar +// SPDX-License-Identifier: BSD-3-Clause + + +#include + +#include + +#include "string/strcmp/streq.h" + + +extern inline bool streq(const char *s1, const char *s2); diff --git a/lib/string/strcmp/streq.h b/lib/string/strcmp/streq.h new file mode 100644 index 000000000..267045c5c --- /dev/null +++ b/lib/string/strcmp/streq.h @@ -0,0 +1,30 @@ +// SPDX-FileCopyrightText: 2024, Alejandro Colomar +// SPDX-License-Identifier: BSD-3-Clause + + +#ifndef SHADOW_INCLUDE_LIB_STRING_STRCMP_STREQ_H_ +#define SHADOW_INCLUDE_LIB_STRING_STRCMP_STREQ_H_ + + +#include + +#include +#include + +#include "attr.h" + + +ATTR_STRING(1) +ATTR_STRING(2) +inline bool streq(const char *s1, const char *s2); + + +/* Return true if s1 and s2 compare equal. */ +inline bool +streq(const char *s1, const char *s2) +{ + return strcmp(s1, s2) == 0; +} + + +#endif // include guard