OSDN Git Service

Remove DOS line endings.
[pf3gnuchains/gcc-fork.git] / libgfortran / intrinsics / flush.c
index 40335f9..2164b47 100644 (file)
@@ -1,5 +1,5 @@
 /* Implementation of the FLUSH intrinsic.
-   Copyright (C) 2004 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005 Free Software Foundation, Inc.
    Contributed by Steven G. Kargl <kargls@comcast.net>.
 
 This file is part of the GNU Fortran 95 runtime library (libgfortran).
@@ -25,8 +25,8 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public
 License along with libgfortran; see the file COPYING.  If not,
-write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
+write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.  */
 
 
 #include "config.h"
@@ -41,19 +41,6 @@ Boston, MA 02111-1307, USA.  */
 /* SUBROUTINE FLUSH(UNIT)
    INTEGER, INTENT(IN), OPTIONAL :: UNIT  */
 
-static void
-recursive_flush (gfc_unit *us)
-{
-  /* There can be no open files.  */
-  if (us == NULL)
-    return;
-
-  flush (us->s);
-  recursive_flush (us->left);
-  recursive_flush (us->right);
-}
-
-
 extern void flush_i4 (GFC_INTEGER_4 *);
 export_proto(flush_i4);
 
@@ -64,14 +51,37 @@ flush_i4 (GFC_INTEGER_4 *unit)
 
   /* flush all streams */
   if (unit == NULL)
+    flush_all_units ();
+  else
     {
-      us = g.unit_root;
-      recursive_flush(us);
+      us = find_unit (*unit);
+      if (us != NULL)
+       {
+         flush (us->s);
+         unlock_unit (us);
+       }
     }
+}
+
+
+extern void flush_i8 (GFC_INTEGER_8 *);
+export_proto(flush_i8);
+
+void
+flush_i8 (GFC_INTEGER_8 *unit)
+{
+  gfc_unit *us;
+
+  /* flush all streams */
+  if (unit == NULL)
+    flush_all_units ();
   else
     {
-      us = find_unit(*unit);
+      us = find_unit (*unit);
       if (us != NULL)
-        flush (us->s);
+       {
+         flush (us->s);
+         unlock_unit (us);
+       }
     }
 }