diff --git a/lib/Makefile.am b/lib/Makefile.am index 4ea5ec4e..96393354 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 00000000..52057ed8 --- /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 00000000..267045c5 --- /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