aboutsummaryrefslogtreecommitdiffstats
path: root/main/ympd/musl-missing-errorh.patch
diff options
context:
space:
mode:
Diffstat (limited to 'main/ympd/musl-missing-errorh.patch')
-rw-r--r--main/ympd/musl-missing-errorh.patch80
1 files changed, 80 insertions, 0 deletions
diff --git a/main/ympd/musl-missing-errorh.patch b/main/ympd/musl-missing-errorh.patch
new file mode 100644
index 0000000000..960ca3fc11
--- /dev/null
+++ b/main/ympd/musl-missing-errorh.patch
@@ -0,0 +1,80 @@
+--- ympd-1.2.2/htdocs/mkdata.c
++++ ympd-1.2.2/htdocs/mkdata.c
+@@ -7,7 +7,11 @@
+
+ #include <stdlib.h>
+ #include <stdio.h>
++#if HAVE_ERROR_H
+ #include <error.h>
++#else
++#include <stdarg.h>
++#endif
+ #include <errno.h>
+ #include <string.h>
+
+@@ -53,6 +57,60 @@
+ return "text/plain";
+ }
+
++/*
++ * Program name.
++ */
++#ifndef HAVE_PROGRAM_INVOCATION_SHORT_NAME
++# ifdef HAVE___PROGNAME
++extern char *__progname;
++# define program_invocation_short_name __progname
++# else
++# ifdef HAVE_GETEXECNAME
++# define program_invocation_short_name \
++ prog_inv_sh_nm_from_file(getexecname(), 0)
++# else
++# define program_invocation_short_name \
++ prog_inv_sh_nm_from_file(__FILE__, 1)
++# endif
++static char prog_inv_sh_nm_buf[256];
++static inline char *prog_inv_sh_nm_from_file(char *f, char stripext)
++{
++ char *t;
++
++ if ((t = strrchr(f, '/')) != NULL)
++ t++;
++ else
++ t = f;
++
++ strncpy(prog_inv_sh_nm_buf, t, sizeof(prog_inv_sh_nm_buf) - 1);
++ prog_inv_sh_nm_buf[sizeof(prog_inv_sh_nm_buf) - 1] = '\0';
++
++ if (stripext && (t = strrchr(prog_inv_sh_nm_buf, '.')) != NULL)
++ *t = '\0';
++
++ return prog_inv_sh_nm_buf;
++}
++# endif
++#endif
++
++#ifndef HAVE_ERROR_H
++/* Emulate the error() function from glibc */
++__attribute__((__format__(__printf__, 3, 4)))
++static void error(int status, int errnum, const char *format, ...)
++{
++ va_list argp;
++ fprintf(stderr, "%s: ", program_invocation_short_name);
++ va_start(argp, format);
++ vfprintf(stderr, format, argp);
++ va_end(argp);
++ if (errnum != 0)
++ fprintf(stderr, ": error code %d", errnum);
++ fprintf(stderr, "\n");
++ if (status != 0)
++ exit(status);
++}
++#endif
++
+ int main(int argc, char *argv[])
+ {
+ int i, j, buf;
+@@ -92,3 +150,4 @@
+ fputs(footer, stdout);
+ return EXIT_SUCCESS;
+ }
++