#! /bin/sh -e

# DP: libf2c update taken from the 3.4.1 release.

dir=
if [ $# -eq 3 -a "$2" = '-d' ]; then
    pdir="-d $3"
    dir="$3/"
elif [ $# -ne 1 ]; then
    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
    exit 1
fi
case "$1" in
    -patch)
        patch $pdir -f --no-backup-if-mismatch -p0 < $0
        ( cd ${dir}libf2c && autoconf2.13 )
        ( cd ${dir}libf2c/libF77 && autoconf2.13 )
        ( cd ${dir}libf2c/libI77 && autoconf2.13 )
        ( cd ${dir}libf2c/libU77 && autoconf2.13 )
        ;;
    -unpatch)
        patch $pdir -f --no-backup-if-mismatch -R -p0 < $0
        rm -f ${dir}libf2c/configure ${dir}libf2c/lib[FIU]77/configure
        ;;
    *)
        echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
        exit 1
esac
exit 0

diff -ur --exclude=CVS libf2c-3.3/ChangeLog libf2c/ChangeLog
--- libf2c-3.3/ChangeLog	2004-06-12 21:58:34.000000000 +0200
+++ libf2c/ChangeLog	2004-07-06 10:39:07.000000000 +0200
@@ -2,47 +2,93 @@
 
 	* GCC 3.3.5 Released.
 
+2004-09-06  Release Manager
+
+	* GCC 3.4.2 Released.
+
+2004-07-01  Release Manager
+
+	* GCC 3.4.1 released.
+
 2004-05-31  Release Manager
 
 	* GCC 3.3.4 Released.
 
+2004-05-06  Bud Davis  <bdavis9659@comcast.net>
+
+	PR libf2c/15151
+	* libI77/wrtfmt.c(wrt_L):  Make sizes and types consistent.
+
+2004-04-18  Release Manager
+
+	* GCC 3.4.0 released.
+
 2004-02-14  Release Manager
 
 	* GCC 3.3.3 Released.
 
+2004-01-31  Bud Davis  <bdavis9659@comcast.net>
+
+	PR fortran/12884
+	* libI77/rsne.c: Enable reading a '/' when reading
+	a '$' delimited namelist.
+
+2004-01-14 Kelley Cook  <kcook@gcc.gnu.org>
+
+	* libF77/configure.in: Update to AC_PREREQ(2.13)
+	* libI77/configure.in: Update to AC_PREREQ(2.13)
+	* libU77/configure.in: Update to AC_PREREQ(2.13)
+	* libU77/configure: Regenerate. 
+
 2003-10-16  Release Manager
 
 	* GCC 3.3.2 Released.
 
-2003-09-09  Alan Modra  <amodra@bigpond.net.au>
+2003-10-14  Nathanael Nerode  <neroden@gcc.gnu.org>
 
 	* configure: Regenerate.
 
-2003-08-04  Release Manager
+2003-09-21  Toon Moene  <toon@moene.indiv.nluug.nl>
+
+	PR libf2c/11918
+	* fstat_.c: Call f_init().
+	* isatty_.c: Ditto.
+	* fnum_.c: Check file descriptor before handing it back.
 
-	* GCC 3.3.1 Released.
+Tue Sep  9 15:22:57 2003  Alan Modra  <amodra@bigpond.net.au>
+
+	* configure: Regenerate.
 
 2003-08-04  Release Manager
 
-	* GCC 3.3.1 Released.
+	* GCC 3.3.1 Released.2004-05-31  Release Manager
 
-2003-07-04  H.J. Lu <hongjiu.lu@intel.com>
+	* GCC 3.3.4 Released.
 
-	* Makefile.in: Replace PWD with PWD_COMMAND.
+2004-02-14  Release Manager
 
-2003-05-13  Release Manager
+	* GCC 3.3.3 Released.
 
-	* GCC 3.3 Released.
+2003-10-16  Release Manager
 
-2003-05-13  Release Manager
+	* GCC 3.3.2 Released.
 
-	* GCC 3.3 Released.
+
+
+2003-07-04  H.J. Lu <hongjiu.lu@intel.com>
+
+	* Makefile.in: Replace PWD with PWD_COMMAND.
 
 2003-05-13  Release Manager
 
 	* GCC 3.3 Released.
 
-2003-04-23  Loren J. Rittle  <ljrittle@acm.org>
+2003-06-15  Nathanael Nerode  <neroden@gcc.gnu.org>
+
+	* libU77/bes.c, libU77/dbes.c: Remove.
+	* libU77/Makefile.in: Remove references to bes.c, dbes.c
+
+2003-04-21  Loren J. Rittle  <ljrittle@acm.org>
 
 	* libI77/configure.in (_XOPEN_SOURCE): Bump to 600.
 	* libI77/configure: Regenerate. 
