Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame^] | 1 | From cdd69321ec97ed19e66a747a968a1637a251b9e6 Mon Sep 17 00:00:00 2001 |
| 2 | From: =?UTF-8?q?Andreas=20M=C3=BCller?= <schnitzeltony@gmail.com> |
| 3 | Date: Mon, 16 Apr 2018 15:07:20 +0200 |
| 4 | Subject: [PATCH] Add a strndupa replacement for musl |
| 5 | MIME-Version: 1.0 |
| 6 | Content-Type: text/plain; charset=UTF-8 |
| 7 | Content-Transfer-Encoding: 8bit |
| 8 | |
| 9 | Upstream-Status: Pending |
| 10 | |
| 11 | Signed-off-by: Andreas MΓΌller <schnitzeltony@gmail.com> |
| 12 | |
| 13 | --- |
| 14 | shared/systemd/src/basic/in-addr-util.c | 1 + |
| 15 | shared/systemd/src/basic/string-util.h | 5 +++++ |
| 16 | 2 files changed, 6 insertions(+) |
| 17 | |
| 18 | diff --git a/shared/systemd/src/basic/in-addr-util.c b/shared/systemd/src/basic/in-addr-util.c |
| 19 | index 5ced350..c6b52b8 100644 |
| 20 | --- a/shared/systemd/src/basic/in-addr-util.c |
| 21 | +++ b/shared/systemd/src/basic/in-addr-util.c |
| 22 | @@ -13,6 +13,7 @@ |
| 23 | #include "in-addr-util.h" |
| 24 | #include "macro.h" |
| 25 | #include "parse-util.h" |
| 26 | +#include "string-util.h" |
| 27 | #include "util.h" |
| 28 | |
| 29 | bool in4_addr_is_null(const struct in_addr *a) { |
| 30 | diff --git a/shared/systemd/src/basic/string-util.h b/shared/systemd/src/basic/string-util.h |
| 31 | index 38070ab..6b918e0 100644 |
| 32 | --- a/shared/systemd/src/basic/string-util.h |
| 33 | +++ b/shared/systemd/src/basic/string-util.h |
| 34 | @@ -27,6 +27,11 @@ |
| 35 | #define strcaseeq(a,b) (strcasecmp((a),(b)) == 0) |
| 36 | #define strncaseeq(a, b, n) (strncasecmp((a), (b), (n)) == 0) |
| 37 | |
| 38 | +/* musl does not know strndupa */ |
| 39 | +#if !defined(__GLIBC__) |
| 40 | +#define strndupa(x,s) strncpy(alloca(strlen(x)+1),x,s) |
| 41 | +#endif |
| 42 | + |
| 43 | int strcmp_ptr(const char *a, const char *b) _pure_; |
| 44 | |
| 45 | static inline bool streq_ptr(const char *a, const char *b) { |