[PATCH v4 2/5] elf: Add the endswith function to <endswith.h>
Florian Weimer
fweimer@redhat.com
Fri Nov 29 15:39:29 GMT 2024
And include <stdbool.h> for a definition of bool.
---
elf/endswith.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/elf/endswith.h b/elf/endswith.h
index c6430c48be..3954e57f8e 100644
--- a/elf/endswith.h
+++ b/elf/endswith.h
@@ -17,6 +17,7 @@
#ifndef _ENDSWITH_H
#define _ENDSWITH_H
+#include <stdbool.h>
#include <string.h>
/* Return true if the N bytes at NAME end with with the characters in
@@ -30,4 +31,11 @@ endswithn (const char *name, size_t n, const char *suffix)
strlen (suffix)) == 0);
}
+/* Same as endswithn, but uses the entire SUBJECT for matching. */
+static inline bool
+endswith (const char *subject, const char *suffix)
+{
+ return endswithn (subject, strlen (subject), suffix);
+}
+
#endif /* _ENDSWITH_H */
--
2.47.0
More information about the Libc-alpha
mailing list