@@ -61,12 +107,24 @@
 	* libI77/open.c (f_open): A DIRECT ACCESS file is
 	UNFORMATTED by default.
 
+Wed Mar 12 22:27:14 2003  Andreas Schwab  <schwab@suse.de>
+
+	* aclocal.m4 (GLIBCPP_EXPORT_INSTALL_INFO): Avoid trailing /. in
+	glibcpp_toolexeclibdir.
+	* configure: Rebuilt.
+
 2003-02-20  Alexandre Oliva  <aoliva@redhat.com>
 
 	* configure.in: Propagate ORIGINAL_LD_FOR_MULTILIBS to
 	config.status.
 	* configure: Rebuilt.
 
+2003-02-03  Andreas Jaeger  <aj@suse.de>
+
+	* libU77/configure.in (AC_PROG_CC_WORKS): Define _GNU_SOURCE.
+	* libU77/config.hin: Regenerated.
+	* libU77/configure: Regenerated.
+
 2003-01-27  Alexandre Oliva  <aoliva@redhat.com>
 
 	* Makefile.in ($(LIBG2C)): -rpath is glibcpp_toolexeclibdir.
@@ -75,12 +133,22 @@
 	version_specific_libs is enabled.
 	* configure: Rebuilt.
 
-2003-01-26  Christian Cornelssen  <ccorn@cs.tu-berlin.de>
+2003-01-09  Christian Cornelssen  <ccorn@cs.tu-berlin.de>
 
 	* Makefile.in (FLAGS_TO_PASS): Also pass DESTDIR.
 	(install, uninstall): Prepend $(DESTDIR) to destination
 	paths in all (un)installation commands.
 
+Wed Dec 18 11:33:35 2002  Jason Merrill  <jason@redhat.com>
+
+	* libU77/date_.c (G77_date_y2kbuggy_0): Declare G77_abort_0 noreturn.
+	* libU77/vxtidate_.c (G77_vxtidate_y2kbuggy_0): Likewise.
+
+2002-11-26  Nathanael Nerode  <neroden@gcc.gnu.org>
+
+	* configure.in: Remove skip-this-dir support.
+	* configure: Regenerate.
+
 2002-11-19  Toon Moene  <toon@moene.indiv.nluug.nl>
 
 	PR fortran/8587
diff -ur --exclude=CVS libf2c-3.3/configure.in libf2c/configure.in
--- libf2c-3.3/configure.in	2003-02-20 10:12:17.000000000 +0100
+++ libf2c/configure.in	2003-02-21 11:40:48.000000000 +0100
@@ -38,34 +38,6 @@
 GLIBCPP_CONFIGURE(.)
 GLIBCPP_EXPORT_INSTALL_INFO
 
-# If the language specific compiler does not exist, but the "gcc" directory 
-# does, we do not build anything. Note, $r is set by the top-level Makefile.
-# Note that when we look for the compiler, we search both with and without
-# extension to handle cross and canadian cross builds. 
-compiler_name=f771
-rm -f skip-this-dir
-AC_MSG_CHECKING(if compiler $compiler_name has been built)
-AC_CACHE_VAL(g77_cv_compiler_exists,
-[g77_cv_compiler_exists=yes
-if test -n "$r"; then
-  if test -d "$r"/gcc; then
-    if test -f "$r"/gcc/$compiler_name \
-       || test -f "$r"/gcc/$compiler_name.exe; then
-      true
-    else
-      g77_cv_compiler_exists=no
-      echo "rm -f config.cache config.log multilib.out" > skip-this-dir
-    fi
-  fi
-fi
-])
-AC_MSG_RESULT($g77_cv_compiler_exists)
-if test x$g77_cv_compiler_exists = xno
-then
-  rm -f Makefile conftest* confdefs* core
-  exit 0
-fi
-
 dnl Checks for programs.
 
 AM_PROG_LIBTOOL
diff -ur --exclude=CVS libf2c-3.3/libF77/configure.in libf2c/libF77/configure.in
--- libf2c-3.3/libF77/configure.in	2002-06-01 03:53:50.000000000 +0200
+++ libf2c/libF77/configure.in	2004-01-15 17:21:44.000000000 +0100
@@ -19,7 +19,7 @@
 #the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #02111-1307, USA.
 
