37 lines
1.3 KiB
Diff
37 lines
1.3 KiB
Diff
--- src/shared/musl_missing.h
|
|
+++ src/shared/musl_missing.h
|
|
@@ -55,13 +55,14 @@ extern char *program_invocation_short_name;
|
|
|
|
/* strndupa may already be defined in another compatibility header */
|
|
#if !defined(strndupa)
|
|
-#define strndupa(src, n) \
|
|
- (__extension__ ({const char *in = (src); \
|
|
- size_t len = strnlen(in, (n)) + 1; \
|
|
- char *out = (char *) alloca(len); \
|
|
- out[len-1] = '\0'; \
|
|
- (char *) memcpy(out, in, len-1);}) \
|
|
- )
|
|
+#define strndupa(x_src, x_n) \
|
|
+ (__extension__ ( { \
|
|
+ const char* x_in = (x_src); \
|
|
+ size_t x_len = strnlen(x_in, (x_n)) + 1; \
|
|
+ char* x_out = (char *) alloca(x_len); \
|
|
+ x_out[x_len-1] = '\0'; \
|
|
+ (char *) memcpy(x_out, x_in, x_len-1); \
|
|
+ } ) )
|
|
#endif
|
|
|
|
/* See http://man7.org/linux/man-pages/man3/canonicalize_file_name.3.html */
|
|
--- src/test/test-hexdecoct.c
|
|
+++ src/test/test-hexdecoct.c
|
|
@@ -22,6 +22,9 @@
|
|
#include "macro.h"
|
|
#include "string-util.h"
|
|
|
|
+/// Additional includes needed by elogind
|
|
+#include "musl_missing.h"
|
|
+
|
|
static void test_hexchar(void) {
|
|
assert_se(hexchar(0xa) == 'a');
|
|
assert_se(hexchar(0x0) == '0');
|
|
|