pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/devel/m4 Override gnulib's fflush.c on DragonFly with ...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/b82ccd75647d
branches:  trunk
changeset: 531396:b82ccd75647d
user:      joerg <joerg%pkgsrc.org@localhost>
date:      Sun Jul 29 14:36:46 2007 +0000

description:
Override gnulib's fflush.c on DragonFly with a far less intrusive
versions. This is still in discussion with upstream, but working m4
is critical, so apply this stop-gap solution. It works on the other
BSD derived stdio implementations as well, if you want to switch.

diffstat:

 devel/m4/Makefile           |   7 +++-
 devel/m4/distinfo           |   4 +-
 devel/m4/files/bsd-fflush.c |  72 +++++++++++++++++++++++++++++++++++++++++++++
 devel/m4/patches/patch-ab   |  13 ++++++++
 devel/m4/patches/patch-ac   |  24 +++++++++++++++
 5 files changed, 118 insertions(+), 2 deletions(-)

diffs (155 lines):

diff -r 02ba7a88eb6c -r b82ccd75647d devel/m4/Makefile
--- a/devel/m4/Makefile Sun Jul 29 14:33:12 2007 +0000
+++ b/devel/m4/Makefile Sun Jul 29 14:36:46 2007 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.50 2007/07/22 06:34:41 wiz Exp $
+# $NetBSD: Makefile,v 1.51 2007/07/29 14:36:46 joerg Exp $
 
 DISTNAME=      m4-1.4.10
 PKGREVISION=   1
@@ -32,6 +32,11 @@
 PLIST_SUBST+=          GM4_LINK="@comment "
 .endif
 
+.if ${OPSYS} == "DragonFly"
+post-patch:
+       ${CP} ${FILESDIR}/bsd-fflush.c ${WRKSRC}/lib/fflush.c
+.endif
+
 post-install:
        ${INSTALL_DATA_DIR} ${DESTDIR}${PREFIX}/share/examples/m4
        ${INSTALL_DATA} ${WRKSRC}/examples/*.m4 ${DESTDIR}${PREFIX}/share/examples/m4
diff -r 02ba7a88eb6c -r b82ccd75647d devel/m4/distinfo
--- a/devel/m4/distinfo Sun Jul 29 14:33:12 2007 +0000
+++ b/devel/m4/distinfo Sun Jul 29 14:36:46 2007 +0000
@@ -1,6 +1,8 @@
-$NetBSD: distinfo,v 1.19 2007/07/22 06:34:41 wiz Exp $
+$NetBSD: distinfo,v 1.20 2007/07/29 14:36:46 joerg Exp $
 
 SHA1 (m4-1.4.10.tar.gz) = 26d47c893722d683308f5d9fc172a11d5b2ad8a9
 RMD160 (m4-1.4.10.tar.gz) = 0a26a714ce9691006524da7c2c3e2859e7321a95
 Size (m4-1.4.10.tar.gz) = 928375 bytes
 SHA1 (patch-aa) = 426327aabb1f48647b3561439dba0261a49860f3
+SHA1 (patch-ab) = 01838a4b055888f48650f6e621f3848c47f7af2a
+SHA1 (patch-ac) = 86c14a4deae3171a0b7a66a2daf94eb58688b742
diff -r 02ba7a88eb6c -r b82ccd75647d devel/m4/files/bsd-fflush.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/devel/m4/files/bsd-fflush.c       Sun Jul 29 14:36:46 2007 +0000
@@ -0,0 +1,72 @@
+/* $NetBSD: bsd-fflush.c,v 1.1 2007/07/29 14:36:46 joerg Exp $ */
+
+/*-
+ * Copyright (c) 2007 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
+ * All rights reserved.
+ *
+ * This code was developed as part of Google's Summer of Code 2007 program.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+ 
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#undef fflush
+
+int
+rpl_fflush(FILE *fp)
+{
+#if defined(__DragonFly__)
+       struct __FILE_public *fp_ = (struct __FILE_public *)fp;
+#else
+#define        fp_ fp
+#endif
+       off_t pos;
+
+       /* NULL pointer or writeable stream: use normal fflush. */
+       if (fp == NULL || (fp_->_flags & (__SWR | __SRW)) != 0)
+               return fflush(fp);
+
+       /* Get current position, possibly different from file pointer. */
+       pos = ftello(fp);
+       if (pos == -1) {
+               errno = EBADF;
+               return -1;
+       }
+       /* Purge buffers. */
+       if (fpurge(fp) == EOF)
+               return -1;
+
+       /*
+        * Disable seek optimisation.  This is forces the following
+        * fseeko to seek the actual position and not realign
+        * the file pointer on a block boundary.
+        */
+       fp_->_flags |= __SNPT;
+
+       return fseeko(fp, pos, SEEK_SET);
+}
diff -r 02ba7a88eb6c -r b82ccd75647d devel/m4/patches/patch-ab
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/devel/m4/patches/patch-ab Sun Jul 29 14:36:46 2007 +0000
@@ -0,0 +1,13 @@
+$NetBSD: patch-ab,v 1.5 2007/07/29 14:36:46 joerg Exp $
+
+--- lib/freading.c.orig        2007-07-24 15:10:13.000000000 +0000
++++ lib/freading.c
+@@ -34,6 +34,8 @@ freading (FILE *fp)
+   return ((fp->_flags & _IO_NO_WRITES) != 0
+         || ((fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0
+             && fp->_IO_read_base != NULL));
++#elif defined(__DragonFly__)
++  return (((struct __FILE_public *)fp)->_flags & __SRD) != 0;
+ #elif defined __sferror             /* FreeBSD, NetBSD, OpenBSD, MacOS X, Cygwin */
+   return (fp->_flags & __SRD) != 0;
+ #elif defined _IOERR                /* AIX, HP-UX, IRIX, OSF/1, Solaris, mingw */
diff -r 02ba7a88eb6c -r b82ccd75647d devel/m4/patches/patch-ac
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/devel/m4/patches/patch-ac Sun Jul 29 14:36:46 2007 +0000
@@ -0,0 +1,24 @@
+$NetBSD: patch-ac,v 1.6 2007/07/29 14:36:47 joerg Exp $
+
+--- configure.orig     2007-07-29 13:25:52.000000000 +0000
++++ configure
+@@ -11711,10 +11711,17 @@ echo "${ECHO_T}$gl_cv_func_fflush_stdin"
+   if test $gl_cv_func_fflush_stdin = no; then
+ 
+   M4_LIBOBJS="$M4_LIBOBJS fflush.$ac_objext"
+-  M4_LIBOBJS="$M4_LIBOBJS fseeko.$ac_objext"
+ 
+   REPLACE_FFLUSH=1
+-  REPLACE_FSEEKO=1
++  case "$host_os" in
++  dragonfly*)
++    REPLACE_FSEEKO=0
++    ;;
++  *)
++    M4_LIBOBJS="$M4_LIBOBJS fseeko.$ac_objext"
++    REPLACE_FSEEKO=1
++    ;;
++  esac
+ 
+   fi
+ 



Home | Main Index | Thread Index | Old Index