-AC_PREREQ(2.12.1)
+AC_PREREQ(2.13)
 AC_INIT(getarg_.c)
 
 dnl Checks for programs.
diff -ur --exclude=CVS libf2c-3.3/libI77/config.h.in libf2c/libI77/config.h.in
--- libf2c-3.3/libI77/config.h.in	2004-03-30 20:57:02.000000000 +0200
+++ libf2c/libI77/config.h.in	2004-01-15 17:22:15.000000000 +0100
@@ -1,4 +1,4 @@
-/* config.h.in.  Generated automatically from configure.in by autoheader.  */
+/* config.h.in.  Generated automatically from configure.in by autoheader 2.13.  */
 
 /* Define to empty if the keyword does not work.  */
 #undef const
diff -ur --exclude=CVS libf2c-3.3/libI77/configure.in libf2c/libI77/configure.in
--- libf2c-3.3/libI77/configure.in	2003-04-24 03:58:04.000000000 +0200
+++ libf2c/libI77/configure.in	2004-01-15 17:21:45.000000000 +0100
@@ -19,7 +19,7 @@
 #the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #02111-1307, USA.
 
-AC_PREREQ(2.12.1)
+AC_PREREQ(2.13)
 AC_INIT(ftell_.c)
 AC_CONFIG_HEADER(config.h)
 
diff -ur --exclude=CVS libf2c-3.3/libI77/rsne.c libf2c/libI77/rsne.c
--- libf2c-3.3/libI77/rsne.c	2002-08-31 16:38:57.000000000 +0200
+++ libf2c/libI77/rsne.c	2004-02-01 09:16:48.000000000 +0100
@@ -278,6 +278,7 @@
   char *vaddr;
   long iva, ivae;
   dimen dimens[MAXDIM], substr;
+  int dollarsign_delimited;
 
   if (!Alpha['a'])
     nl_init ();
@@ -285,14 +286,16 @@
   f__formatted = 1;
   got1 = 0;
 top:
