void-packages/srcpkgs/simgear/patches/musl-strerror_r.patch
Đoàn Trần Công Danh 4b97cd2fb4 srcpkgs/s*: convert patches to -Np1
```sh
git grep -l '^patch_args=-Np0' "srcpkgs/$1*/template" |
while read template; do
	for p in ${template%/template}/patches/*; do
		sed -i '
			\,^[+-][+-][+-] /dev/null,b
			/^[*-]\+ [0-9]\+\(,[0-9]\+\)\? [*-]\+$/b
			s,^[*][*][*] ,&a/,
			/^--- /{
				s,\(^--- \)\(./\)*,\1a/,
				s,[.-][Oo][Rr][Ii][Gg]\([	/]\),\1,
				s/[.-][Oo][Rr][Ii][Gg]$//
				s/[.]patched[.]\([^.]\)/.\1/
				h
			}
			/^+++ -/{
				g
				s/^--- a/+++ b/
				b
			}
			s,\(^+++ \)\(./\)*,\1b/,
		' "$p"
	done
	sed -i '/^patch_args=/d' $template
done
```
2021-06-20 13:17:29 +07:00

25 lines
971 B
Diff

--- a/simgear/misc/strutils.cxx 2020-06-26 00:07:33.000000000 +0200
+++ b/simgear/misc/strutils.cxx 2020-08-22 19:50:07.043076612 +0200
@@ -1137,7 +1137,13 @@
// Always makes the string in 'buf' null-terminated
retcode = strerror_s(buf, sizeof(buf), errnum);
#elif defined(_GNU_SOURCE)
+#if defined(__GLIBC__)
return std::string(strerror_r(errnum, buf, sizeof(buf)));
+#else
+ int retcode;
+ // Musl libc support
+ retcode = strerror_r(errnum, buf, sizeof(buf));
+#endif
#elif (_POSIX_C_SOURCE >= 200112L) || defined(SG_MAC) || defined(__FreeBSD__) || defined(__OpenBSD__)
int retcode;
// POSIX.1-2001 and POSIX.1-2008
@@ -1146,7 +1152,7 @@
#error "Could not find a thread-safe alternative to strerror()."
#endif
-#if !defined(_GNU_SOURCE)
+#if !defined(_GNU_SOURCE) || !defined(__GLIBC__)
if (retcode) {
std::string msg = "unable to get error message for a given error number";
// C++11 would make this shorter with std::to_string()