OSDN Git Service

2004-12-02 Bud Davis <bdavis9659@comcast.net>
[pf3gnuchains/gcc-fork.git] / libgfortran / io / endfile.c
1 /* Copyright (C) 2002-2003 Free Software Foundation, Inc.
2    Contributed by Andy Vaught
3
4 This file is part of the GNU Fortran 95 runtime library (libgfortran).
5
6 Libgfortran is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 Libgfortran is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Libgfortran; see the file COPYING.  If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.  */
20
21 #include "config.h"
22 #include "libgfortran.h"
23 #include "io.h"
24
25 /* endfile.c--  Implement the ENDFILE statement */
26
27 void
28 st_endfile (void)
29 {
30   gfc_unit *u;
31
32   library_start ();
33
34   u = get_unit (0);
35   if (u != NULL)
36     {
37       current_unit = u;         /* next_record() needs this set */
38       if (u->current_record)
39         next_record (1);
40
41       flush(u->s);
42       struncate (u->s);
43       u->endfile = AFTER_ENDFILE;
44     }
45
46   library_end ();
47 }