+  dollarsign_delimited = 0;
   for (;;)
     switch (GETC (ch))
       {
       case EOF:
       eof:
 	err (a->ciend, (EOF), where0);
-      case '&':
       case '$':
+        dollarsign_delimited = 1;
+      case '&':
 	goto have_amp;
 #ifndef No_Namelist_Questions
       case '?':
@@ -329,6 +332,8 @@
 	  case EOF:
 	    err (a->ciend, EOF, where0);
 	  case '/':
+            if (dollarsign_delimited)
+               continue;
 	  case '&':
 	  case '$':
 	    if (f__external)
diff -ur --exclude=CVS libf2c-3.3/libI77/wrtfmt.c libf2c/libI77/wrtfmt.c
--- libf2c-3.3/libI77/wrtfmt.c	2002-06-02 15:01:12.000000000 +0200
+++ libf2c/libI77/wrtfmt.c	2004-06-19 16:07:57.000000000 +0200
@@ -251,13 +251,19 @@
 wrt_L (Uint * n, int len, ftnlen sz)
 {
   int i;
-  long x;
-  if (sizeof (long) == sz)
-    x = n->il;
-  else if (sz == sizeof (char))
-    x = n->ic;
+  longint x;
+#ifdef Allow_TYQUAD
+  if (sizeof (longint) == sz)
+    x = n->ili;
   else
+#endif
+  if (sizeof (short ) == sz)
     x = n->is;
+  else if (sizeof (char) == sz)
+    x = n->ic;
+  else if (sizeof (integer) == sz)
+    x = n->il;
+
   for (i = 0; i < len - 1; i++)
     (*f__putn) (' ');
   if (x)
diff -ur --exclude=CVS libf2c-3.3/libU77/config.hin libf2c/libU77/config.hin
--- libf2c-3.3/libU77/config.hin	2002-06-01 03:53:53.000000000 +0200
+++ libf2c/libU77/config.hin	2003-06-13 11:29:59.000000000 +0200
@@ -1,4 +1,4 @@
-/* config.hin.  Generated automatically from configure.in by autoheader.  */
+/* config.hin.  Generated automatically from configure.in by autoheader 2.13.  */
 
 /* Define to empty if the keyword does not work.  */
 #undef const
@@ -123,3 +123,6 @@
 /* Get 64-bit file size support */
 #undef _FILE_OFFSET_BITS
 
+/* Get GNU extensions */
+#undef _GNU_SOURCE
+
diff -ur --exclude=CVS libf2c-3.3/libU77/configure.in libf2c/libU77/configure.in
--- libf2c-3.3/libU77/configure.in	2003-04-24 03:58:04.000000000 +0200
+++ libf2c/libU77/configure.in	2004-01-15 17:21:47.000000000 +0100
@@ -19,7 +19,7 @@
 #to Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307,
 #USA.
 
-AC_PREREQ(2.12.1)
+AC_PREREQ(2.13)
 AC_INIT(access_.c)
 AC_CONFIG_HEADER(config.h:config.hin)
 
@@ -47,6 +47,8 @@
   # The following is needed by Solaris2.5.1 so that struct timeval is declared.
   AC_DEFINE(__EXTENSIONS__, 1, [Solaris extensions])
   AC_DEFINE(_FILE_OFFSET_BITS, 64, [Get 64-bit file size support])
+  # The following is needed by glibc2 so that gethostname is declared.
+  AC_DEFINE(_GNU_SOURCE, 1, [Get GNU extensions])
 fi
 
 dnl Checks for programs.
diff -ur --exclude=CVS libf2c-3.3/libU77/date_.c libf2c/libU77/date_.c
--- libf2c-3.3/libU77/date_.c	2002-06-05 21:07:10.000000000 +0200
+++ libf2c/libU77/date_.c	2002-12-18 19:39:28.000000000 +0100
@@ -49,7 +49,7 @@
 G77_date_y2kbuggy_0 (char *buf __attribute__ ((__unused__)),
 		     ftnlen buf_len __attribute__ ((__unused__)))
 {
-  extern int G77_abort_0 ();
+  extern int G77_abort_0() __attribute__ ((noreturn));
   fprintf (stderr, "%s\n", G77_Non_Y2K_Compliance_Message);
   G77_abort_0 ();
 }
diff -ur --exclude=CVS libf2c-3.3/libU77/fnum_.c libf2c/libU77/fnum_.c
--- libf2c-3.3/libU77/fnum_.c	2002-06-01 14:38:32.000000000 +0200
+++ libf2c/libU77/fnum_.c	2003-09-22 10:01:40.000000000 +0200
@@ -27,6 +27,10 @@
 {
   if (*lunit >= MXUNIT || *lunit < 0)
     err (1, 101, "fnum");
+
+  if (f__units[*lunit].ufd == NULL)
+    err (1, 114, "fnum");
+
   /* f__units is a table of descriptions for the unit numbers (defined
      in io.h).  Use file descriptor (ufd) and fileno rather than udev
      field since udev is unix specific */
diff -ur --exclude=CVS libf2c-3.3/libU77/fstat_.c libf2c/libU77/fstat_.c
--- libf2c-3.3/libU77/fstat_.c	2002-06-01 14:38:32.000000000 +0200
+++ libf2c/libU77/fstat_.c	2003-09-22 10:01:40.000000000 +0200
@@ -23,6 +23,7 @@
 #include "config.h"
 #endif
 #include "f2c.h"
+#include "fio.h"
 #include <sys/types.h>
 #include <sys/stat.h>
 
@@ -34,6 +35,7 @@
   int err;
   struct stat buf;
 
+  if (f__init != 1) f_init();
   err = fstat (G77_fnum_0 (lunit), &buf);
   statb[0] = buf.st_dev;
   statb[1] = buf.st_ino;
diff -ur --exclude=CVS libf2c-3.3/libU77/isatty_.c libf2c/libU77/isatty_.c
--- libf2c-3.3/libU77/isatty_.c	2002-06-01 14:38:32.000000000 +0200
+++ libf2c/libU77/isatty_.c	2003-09-22 10:01:40.000000000 +0200
@@ -30,6 +30,7 @@
 logical
 G77_isatty_0 (integer * lunit)
 {
+  if (f__init != 1) f_init();
   if (*lunit >= MXUNIT || *lunit < 0)
     err (1, 101, "isatty");
   /* f__units is a table of descriptions for the unit numbers (defined
diff -ur --exclude=CVS libf2c-3.3/libU77/vxtidate_.c libf2c/libU77/vxtidate_.c
--- libf2c-3.3/libU77/vxtidate_.c	2002-06-05 21:07:11.000000000 +0200
+++ libf2c/libU77/vxtidate_.c	2002-12-18 19:39:28.000000000 +0100
@@ -58,7 +58,7 @@
 			 integer * d __attribute__ ((__unused__)),
 			 integer * y __attribute__ ((__unused__)))
 {
-  extern int G77_abort_0 ();
+  extern int G77_abort_0() __attribute__ ((noreturn));
   fprintf (stderr, "%s\n", G77_Non_Y2K_Compliance_Message);
   G77_abort_0 ();
 }
