Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 1 | From 6db6596e450062601d18b2ae812a4a58d2e03a53 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 | src/systemd/src/basic/in-addr-util.c | 1 + |
| 14 | src/systemd/src/basic/string-util.h | 5 +++++ |
| 15 | 2 files changed, 6 insertions(+) |
| 16 | |
| 17 | diff --git a/src/systemd/src/basic/in-addr-util.c b/src/systemd/src/basic/in-addr-util.c |
| 18 | index 2a02d90..a57c360 100644 |
| 19 | --- a/src/systemd/src/basic/in-addr-util.c |
| 20 | +++ b/src/systemd/src/basic/in-addr-util.c |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 21 | @@ -13,6 +13,7 @@ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 22 | #include "in-addr-util.h" |
| 23 | #include "macro.h" |
| 24 | #include "parse-util.h" |
| 25 | +#include "string-util.h" |
| 26 | #include "util.h" |
| 27 | |
| 28 | bool in4_addr_is_null(const struct in_addr *a) { |
| 29 | diff --git a/src/systemd/src/basic/string-util.h b/src/systemd/src/basic/string-util.h |
| 30 | index 4c94b18..a6dc446 100644 |
| 31 | --- a/src/systemd/src/basic/string-util.h |
| 32 | +++ b/src/systemd/src/basic/string-util.h |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 33 | @@ -26,6 +26,11 @@ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 34 | #define strcaseeq(a,b) (strcasecmp((a),(b)) == 0) |
| 35 | #define strncaseeq(a, b, n) (strncasecmp((a), (b), (n)) == 0) |
| 36 | |
| 37 | +/* musl does not know strndupa */ |
| 38 | +#if !defined(__GLIBC__) |
| 39 | +#define strndupa(x,s) strncpy(alloca(strlen(x)+1),x,s) |
| 40 | +#endif |
| 41 | + |
| 42 | int strcmp_ptr(const char *a, const char *b) _pure_; |
| 43 | |
| 44 | static inline bool streq_ptr(const char *a, const char *b) { |
| 45 | -- |
| 46 | 2.14.3 |
| 47 | |