Merge from mainline (gomp-merge-2005-02-26).
[official-gcc.git] / libgfortran / io / endfile.c
blob8d01ea1076b019a3d2df41bb0f2866277a6b610e
1 /* Copyright (C) 2002-2003 Free Software Foundation, Inc.
2 Contributed by Andy Vaught
4 This file is part of the GNU Fortran 95 runtime library (libgfortran).
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.
11 In addition to the permissions in the GNU General Public License, the
12 Free Software Foundation gives you unlimited permission to link the
13 compiled version of this file into combinations with other programs,
14 and to distribute those combinations without any restriction coming
15 from the use of this file. (The General Public License restrictions
16 do apply in other respects; for example, they cover modification of
17 the file, and distribution when not linked into a combine
18 executable.)
20 Libgfortran is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
25 You should have received a copy of the GNU General Public License
26 along with Libgfortran; see the file COPYING. If not, write to
27 the Free Software Foundation, 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. */
30 #include "config.h"
31 #include "libgfortran.h"
32 #include "io.h"
34 /* endfile.c-- Implement the ENDFILE statement */
36 extern void st_endfile (void);
37 export_proto(st_endfile);
39 void
40 st_endfile (void)
42 gfc_unit *u;
44 library_start ();
46 u = get_unit (0);
47 if (u != NULL)
49 current_unit = u; /* next_record() needs this set */
50 if (u->current_record)
51 next_record (1);
53 flush(u->s);
54 struncate (u->s);
55 u->endfile = AFTER_ENDFILE;
58 library_end ();