From 239afe3fe7b955493174afa7341ef19be4bdf3cb Mon Sep 17 00:00:00 2001
From: Paul Moore
Date: Mon, 13 Apr 2015 14:20:32 +0100
Subject: [PATCH] New package diffutils
---
mingw-w64-diffutils/PKGBUILD | 48 +++++++++++++++++++
.../msvc_invalid_parameter_handler.patch | 13 +++++
.../win64_dont_check_ptrdiff_size.patch | 13 +++++
.../win_use_raise_rather_than_kill.patch | 14 ++++++
4 files changed, 88 insertions(+)
create mode 100644 mingw-w64-diffutils/PKGBUILD
create mode 100644 mingw-w64-diffutils/msvc_invalid_parameter_handler.patch
create mode 100644 mingw-w64-diffutils/win64_dont_check_ptrdiff_size.patch
create mode 100644 mingw-w64-diffutils/win_use_raise_rather_than_kill.patch
diff --git a/mingw-w64-diffutils/PKGBUILD b/mingw-w64-diffutils/PKGBUILD
new file mode 100644
index 0000000000..be64ba1108
--- /dev/null
+++ b/mingw-w64-diffutils/PKGBUILD
@@ -0,0 +1,48 @@
+# Maintainer: Alexey Pavlov
+# Contributor: Paul Moore
+
+_realname=diffutils
+pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
+pkgver=3.3
+pkgrel=1
+pkgdesc="GNU Diffutils is a package of several programs related to finding differences between files (mingw-w64)"
+arch=('any')
+url='http://www.gnu.org/software/diffutils/'
+license=('GPL3')
+depends=("${MINGW_PACKAGE_PREFIX}-libwinpthread")
+options=('strip' '!libtool' 'staticlibs')
+source=("http://ftp.gnu.org/gnu/${_realname}/${_realname}-${pkgver}.tar.xz"
+ "win_use_raise_rather_than_kill.patch"
+ "win64_dont_check_ptrdiff_size.patch"
+ "msvc_invalid_parameter_handler.patch")
+md5sums=('99180208ec2a82ce71f55b0d7389f1b3'
+ '6e979e13696642bd184fb6b946ba996a'
+ '957454716c06313df2251cd2baf5a89c'
+ 'de6ece1a99a2471131899e49355f87e4')
+
+
+prepare() {
+ cd $srcdir/${_realname}-${pkgver}
+ patch -p0 -i ${srcdir}/win_use_raise_rather_than_kill.patch
+ patch -p0 -i ${srcdir}/win64_dont_check_ptrdiff_size.patch
+ patch -p0 -i ${srcdir}/msvc_invalid_parameter_handler.patch
+}
+
+build() {
+ cd $srcdir/${_realname}-${pkgver}
+ ./configure --prefix=${MINGW_PREFIX} \
+ --build=${MINGW_CHOST} \
+ --host=${MINGW_CHOST} \
+ --target=${MINGW_CHOST}
+
+ make
+}
+
+package() {
+ cd ${srcdir}/${_realname}-${pkgver}
+ make install DESTDIR="${pkgdir}"
+
+ # Licenses
+ install -Dm644 "${srcdir}/${_realname}-${pkgver}/README" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/README"
+ install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
+}
diff --git a/mingw-w64-diffutils/msvc_invalid_parameter_handler.patch b/mingw-w64-diffutils/msvc_invalid_parameter_handler.patch
new file mode 100644
index 0000000000..957349ef21
--- /dev/null
+++ b/mingw-w64-diffutils/msvc_invalid_parameter_handler.patch
@@ -0,0 +1,13 @@
+--- lib/config.hin.orig 2013-03-24 17:55:37.000000000 +0000
++++ lib/config.hin 2015-04-13 13:38:17.351409000 +0100
+@@ -599,7 +599,9 @@
+
+ /* Define to 1 on MSVC platforms that have the "invalid parameter handler"
+ concept. */
+-#undef HAVE_MSVC_INVALID_PARAMETER_HANDLER
++/* Commented out due to a gnulib bug - see
++ http://lists.gnu.org/archive/html/bug-sed/2015-01/msg00003.html */
++/* #undef HAVE_MSVC_INVALID_PARAMETER_HANDLER */
+
+ /* Define to 1 if you have the `nanotime' function. */
+ #undef HAVE_NANOTIME
diff --git a/mingw-w64-diffutils/win64_dont_check_ptrdiff_size.patch b/mingw-w64-diffutils/win64_dont_check_ptrdiff_size.patch
new file mode 100644
index 0000000000..128e84dbd1
--- /dev/null
+++ b/mingw-w64-diffutils/win64_dont_check_ptrdiff_size.patch
@@ -0,0 +1,13 @@
+--- src/system.h.orig 2013-02-02 04:39:05.000000000 +0000
++++ src/system.h 2015-04-13 13:22:05.557095800 +0100
+@@ -132,7 +132,10 @@
+ #define LIN_MAX PTRDIFF_MAX
+ verify (TYPE_SIGNED (lin));
+ verify (sizeof (ptrdiff_t) <= sizeof (lin));
++#ifndef _WIN64
++/* On Windows 64-bit, this fails. It's probably not an issue in practice. */
+ verify (sizeof (lin) <= sizeof (long int));
++#endif
+
+ /* This section contains POSIX-compliant defaults for macros
+ that are meant to be overridden by hand in config.h as needed. */
diff --git a/mingw-w64-diffutils/win_use_raise_rather_than_kill.patch b/mingw-w64-diffutils/win_use_raise_rather_than_kill.patch
new file mode 100644
index 0000000000..998f5e5783
--- /dev/null
+++ b/mingw-w64-diffutils/win_use_raise_rather_than_kill.patch
@@ -0,0 +1,14 @@
+--- src/sdiff.c.orig 2013-02-02 04:39:05.000000000 +0000
++++ src/sdiff.c 2015-04-13 13:17:38.480390800 +0100
+@@ -805,7 +805,11 @@
+
+ /* Yield an exit status indicating that a signal was received. */
+ untrapsig (s);
++#if defined _MSC_VER || defined __MINGW32__
++ raise (s);
++#else
+ kill (getpid (), s);
++#endif
+
+ /* That didn't work, so exit with error status. */
+ exit (EXIT_TROUBLE);