gentoo-overlay/sys-apps/systemd/files/0015-basic-Define-our-own-b...

35 lines
1.2 KiB
Diff
Raw Permalink Normal View History

From 6ef506dbf1d28618d92f0b9bb2b2fa2b989acd99 Mon Sep 17 00:00:00 2001
From: "A. Wilcox" <AWilcox@Wilcox-Tech.com>
Date: Sun, 18 Aug 2024 02:50:50 -0500
Subject: [PATCH 15/34] basic: Define our own basename
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
This prevents issues where the POSIX basename is not the same as the GNU
basename. I think maybe upstream could be convinced since glibc does
provide the POSIX one as well, but until then, let's do this.
This cannot be upstreamed.
Signed-off-by: Alexander Miroshnichenko <alex@millerson.name>
---
src/basic/string-util.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/basic/string-util.h b/src/basic/string-util.h
index ff5efbcf557b..656f5100e202 100644
--- a/src/basic/string-util.h
+++ b/src/basic/string-util.h
@@ -26,6 +26,8 @@
#define URI_UNRESERVED ALPHANUMERICAL "-._~" /* [RFC3986] */
#define URI_VALID URI_RESERVED URI_UNRESERVED /* [RFC3986] */
+#define basename(src) (strrchr(src,'/') ? strrchr(src,'/')+1 : src)
+
static inline char* strstr_ptr(const char *haystack, const char *needle) {
if (!haystack || !needle)
return NULL;
--
2.41.0