Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions lib/string/strchr/strnul.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
// SPDX-FileCopyrightText: 2024-2026, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause


Expand All @@ -10,17 +10,9 @@

#include <string.h>

#include "attr.h"


// string null-byte
// Similar to strlen(3), but return a pointer instead of an offset.
#define strnul(s) \
({ \
__auto_type s_ = s; \
\
s_ + strlen(s_); \
})
// strnul - string null-byte
#define strnul(s) strchr(s, '\0')


#endif // include guard
7 changes: 1 addition & 6 deletions lib/string/strcmp/strcaseeq.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
// SPDX-FileCopyrightText: 2024-2025, Alejandro Colomar <alx@kernel.org>
// SPDX-FileCopyrightText: 2024-2026, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause


#include "config.h"

#include <stdbool.h>

#include "string/strcmp/strcaseeq.h"


extern inline bool strcaseeq(const char *s1, const char *s2);
18 changes: 3 additions & 15 deletions lib/string/strcmp/strcaseeq.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2024-2025, Alejandro Colomar <alx@kernel.org>
// SPDX-FileCopyrightText: 2024-2026, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause


Expand All @@ -8,23 +8,11 @@

#include "config.h"

#include <stdbool.h>
#include <strings.h>

#include "attr.h"


ATTR_STRING(1) ATTR_STRING(2)
inline bool strcaseeq(const char *s1, const char *s2);


// strings case-insensitive equal
// streq(), but case-insensitive.
inline bool
strcaseeq(const char *s1, const char *s2)
{
return strcasecmp(s1, s2) == 0;
}
// strcaseeq - strings case-insensitive equal
#define strcaseeq(s1, s2) (!strcasecmp(s1, s2))


#endif // include guard
7 changes: 1 addition & 6 deletions lib/string/strcmp/streq.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
// SPDX-FileCopyrightText: 2024-2026, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause


#include "config.h"

#include <stdbool.h>

#include "string/strcmp/streq.h"


extern inline bool streq(const char *s1, const char *s2);
19 changes: 3 additions & 16 deletions lib/string/strcmp/streq.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
// SPDX-FileCopyrightText: 2024-2026, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause


Expand All @@ -8,24 +8,11 @@

#include "config.h"

#include <stdbool.h>
#include <string.h>

#include "attr.h"


ATTR_STRING(1)
ATTR_STRING(2)
inline bool streq(const char *s1, const char *s2);


// strings equal
/* Return true if s1 and s2 compare equal. */
inline bool
streq(const char *s1, const char *s2)
{
return strcmp(s1, s2) == 0;
}
// streq - strings equal
#define streq(s1, s2) (!strcmp(s1, s2))


#endif // include guard
Loading