/* 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).
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"
/* 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);
/* 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);
+ }
}
}