2005-05-17 18:54:58 +02:00
|
|
|
/* Copyright (C) 2002, 2003, 2004, 2005
|
|
|
|
Free Software Foundation, Inc.
|
2004-05-13 08:41:07 +02:00
|
|
|
Contributed by Andy Vaught
|
|
|
|
|
|
|
|
This file is part of the GNU Fortran 95 runtime library (libgfortran).
|
|
|
|
|
|
|
|
Libgfortran is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
any later version.
|
|
|
|
|
2005-01-12 22:27:33 +01:00
|
|
|
In addition to the permissions in the GNU General Public License, the
|
|
|
|
Free Software Foundation gives you unlimited permission to link the
|
|
|
|
compiled version of this file into combinations with other programs,
|
|
|
|
and to distribute those combinations without any restriction coming
|
|
|
|
from the use of this file. (The General Public License restrictions
|
|
|
|
do apply in other respects; for example, they cover modification of
|
|
|
|
the file, and distribution when not linked into a combine
|
|
|
|
executable.)
|
|
|
|
|
2004-05-13 08:41:07 +02:00
|
|
|
Libgfortran is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
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, 59 Temple Place - Suite 330,
|
|
|
|
Boston, MA 02111-1307, USA. */
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "libgfortran.h"
|
|
|
|
#include "io.h"
|
|
|
|
|
|
|
|
|
|
|
|
static st_option access_opt[] = {
|
|
|
|
{"sequential", ACCESS_SEQUENTIAL},
|
|
|
|
{"direct", ACCESS_DIRECT},
|
2005-05-17 18:54:58 +02:00
|
|
|
{NULL, 0}
|
c99_functions.c, [...]: Whitespace fixes.
* intrinsics/c99_functions.c, intrinsics/eoshift0.c,
intrinsics/eoshift2.c, intrinsics/exit.c, intrinsics/flush.c,
intrinsics/ishftc.c, intrinsics/mvbits.c, intrinsics/pack_generic.c,
intrinsics/random.c, intrinsics/reshape_generic.c, intrinsics/size.c,
intrinsics/spread_generic.c, intrinsics/stat.c,
intrinsics/string_intrinsics.c, intrinsics/system_clock.c,
intrinsics/transpose_generic.c, intrinsics/unlink.c,
intrinsics/unpack_generic.c, io/backspace.c, io/format.c,
io/list_read.c, io/lock.c, io/open.c, io/transfer.c, io/unix.c,
io/write.c, runtime/environ.c, runtime/error.c,
runtime/in_pack_generic.c, runtime/in_unpack_generic.c, runtime/main.c,
runtime/memory.c, runtime/pause.c, runtime/stop.c,
runtime/string.c: Whitespace fixes.
From-SVN: r91794
2004-12-07 01:01:01 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static st_option action_opt[] =
|
2004-05-13 08:41:07 +02:00
|
|
|
{
|
c99_functions.c, [...]: Whitespace fixes.
* intrinsics/c99_functions.c, intrinsics/eoshift0.c,
intrinsics/eoshift2.c, intrinsics/exit.c, intrinsics/flush.c,
intrinsics/ishftc.c, intrinsics/mvbits.c, intrinsics/pack_generic.c,
intrinsics/random.c, intrinsics/reshape_generic.c, intrinsics/size.c,
intrinsics/spread_generic.c, intrinsics/stat.c,
intrinsics/string_intrinsics.c, intrinsics/system_clock.c,
intrinsics/transpose_generic.c, intrinsics/unlink.c,
intrinsics/unpack_generic.c, io/backspace.c, io/format.c,
io/list_read.c, io/lock.c, io/open.c, io/transfer.c, io/unix.c,
io/write.c, runtime/environ.c, runtime/error.c,
runtime/in_pack_generic.c, runtime/in_unpack_generic.c, runtime/main.c,
runtime/memory.c, runtime/pause.c, runtime/stop.c,
runtime/string.c: Whitespace fixes.
From-SVN: r91794
2004-12-07 01:01:01 +01:00
|
|
|
{ "read", ACTION_READ},
|
|
|
|
{ "write", ACTION_WRITE},
|
|
|
|
{ "readwrite", ACTION_READWRITE},
|
2005-05-17 18:54:58 +02:00
|
|
|
{ NULL, 0}
|
c99_functions.c, [...]: Whitespace fixes.
* intrinsics/c99_functions.c, intrinsics/eoshift0.c,
intrinsics/eoshift2.c, intrinsics/exit.c, intrinsics/flush.c,
intrinsics/ishftc.c, intrinsics/mvbits.c, intrinsics/pack_generic.c,
intrinsics/random.c, intrinsics/reshape_generic.c, intrinsics/size.c,
intrinsics/spread_generic.c, intrinsics/stat.c,
intrinsics/string_intrinsics.c, intrinsics/system_clock.c,
intrinsics/transpose_generic.c, intrinsics/unlink.c,
intrinsics/unpack_generic.c, io/backspace.c, io/format.c,
io/list_read.c, io/lock.c, io/open.c, io/transfer.c, io/unix.c,
io/write.c, runtime/environ.c, runtime/error.c,
runtime/in_pack_generic.c, runtime/in_unpack_generic.c, runtime/main.c,
runtime/memory.c, runtime/pause.c, runtime/stop.c,
runtime/string.c: Whitespace fixes.
From-SVN: r91794
2004-12-07 01:01:01 +01:00
|
|
|
};
|
2004-05-13 08:41:07 +02:00
|
|
|
|
c99_functions.c, [...]: Whitespace fixes.
* intrinsics/c99_functions.c, intrinsics/eoshift0.c,
intrinsics/eoshift2.c, intrinsics/exit.c, intrinsics/flush.c,
intrinsics/ishftc.c, intrinsics/mvbits.c, intrinsics/pack_generic.c,
intrinsics/random.c, intrinsics/reshape_generic.c, intrinsics/size.c,
intrinsics/spread_generic.c, intrinsics/stat.c,
intrinsics/string_intrinsics.c, intrinsics/system_clock.c,
intrinsics/transpose_generic.c, intrinsics/unlink.c,
intrinsics/unpack_generic.c, io/backspace.c, io/format.c,
io/list_read.c, io/lock.c, io/open.c, io/transfer.c, io/unix.c,
io/write.c, runtime/environ.c, runtime/error.c,
runtime/in_pack_generic.c, runtime/in_unpack_generic.c, runtime/main.c,
runtime/memory.c, runtime/pause.c, runtime/stop.c,
runtime/string.c: Whitespace fixes.
From-SVN: r91794
2004-12-07 01:01:01 +01:00
|
|
|
static st_option blank_opt[] =
|
2004-05-13 08:41:07 +02:00
|
|
|
{
|
c99_functions.c, [...]: Whitespace fixes.
* intrinsics/c99_functions.c, intrinsics/eoshift0.c,
intrinsics/eoshift2.c, intrinsics/exit.c, intrinsics/flush.c,
intrinsics/ishftc.c, intrinsics/mvbits.c, intrinsics/pack_generic.c,
intrinsics/random.c, intrinsics/reshape_generic.c, intrinsics/size.c,
intrinsics/spread_generic.c, intrinsics/stat.c,
intrinsics/string_intrinsics.c, intrinsics/system_clock.c,
intrinsics/transpose_generic.c, intrinsics/unlink.c,
intrinsics/unpack_generic.c, io/backspace.c, io/format.c,
io/list_read.c, io/lock.c, io/open.c, io/transfer.c, io/unix.c,
io/write.c, runtime/environ.c, runtime/error.c,
runtime/in_pack_generic.c, runtime/in_unpack_generic.c, runtime/main.c,
runtime/memory.c, runtime/pause.c, runtime/stop.c,
runtime/string.c: Whitespace fixes.
From-SVN: r91794
2004-12-07 01:01:01 +01:00
|
|
|
{ "null", BLANK_NULL},
|
|
|
|
{ "zero", BLANK_ZERO},
|
2005-05-17 18:54:58 +02:00
|
|
|
{ NULL, 0}
|
c99_functions.c, [...]: Whitespace fixes.
* intrinsics/c99_functions.c, intrinsics/eoshift0.c,
intrinsics/eoshift2.c, intrinsics/exit.c, intrinsics/flush.c,
intrinsics/ishftc.c, intrinsics/mvbits.c, intrinsics/pack_generic.c,
intrinsics/random.c, intrinsics/reshape_generic.c, intrinsics/size.c,
intrinsics/spread_generic.c, intrinsics/stat.c,
intrinsics/string_intrinsics.c, intrinsics/system_clock.c,
intrinsics/transpose_generic.c, intrinsics/unlink.c,
intrinsics/unpack_generic.c, io/backspace.c, io/format.c,
io/list_read.c, io/lock.c, io/open.c, io/transfer.c, io/unix.c,
io/write.c, runtime/environ.c, runtime/error.c,
runtime/in_pack_generic.c, runtime/in_unpack_generic.c, runtime/main.c,
runtime/memory.c, runtime/pause.c, runtime/stop.c,
runtime/string.c: Whitespace fixes.
From-SVN: r91794
2004-12-07 01:01:01 +01:00
|
|
|
};
|
2004-05-13 08:41:07 +02:00
|
|
|
|
c99_functions.c, [...]: Whitespace fixes.
* intrinsics/c99_functions.c, intrinsics/eoshift0.c,
intrinsics/eoshift2.c, intrinsics/exit.c, intrinsics/flush.c,
intrinsics/ishftc.c, intrinsics/mvbits.c, intrinsics/pack_generic.c,
intrinsics/random.c, intrinsics/reshape_generic.c, intrinsics/size.c,
intrinsics/spread_generic.c, intrinsics/stat.c,
intrinsics/string_intrinsics.c, intrinsics/system_clock.c,
intrinsics/transpose_generic.c, intrinsics/unlink.c,
intrinsics/unpack_generic.c, io/backspace.c, io/format.c,
io/list_read.c, io/lock.c, io/open.c, io/transfer.c, io/unix.c,
io/write.c, runtime/environ.c, runtime/error.c,
runtime/in_pack_generic.c, runtime/in_unpack_generic.c, runtime/main.c,
runtime/memory.c, runtime/pause.c, runtime/stop.c,
runtime/string.c: Whitespace fixes.
From-SVN: r91794
2004-12-07 01:01:01 +01:00
|
|
|
static st_option delim_opt[] =
|
2004-05-13 08:41:07 +02:00
|
|
|
{
|
c99_functions.c, [...]: Whitespace fixes.
* intrinsics/c99_functions.c, intrinsics/eoshift0.c,
intrinsics/eoshift2.c, intrinsics/exit.c, intrinsics/flush.c,
intrinsics/ishftc.c, intrinsics/mvbits.c, intrinsics/pack_generic.c,
intrinsics/random.c, intrinsics/reshape_generic.c, intrinsics/size.c,
intrinsics/spread_generic.c, intrinsics/stat.c,
intrinsics/string_intrinsics.c, intrinsics/system_clock.c,
intrinsics/transpose_generic.c, intrinsics/unlink.c,
intrinsics/unpack_generic.c, io/backspace.c, io/format.c,
io/list_read.c, io/lock.c, io/open.c, io/transfer.c, io/unix.c,
io/write.c, runtime/environ.c, runtime/error.c,
runtime/in_pack_generic.c, runtime/in_unpack_generic.c, runtime/main.c,
runtime/memory.c, runtime/pause.c, runtime/stop.c,
runtime/string.c: Whitespace fixes.
From-SVN: r91794
2004-12-07 01:01:01 +01:00
|
|
|
{ "none", DELIM_NONE},
|
|
|
|
{ "apostrophe", DELIM_APOSTROPHE},
|
|
|
|
{ "quote", DELIM_QUOTE},
|
2005-05-17 18:54:58 +02:00
|
|
|
{ NULL, 0}
|
c99_functions.c, [...]: Whitespace fixes.
* intrinsics/c99_functions.c, intrinsics/eoshift0.c,
intrinsics/eoshift2.c, intrinsics/exit.c, intrinsics/flush.c,
intrinsics/ishftc.c, intrinsics/mvbits.c, intrinsics/pack_generic.c,
intrinsics/random.c, intrinsics/reshape_generic.c, intrinsics/size.c,
intrinsics/spread_generic.c, intrinsics/stat.c,
intrinsics/string_intrinsics.c, intrinsics/system_clock.c,
intrinsics/transpose_generic.c, intrinsics/unlink.c,
intrinsics/unpack_generic.c, io/backspace.c, io/format.c,
io/list_read.c, io/lock.c, io/open.c, io/transfer.c, io/unix.c,
io/write.c, runtime/environ.c, runtime/error.c,
runtime/in_pack_generic.c, runtime/in_unpack_generic.c, runtime/main.c,
runtime/memory.c, runtime/pause.c, runtime/stop.c,
runtime/string.c: Whitespace fixes.
From-SVN: r91794
2004-12-07 01:01:01 +01:00
|
|
|
};
|
2004-05-13 08:41:07 +02:00
|
|
|
|
c99_functions.c, [...]: Whitespace fixes.
* intrinsics/c99_functions.c, intrinsics/eoshift0.c,
intrinsics/eoshift2.c, intrinsics/exit.c, intrinsics/flush.c,
intrinsics/ishftc.c, intrinsics/mvbits.c, intrinsics/pack_generic.c,
intrinsics/random.c, intrinsics/reshape_generic.c, intrinsics/size.c,
intrinsics/spread_generic.c, intrinsics/stat.c,
intrinsics/string_intrinsics.c, intrinsics/system_clock.c,
intrinsics/transpose_generic.c, intrinsics/unlink.c,
intrinsics/unpack_generic.c, io/backspace.c, io/format.c,
io/list_read.c, io/lock.c, io/open.c, io/transfer.c, io/unix.c,
io/write.c, runtime/environ.c, runtime/error.c,
runtime/in_pack_generic.c, runtime/in_unpack_generic.c, runtime/main.c,
runtime/memory.c, runtime/pause.c, runtime/stop.c,
runtime/string.c: Whitespace fixes.
From-SVN: r91794
2004-12-07 01:01:01 +01:00
|
|
|
static st_option form_opt[] =
|
2004-05-13 08:41:07 +02:00
|
|
|
{
|
c99_functions.c, [...]: Whitespace fixes.
* intrinsics/c99_functions.c, intrinsics/eoshift0.c,
intrinsics/eoshift2.c, intrinsics/exit.c, intrinsics/flush.c,
intrinsics/ishftc.c, intrinsics/mvbits.c, intrinsics/pack_generic.c,
intrinsics/random.c, intrinsics/reshape_generic.c, intrinsics/size.c,
intrinsics/spread_generic.c, intrinsics/stat.c,
intrinsics/string_intrinsics.c, intrinsics/system_clock.c,
intrinsics/transpose_generic.c, intrinsics/unlink.c,
intrinsics/unpack_generic.c, io/backspace.c, io/format.c,
io/list_read.c, io/lock.c, io/open.c, io/transfer.c, io/unix.c,
io/write.c, runtime/environ.c, runtime/error.c,
runtime/in_pack_generic.c, runtime/in_unpack_generic.c, runtime/main.c,
runtime/memory.c, runtime/pause.c, runtime/stop.c,
runtime/string.c: Whitespace fixes.
From-SVN: r91794
2004-12-07 01:01:01 +01:00
|
|
|
{ "formatted", FORM_FORMATTED},
|
|
|
|
{ "unformatted", FORM_UNFORMATTED},
|
2005-05-17 18:54:58 +02:00
|
|
|
{ NULL, 0}
|
c99_functions.c, [...]: Whitespace fixes.
* intrinsics/c99_functions.c, intrinsics/eoshift0.c,
intrinsics/eoshift2.c, intrinsics/exit.c, intrinsics/flush.c,
intrinsics/ishftc.c, intrinsics/mvbits.c, intrinsics/pack_generic.c,
intrinsics/random.c, intrinsics/reshape_generic.c, intrinsics/size.c,
intrinsics/spread_generic.c, intrinsics/stat.c,
intrinsics/string_intrinsics.c, intrinsics/system_clock.c,
intrinsics/transpose_generic.c, intrinsics/unlink.c,
intrinsics/unpack_generic.c, io/backspace.c, io/format.c,
io/list_read.c, io/lock.c, io/open.c, io/transfer.c, io/unix.c,
io/write.c, runtime/environ.c, runtime/error.c,
runtime/in_pack_generic.c, runtime/in_unpack_generic.c, runtime/main.c,
runtime/memory.c, runtime/pause.c, runtime/stop.c,
runtime/string.c: Whitespace fixes.
From-SVN: r91794
2004-12-07 01:01:01 +01:00
|
|
|
};
|
2004-05-13 08:41:07 +02:00
|
|
|
|
c99_functions.c, [...]: Whitespace fixes.
* intrinsics/c99_functions.c, intrinsics/eoshift0.c,
intrinsics/eoshift2.c, intrinsics/exit.c, intrinsics/flush.c,
intrinsics/ishftc.c, intrinsics/mvbits.c, intrinsics/pack_generic.c,
intrinsics/random.c, intrinsics/reshape_generic.c, intrinsics/size.c,
intrinsics/spread_generic.c, intrinsics/stat.c,
intrinsics/string_intrinsics.c, intrinsics/system_clock.c,
intrinsics/transpose_generic.c, intrinsics/unlink.c,
intrinsics/unpack_generic.c, io/backspace.c, io/format.c,
io/list_read.c, io/lock.c, io/open.c, io/transfer.c, io/unix.c,
io/write.c, runtime/environ.c, runtime/error.c,
runtime/in_pack_generic.c, runtime/in_unpack_generic.c, runtime/main.c,
runtime/memory.c, runtime/pause.c, runtime/stop.c,
runtime/string.c: Whitespace fixes.
From-SVN: r91794
2004-12-07 01:01:01 +01:00
|
|
|
static st_option position_opt[] =
|
2004-05-13 08:41:07 +02:00
|
|
|
{
|
c99_functions.c, [...]: Whitespace fixes.
* intrinsics/c99_functions.c, intrinsics/eoshift0.c,
intrinsics/eoshift2.c, intrinsics/exit.c, intrinsics/flush.c,
intrinsics/ishftc.c, intrinsics/mvbits.c, intrinsics/pack_generic.c,
intrinsics/random.c, intrinsics/reshape_generic.c, intrinsics/size.c,
intrinsics/spread_generic.c, intrinsics/stat.c,
intrinsics/string_intrinsics.c, intrinsics/system_clock.c,
intrinsics/transpose_generic.c, intrinsics/unlink.c,
intrinsics/unpack_generic.c, io/backspace.c, io/format.c,
io/list_read.c, io/lock.c, io/open.c, io/transfer.c, io/unix.c,
io/write.c, runtime/environ.c, runtime/error.c,
runtime/in_pack_generic.c, runtime/in_unpack_generic.c, runtime/main.c,
runtime/memory.c, runtime/pause.c, runtime/stop.c,
runtime/string.c: Whitespace fixes.
From-SVN: r91794
2004-12-07 01:01:01 +01:00
|
|
|
{ "asis", POSITION_ASIS},
|
|
|
|
{ "rewind", POSITION_REWIND},
|
|
|
|
{ "append", POSITION_APPEND},
|
2005-05-17 18:54:58 +02:00
|
|
|
{ NULL, 0}
|
c99_functions.c, [...]: Whitespace fixes.
* intrinsics/c99_functions.c, intrinsics/eoshift0.c,
intrinsics/eoshift2.c, intrinsics/exit.c, intrinsics/flush.c,
intrinsics/ishftc.c, intrinsics/mvbits.c, intrinsics/pack_generic.c,
intrinsics/random.c, intrinsics/reshape_generic.c, intrinsics/size.c,
intrinsics/spread_generic.c, intrinsics/stat.c,
intrinsics/string_intrinsics.c, intrinsics/system_clock.c,
intrinsics/transpose_generic.c, intrinsics/unlink.c,
intrinsics/unpack_generic.c, io/backspace.c, io/format.c,
io/list_read.c, io/lock.c, io/open.c, io/transfer.c, io/unix.c,
io/write.c, runtime/environ.c, runtime/error.c,
runtime/in_pack_generic.c, runtime/in_unpack_generic.c, runtime/main.c,
runtime/memory.c, runtime/pause.c, runtime/stop.c,
runtime/string.c: Whitespace fixes.
From-SVN: r91794
2004-12-07 01:01:01 +01:00
|
|
|
};
|
2004-05-13 08:41:07 +02:00
|
|
|
|
c99_functions.c, [...]: Whitespace fixes.
* intrinsics/c99_functions.c, intrinsics/eoshift0.c,
intrinsics/eoshift2.c, intrinsics/exit.c, intrinsics/flush.c,
intrinsics/ishftc.c, intrinsics/mvbits.c, intrinsics/pack_generic.c,
intrinsics/random.c, intrinsics/reshape_generic.c, intrinsics/size.c,
intrinsics/spread_generic.c, intrinsics/stat.c,
intrinsics/string_intrinsics.c, intrinsics/system_clock.c,
intrinsics/transpose_generic.c, intrinsics/unlink.c,
intrinsics/unpack_generic.c, io/backspace.c, io/format.c,
io/list_read.c, io/lock.c, io/open.c, io/transfer.c, io/unix.c,
io/write.c, runtime/environ.c, runtime/error.c,
runtime/in_pack_generic.c, runtime/in_unpack_generic.c, runtime/main.c,
runtime/memory.c, runtime/pause.c, runtime/stop.c,
runtime/string.c: Whitespace fixes.
From-SVN: r91794
2004-12-07 01:01:01 +01:00
|
|
|
static st_option status_opt[] =
|
2004-05-13 08:41:07 +02:00
|
|
|
{
|
c99_functions.c, [...]: Whitespace fixes.
* intrinsics/c99_functions.c, intrinsics/eoshift0.c,
intrinsics/eoshift2.c, intrinsics/exit.c, intrinsics/flush.c,
intrinsics/ishftc.c, intrinsics/mvbits.c, intrinsics/pack_generic.c,
intrinsics/random.c, intrinsics/reshape_generic.c, intrinsics/size.c,
intrinsics/spread_generic.c, intrinsics/stat.c,
intrinsics/string_intrinsics.c, intrinsics/system_clock.c,
intrinsics/transpose_generic.c, intrinsics/unlink.c,
intrinsics/unpack_generic.c, io/backspace.c, io/format.c,
io/list_read.c, io/lock.c, io/open.c, io/transfer.c, io/unix.c,
io/write.c, runtime/environ.c, runtime/error.c,
runtime/in_pack_generic.c, runtime/in_unpack_generic.c, runtime/main.c,
runtime/memory.c, runtime/pause.c, runtime/stop.c,
runtime/string.c: Whitespace fixes.
From-SVN: r91794
2004-12-07 01:01:01 +01:00
|
|
|
{ "unknown", STATUS_UNKNOWN},
|
|
|
|
{ "old", STATUS_OLD},
|
|
|
|
{ "new", STATUS_NEW},
|
|
|
|
{ "replace", STATUS_REPLACE},
|
|
|
|
{ "scratch", STATUS_SCRATCH},
|
2005-05-17 18:54:58 +02:00
|
|
|
{ NULL, 0}
|
c99_functions.c, [...]: Whitespace fixes.
* intrinsics/c99_functions.c, intrinsics/eoshift0.c,
intrinsics/eoshift2.c, intrinsics/exit.c, intrinsics/flush.c,
intrinsics/ishftc.c, intrinsics/mvbits.c, intrinsics/pack_generic.c,
intrinsics/random.c, intrinsics/reshape_generic.c, intrinsics/size.c,
intrinsics/spread_generic.c, intrinsics/stat.c,
intrinsics/string_intrinsics.c, intrinsics/system_clock.c,
intrinsics/transpose_generic.c, intrinsics/unlink.c,
intrinsics/unpack_generic.c, io/backspace.c, io/format.c,
io/list_read.c, io/lock.c, io/open.c, io/transfer.c, io/unix.c,
io/write.c, runtime/environ.c, runtime/error.c,
runtime/in_pack_generic.c, runtime/in_unpack_generic.c, runtime/main.c,
runtime/memory.c, runtime/pause.c, runtime/stop.c,
runtime/string.c: Whitespace fixes.
From-SVN: r91794
2004-12-07 01:01:01 +01:00
|
|
|
};
|
2004-05-13 08:41:07 +02:00
|
|
|
|
c99_functions.c, [...]: Whitespace fixes.
* intrinsics/c99_functions.c, intrinsics/eoshift0.c,
intrinsics/eoshift2.c, intrinsics/exit.c, intrinsics/flush.c,
intrinsics/ishftc.c, intrinsics/mvbits.c, intrinsics/pack_generic.c,
intrinsics/random.c, intrinsics/reshape_generic.c, intrinsics/size.c,
intrinsics/spread_generic.c, intrinsics/stat.c,
intrinsics/string_intrinsics.c, intrinsics/system_clock.c,
intrinsics/transpose_generic.c, intrinsics/unlink.c,
intrinsics/unpack_generic.c, io/backspace.c, io/format.c,
io/list_read.c, io/lock.c, io/open.c, io/transfer.c, io/unix.c,
io/write.c, runtime/environ.c, runtime/error.c,
runtime/in_pack_generic.c, runtime/in_unpack_generic.c, runtime/main.c,
runtime/memory.c, runtime/pause.c, runtime/stop.c,
runtime/string.c: Whitespace fixes.
From-SVN: r91794
2004-12-07 01:01:01 +01:00
|
|
|
static st_option pad_opt[] =
|
2004-05-13 08:41:07 +02:00
|
|
|
{
|
c99_functions.c, [...]: Whitespace fixes.
* intrinsics/c99_functions.c, intrinsics/eoshift0.c,
intrinsics/eoshift2.c, intrinsics/exit.c, intrinsics/flush.c,
intrinsics/ishftc.c, intrinsics/mvbits.c, intrinsics/pack_generic.c,
intrinsics/random.c, intrinsics/reshape_generic.c, intrinsics/size.c,
intrinsics/spread_generic.c, intrinsics/stat.c,
intrinsics/string_intrinsics.c, intrinsics/system_clock.c,
intrinsics/transpose_generic.c, intrinsics/unlink.c,
intrinsics/unpack_generic.c, io/backspace.c, io/format.c,
io/list_read.c, io/lock.c, io/open.c, io/transfer.c, io/unix.c,
io/write.c, runtime/environ.c, runtime/error.c,
runtime/in_pack_generic.c, runtime/in_unpack_generic.c, runtime/main.c,
runtime/memory.c, runtime/pause.c, runtime/stop.c,
runtime/string.c: Whitespace fixes.
From-SVN: r91794
2004-12-07 01:01:01 +01:00
|
|
|
{ "yes", PAD_YES},
|
|
|
|
{ "no", PAD_NO},
|
2005-05-17 18:54:58 +02:00
|
|
|
{ NULL, 0}
|
2004-05-13 08:41:07 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Given a unit, test to see if the file is positioned at the terminal
|
|
|
|
point, and if so, change state from NO_ENDFILE flag to AT_ENDFILE.
|
|
|
|
This prevents us from changing the state from AFTER_ENDFILE to
|
|
|
|
AT_ENDFILE. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
void
|
re PR libfortran/15234 (libgfortran doesn't compile on Tru64 UNIX V4.0F)
PR fortran/15234
* io/io.h (unit_t): Rename to ...
(gfc_unit) ... this.
(unit_root, current_unit, find_file, find_unit, get_unit): Now
of type gfc_unit.
(delete_file, insert_unit, close_unit): Argument now of type
gfc_unit.
* backspace.c (st_backspace), close.c (st_close), endfile.c
(st_endfile), inquire.c (inquire_via_unit, st_inquire), open.c
(test_endfile, edit_modes, new_unit, already_open, st_open),
rewind.c (st_rewind), transfer.c (current_unit), unit.c
(internal_unit, unit_cache, rotate_left, rotate_right, insert,
insert_unit, delete_root, delete_treap, delete_unit, find_unit,
get_unit, init_units, close_unit), unix.c (find_file0,
find_file, delete_file): Replace all occurences of unit_t by
gfc_unit.
From-SVN: r81903
2004-05-15 22:44:38 +02:00
|
|
|
test_endfile (gfc_unit * u)
|
2004-05-13 08:41:07 +02:00
|
|
|
{
|
|
|
|
if (u->endfile == NO_ENDFILE && file_length (u->s) == file_position (u->s))
|
|
|
|
u->endfile = AT_ENDFILE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Change the modes of a file, those that are allowed * to be
|
|
|
|
changed. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
static void
|
re PR libfortran/15234 (libgfortran doesn't compile on Tru64 UNIX V4.0F)
PR fortran/15234
* io/io.h (unit_t): Rename to ...
(gfc_unit) ... this.
(unit_root, current_unit, find_file, find_unit, get_unit): Now
of type gfc_unit.
(delete_file, insert_unit, close_unit): Argument now of type
gfc_unit.
* backspace.c (st_backspace), close.c (st_close), endfile.c
(st_endfile), inquire.c (inquire_via_unit, st_inquire), open.c
(test_endfile, edit_modes, new_unit, already_open, st_open),
rewind.c (st_rewind), transfer.c (current_unit), unit.c
(internal_unit, unit_cache, rotate_left, rotate_right, insert,
insert_unit, delete_root, delete_treap, delete_unit, find_unit,
get_unit, init_units, close_unit), unix.c (find_file0,
find_file, delete_file): Replace all occurences of unit_t by
gfc_unit.
From-SVN: r81903
2004-05-15 22:44:38 +02:00
|
|
|
edit_modes (gfc_unit * u, unit_flags * flags)
|
2004-05-13 08:41:07 +02:00
|
|
|
{
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Complain about attempts to change the unchangeable. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
if (flags->status != STATUS_UNSPECIFIED &&
|
|
|
|
u->flags.status != flags->position)
|
|
|
|
generate_error (ERROR_BAD_OPTION,
|
|
|
|
"Cannot change STATUS parameter in OPEN statement");
|
|
|
|
|
|
|
|
if (flags->access != ACCESS_UNSPECIFIED && u->flags.access != flags->access)
|
|
|
|
generate_error (ERROR_BAD_OPTION,
|
|
|
|
"Cannot change ACCESS parameter in OPEN statement");
|
|
|
|
|
|
|
|
if (flags->form != FORM_UNSPECIFIED && u->flags.form != flags->form)
|
|
|
|
generate_error (ERROR_BAD_OPTION,
|
|
|
|
"Cannot change FORM parameter in OPEN statement");
|
|
|
|
|
|
|
|
if (ioparm.recl_in != 0 && ioparm.recl_in != u->recl)
|
|
|
|
generate_error (ERROR_BAD_OPTION,
|
|
|
|
"Cannot change RECL parameter in OPEN statement");
|
|
|
|
|
|
|
|
if (flags->action != ACTION_UNSPECIFIED && u->flags.access != flags->access)
|
|
|
|
generate_error (ERROR_BAD_OPTION,
|
|
|
|
"Cannot change ACTION parameter in OPEN statement");
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Status must be OLD if present. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
if (flags->status != STATUS_UNSPECIFIED && flags->status != STATUS_OLD)
|
|
|
|
generate_error (ERROR_BAD_OPTION,
|
|
|
|
"OPEN statement must have a STATUS of OLD");
|
|
|
|
|
|
|
|
if (u->flags.form == FORM_UNFORMATTED)
|
|
|
|
{
|
|
|
|
if (flags->delim != DELIM_UNSPECIFIED)
|
|
|
|
generate_error (ERROR_OPTION_CONFLICT,
|
|
|
|
"DELIM parameter conflicts with UNFORMATTED form in "
|
|
|
|
"OPEN statement");
|
|
|
|
|
|
|
|
if (flags->blank != BLANK_UNSPECIFIED)
|
|
|
|
generate_error (ERROR_OPTION_CONFLICT,
|
|
|
|
"BLANK parameter conflicts with UNFORMATTED form in "
|
|
|
|
"OPEN statement");
|
|
|
|
|
|
|
|
if (flags->pad != PAD_UNSPECIFIED)
|
|
|
|
generate_error (ERROR_OPTION_CONFLICT,
|
|
|
|
"PAD paramter conflicts with UNFORMATTED form in "
|
|
|
|
"OPEN statement");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ioparm.library_return == LIBRARY_OK)
|
2004-08-23 16:28:31 +02:00
|
|
|
{
|
|
|
|
/* Change the changeable: */
|
2004-05-13 08:41:07 +02:00
|
|
|
if (flags->blank != BLANK_UNSPECIFIED)
|
|
|
|
u->flags.blank = flags->blank;
|
|
|
|
if (flags->delim != DELIM_UNSPECIFIED)
|
|
|
|
u->flags.delim = flags->delim;
|
|
|
|
if (flags->pad != PAD_UNSPECIFIED)
|
|
|
|
u->flags.pad = flags->pad;
|
|
|
|
}
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Reposition the file if necessary. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
switch (flags->position)
|
|
|
|
{
|
|
|
|
case POSITION_UNSPECIFIED:
|
|
|
|
case POSITION_ASIS:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case POSITION_REWIND:
|
|
|
|
if (sseek (u->s, 0) == FAILURE)
|
|
|
|
goto seek_error;
|
|
|
|
|
|
|
|
u->current_record = 0;
|
|
|
|
u->last_record = 0;
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
test_endfile (u); /* We might be at the end. */
|
2004-05-13 08:41:07 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case POSITION_APPEND:
|
|
|
|
if (sseek (u->s, file_length (u->s)) == FAILURE)
|
|
|
|
goto seek_error;
|
|
|
|
|
|
|
|
u->current_record = 0;
|
2004-08-23 16:28:31 +02:00
|
|
|
u->endfile = AT_ENDFILE; /* We are at the end. */
|
2004-05-13 08:41:07 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
seek_error:
|
|
|
|
generate_error (ERROR_OS, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Open an unused unit. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
void
|
|
|
|
new_unit (unit_flags * flags)
|
|
|
|
{
|
re PR libfortran/15234 (libgfortran doesn't compile on Tru64 UNIX V4.0F)
PR fortran/15234
* io/io.h (unit_t): Rename to ...
(gfc_unit) ... this.
(unit_root, current_unit, find_file, find_unit, get_unit): Now
of type gfc_unit.
(delete_file, insert_unit, close_unit): Argument now of type
gfc_unit.
* backspace.c (st_backspace), close.c (st_close), endfile.c
(st_endfile), inquire.c (inquire_via_unit, st_inquire), open.c
(test_endfile, edit_modes, new_unit, already_open, st_open),
rewind.c (st_rewind), transfer.c (current_unit), unit.c
(internal_unit, unit_cache, rotate_left, rotate_right, insert,
insert_unit, delete_root, delete_treap, delete_unit, find_unit,
get_unit, init_units, close_unit), unix.c (find_file0,
find_file, delete_file): Replace all occurences of unit_t by
gfc_unit.
From-SVN: r81903
2004-05-15 22:44:38 +02:00
|
|
|
gfc_unit *u;
|
2004-05-13 08:41:07 +02:00
|
|
|
stream *s;
|
|
|
|
char tmpname[5 /* fort. */ + 10 /* digits of unit number */ + 1 /* 0 */];
|
|
|
|
|
2004-12-08 01:32:39 +01:00
|
|
|
/* Change unspecifieds to defaults. Leave (flags->action ==
|
|
|
|
ACTION_UNSPECIFIED) alone so open_external() can set it based on
|
|
|
|
what type of open actually works. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
if (flags->access == ACCESS_UNSPECIFIED)
|
|
|
|
flags->access = ACCESS_SEQUENTIAL;
|
|
|
|
|
|
|
|
if (flags->form == FORM_UNSPECIFIED)
|
|
|
|
flags->form = (flags->access == ACCESS_SEQUENTIAL)
|
|
|
|
? FORM_FORMATTED : FORM_UNFORMATTED;
|
|
|
|
|
|
|
|
|
|
|
|
if (flags->delim == DELIM_UNSPECIFIED)
|
|
|
|
flags->delim = DELIM_NONE;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (flags->form == FORM_UNFORMATTED)
|
|
|
|
{
|
|
|
|
generate_error (ERROR_OPTION_CONFLICT,
|
|
|
|
"DELIM parameter conflicts with UNFORMATTED form in "
|
|
|
|
"OPEN statement");
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags->blank == BLANK_UNSPECIFIED)
|
|
|
|
flags->blank = BLANK_NULL;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (flags->form == FORM_UNFORMATTED)
|
|
|
|
{
|
|
|
|
generate_error (ERROR_OPTION_CONFLICT,
|
|
|
|
"BLANK parameter conflicts with UNFORMATTED form in "
|
|
|
|
"OPEN statement");
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags->pad == PAD_UNSPECIFIED)
|
|
|
|
flags->pad = PAD_YES;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (flags->form == FORM_UNFORMATTED)
|
|
|
|
{
|
|
|
|
generate_error (ERROR_OPTION_CONFLICT,
|
|
|
|
"PAD paramter conflicts with UNFORMATTED form in "
|
|
|
|
"OPEN statement");
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags->position != POSITION_ASIS && flags->access == ACCESS_DIRECT)
|
|
|
|
{
|
|
|
|
generate_error (ERROR_OPTION_CONFLICT,
|
|
|
|
"ACCESS parameter conflicts with SEQUENTIAL access in "
|
|
|
|
"OPEN statement");
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (flags->position == POSITION_UNSPECIFIED)
|
|
|
|
flags->position = POSITION_ASIS;
|
|
|
|
|
|
|
|
|
|
|
|
if (flags->status == STATUS_UNSPECIFIED)
|
|
|
|
flags->status = STATUS_UNKNOWN;
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Checks. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
if (flags->access == ACCESS_DIRECT && ioparm.recl_in == 0)
|
|
|
|
{
|
|
|
|
generate_error (ERROR_MISSING_OPTION,
|
|
|
|
"Missing RECL parameter in OPEN statement");
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ioparm.recl_in != 0 && ioparm.recl_in <= 0)
|
|
|
|
{
|
|
|
|
generate_error (ERROR_BAD_OPTION,
|
|
|
|
"RECL parameter is non-positive in OPEN statement");
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (flags->status)
|
|
|
|
{
|
|
|
|
case STATUS_SCRATCH:
|
|
|
|
if (ioparm.file == NULL)
|
|
|
|
break;
|
|
|
|
|
|
|
|
generate_error (ERROR_BAD_OPTION,
|
|
|
|
"FILE parameter must not be present in OPEN statement");
|
|
|
|
return;
|
|
|
|
|
|
|
|
case STATUS_OLD:
|
|
|
|
case STATUS_NEW:
|
|
|
|
case STATUS_REPLACE:
|
|
|
|
case STATUS_UNKNOWN:
|
|
|
|
if (ioparm.file != NULL)
|
|
|
|
break;
|
|
|
|
|
|
|
|
ioparm.file = tmpname;
|
|
|
|
ioparm.file_len = sprintf(ioparm.file, "fort.%d", ioparm.unit);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
internal_error ("new_unit(): Bad status");
|
|
|
|
}
|
|
|
|
|
2005-01-23 01:14:31 +01:00
|
|
|
/* Make sure the file isn't already open someplace else.
|
|
|
|
Do not error if opening file preconnected to stdin, stdout, stderr. */
|
|
|
|
|
|
|
|
u = find_file ();
|
|
|
|
if (u != NULL
|
|
|
|
&& (options.stdin_unit < 0 || u->unit_number != options.stdin_unit)
|
|
|
|
&& (options.stdout_unit < 0 || u->unit_number != options.stdout_unit)
|
|
|
|
&& (options.stderr_unit < 0 || u->unit_number != options.stderr_unit))
|
2004-05-13 08:41:07 +02:00
|
|
|
{
|
|
|
|
generate_error (ERROR_ALREADY_OPEN, NULL);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Open file. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
2004-12-08 01:32:39 +01:00
|
|
|
s = open_external (flags);
|
2004-05-13 08:41:07 +02:00
|
|
|
if (s == NULL)
|
|
|
|
{
|
|
|
|
generate_error (ERROR_OS, NULL);
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags->status == STATUS_NEW || flags->status == STATUS_REPLACE)
|
|
|
|
flags->status = STATUS_OLD;
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Create the unit structure. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
re PR libfortran/15234 (libgfortran doesn't compile on Tru64 UNIX V4.0F)
PR fortran/15234
* io/io.h (unit_t): Rename to ...
(gfc_unit) ... this.
(unit_root, current_unit, find_file, find_unit, get_unit): Now
of type gfc_unit.
(delete_file, insert_unit, close_unit): Argument now of type
gfc_unit.
* backspace.c (st_backspace), close.c (st_close), endfile.c
(st_endfile), inquire.c (inquire_via_unit, st_inquire), open.c
(test_endfile, edit_modes, new_unit, already_open, st_open),
rewind.c (st_rewind), transfer.c (current_unit), unit.c
(internal_unit, unit_cache, rotate_left, rotate_right, insert,
insert_unit, delete_root, delete_treap, delete_unit, find_unit,
get_unit, init_units, close_unit), unix.c (find_file0,
find_file, delete_file): Replace all occurences of unit_t by
gfc_unit.
From-SVN: r81903
2004-05-15 22:44:38 +02:00
|
|
|
u = get_mem (sizeof (gfc_unit) + ioparm.file_len);
|
2005-05-12 19:50:33 +02:00
|
|
|
memset (u, '\0', sizeof (gfc_unit) + ioparm.file_len);
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
u->unit_number = ioparm.unit;
|
|
|
|
u->s = s;
|
|
|
|
u->flags = *flags;
|
|
|
|
|
2005-05-11 07:56:20 +02:00
|
|
|
if (flags->position == POSITION_APPEND)
|
|
|
|
{
|
|
|
|
if (sseek (u->s, file_length (u->s)) == FAILURE)
|
|
|
|
generate_error (ERROR_OS, NULL);
|
|
|
|
u->endfile = AT_ENDFILE;
|
|
|
|
}
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Unspecified recl ends up with a processor dependent value. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
2005-03-16 20:32:08 +01:00
|
|
|
u->recl = (ioparm.recl_in != 0) ? ioparm.recl_in : g.max_offset;
|
2004-05-13 08:41:07 +02:00
|
|
|
u->last_record = 0;
|
|
|
|
u->current_record = 0;
|
|
|
|
|
|
|
|
/* If the file is direct access, calculate the maximum record number
|
2004-08-23 16:28:31 +02:00
|
|
|
via a division now instead of letting the multiplication overflow
|
|
|
|
later. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
if (flags->access == ACCESS_DIRECT)
|
|
|
|
u->maxrec = g.max_offset / u->recl;
|
|
|
|
|
|
|
|
memmove (u->file, ioparm.file, ioparm.file_len);
|
|
|
|
u->file_len = ioparm.file_len;
|
|
|
|
|
|
|
|
insert_unit (u);
|
|
|
|
|
|
|
|
/* The file is now connected. Errors after this point leave the
|
2004-08-23 16:28:31 +02:00
|
|
|
file connected. Curiously, the standard requires that the
|
|
|
|
position specifier be ignored for new files so a newly connected
|
|
|
|
file starts out that the initial point. We still need to figure
|
|
|
|
out if the file is at the end or not. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
test_endfile (u);
|
|
|
|
|
c99_functions.c, [...]: Whitespace fixes.
* intrinsics/c99_functions.c, intrinsics/eoshift0.c,
intrinsics/eoshift2.c, intrinsics/exit.c, intrinsics/flush.c,
intrinsics/ishftc.c, intrinsics/mvbits.c, intrinsics/pack_generic.c,
intrinsics/random.c, intrinsics/reshape_generic.c, intrinsics/size.c,
intrinsics/spread_generic.c, intrinsics/stat.c,
intrinsics/string_intrinsics.c, intrinsics/system_clock.c,
intrinsics/transpose_generic.c, intrinsics/unlink.c,
intrinsics/unpack_generic.c, io/backspace.c, io/format.c,
io/list_read.c, io/lock.c, io/open.c, io/transfer.c, io/unix.c,
io/write.c, runtime/environ.c, runtime/error.c,
runtime/in_pack_generic.c, runtime/in_unpack_generic.c, runtime/main.c,
runtime/memory.c, runtime/pause.c, runtime/stop.c,
runtime/string.c: Whitespace fixes.
From-SVN: r91794
2004-12-07 01:01:01 +01:00
|
|
|
cleanup:
|
2004-05-13 08:41:07 +02:00
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Free memory associated with a temporary filename. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
if (flags->status == STATUS_SCRATCH)
|
|
|
|
free_mem (ioparm.file);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Open a unit which is already open. This involves changing the
|
|
|
|
modes or closing what is there now and opening the new file. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
static void
|
re PR libfortran/15234 (libgfortran doesn't compile on Tru64 UNIX V4.0F)
PR fortran/15234
* io/io.h (unit_t): Rename to ...
(gfc_unit) ... this.
(unit_root, current_unit, find_file, find_unit, get_unit): Now
of type gfc_unit.
(delete_file, insert_unit, close_unit): Argument now of type
gfc_unit.
* backspace.c (st_backspace), close.c (st_close), endfile.c
(st_endfile), inquire.c (inquire_via_unit, st_inquire), open.c
(test_endfile, edit_modes, new_unit, already_open, st_open),
rewind.c (st_rewind), transfer.c (current_unit), unit.c
(internal_unit, unit_cache, rotate_left, rotate_right, insert,
insert_unit, delete_root, delete_treap, delete_unit, find_unit,
get_unit, init_units, close_unit), unix.c (find_file0,
find_file, delete_file): Replace all occurences of unit_t by
gfc_unit.
From-SVN: r81903
2004-05-15 22:44:38 +02:00
|
|
|
already_open (gfc_unit * u, unit_flags * flags)
|
2004-05-13 08:41:07 +02:00
|
|
|
{
|
|
|
|
if (ioparm.file == NULL)
|
|
|
|
{
|
|
|
|
edit_modes (u, flags);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If the file is connected to something else, close it and open a
|
2004-08-23 16:28:31 +02:00
|
|
|
new unit. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
if (!compare_file_filename (u->s, ioparm.file, ioparm.file_len))
|
|
|
|
{
|
|
|
|
if (close_unit (u))
|
|
|
|
{
|
|
|
|
generate_error (ERROR_OS, "Error closing file in OPEN statement");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
new_unit (flags);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
edit_modes (u, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Open file. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
acinclude.m4 (LIBGFOR_CHECK_ATTRIBUTE_VISIBILITY): New.
* acinclude.m4 (LIBGFOR_CHECK_ATTRIBUTE_VISIBILITY): New.
(LIBGFOR_CHECK_ATTRIBUTE_DLLEXPORT): New.
(LIBGFOR_CHECK_ATTRIBUTE_ALIAS): New.
* configure.ac: Use them.
* configure, config.h.in, aclocal.m4: Rebuild.
* libgfortran.h (prefix): Remove.
(PREFIX, IPREFIX): New.
(sym_rename, sym_rename1, sym_rename2): New.
(internal_proto, export_proto, export_proto_np): New.
(iexport_proto, iexport): New.
(iexport_data_proto, iexport_data): New.
* intrinsics/abort.c, intrinsics/args.c, intrinsics/associated.c,
intrinsics/cpu_time.c, intrinsics/cshift0.c,
intrinsics/date_and_time.c, intrinsics/env.c, intrinsics/eoshift0.c,
intrinsics/eoshift2.c, intrinsics/etime.c, intrinsics/exit.c,
intrinsics/flush.c, intrinsics/fnum.c, intrinsics/getXid.c,
intrinsics/getcwd.c, intrinsics/ishftc.c, intrinsics/mvbits.c,
intrinsics/pack_generic.c, intrinsics/rand.c, intrinsics/random.c,
intrinsics/reshape_generic.c, intrinsics/size.c,
intrinsics/spread_generic.c, intrinsics/stat.c,
intrinsics/string_intrinsics.c, intrinsics/system.c,
intrinsics/system_clock.c, intrinsics/transpose_generic.c,
intrinsics/umask.c, intrinsics/unlink.c, intrinsics/unpack_generic.c,
io/backspace.c, io/close.c, io/endfile.c, io/inquire.c, io/io.h,
io/open.c, io/rewind.c, io/transfer.c, libgfortran.h, m4/cshift1.m4,
m4/dotprod.m4, m4/dotprodc.m4, m4/dotprodl.m4, m4/eoshift1.m4,
m4/eoshift3.m4, m4/exponent.m4, m4/fraction.m4, m4/iforeach.m4,
m4/ifunction.m4, m4/matmul.m4, m4/matmull.m4, m4/nearest.m4,
m4/pow.m4, m4/reshape.m4, m4/set_exponent.m4, m4/shape.m4,
m4/transpose.m4, runtime/environ.c, runtime/error.c,
runtime/in_pack_generic.c, runtime/in_unpack_generic.c,
runtime/main.c, runtime/memory.c, runtime/pause.c, runtime/select.c,
runtime/stop.c: Use them to mark symbols internal or external.
* generated/*: Rebuild.
From-SVN: r92045
2004-12-12 09:59:05 +01:00
|
|
|
extern void st_open (void);
|
|
|
|
export_proto(st_open);
|
|
|
|
|
2004-05-13 08:41:07 +02:00
|
|
|
void
|
|
|
|
st_open (void)
|
|
|
|
{
|
|
|
|
unit_flags flags;
|
re PR libfortran/15234 (libgfortran doesn't compile on Tru64 UNIX V4.0F)
PR fortran/15234
* io/io.h (unit_t): Rename to ...
(gfc_unit) ... this.
(unit_root, current_unit, find_file, find_unit, get_unit): Now
of type gfc_unit.
(delete_file, insert_unit, close_unit): Argument now of type
gfc_unit.
* backspace.c (st_backspace), close.c (st_close), endfile.c
(st_endfile), inquire.c (inquire_via_unit, st_inquire), open.c
(test_endfile, edit_modes, new_unit, already_open, st_open),
rewind.c (st_rewind), transfer.c (current_unit), unit.c
(internal_unit, unit_cache, rotate_left, rotate_right, insert,
insert_unit, delete_root, delete_treap, delete_unit, find_unit,
get_unit, init_units, close_unit), unix.c (find_file0,
find_file, delete_file): Replace all occurences of unit_t by
gfc_unit.
From-SVN: r81903
2004-05-15 22:44:38 +02:00
|
|
|
gfc_unit *u = NULL;
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
library_start ();
|
|
|
|
|
2004-08-23 16:28:31 +02:00
|
|
|
/* Decode options. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
flags.access = (ioparm.access == NULL) ? ACCESS_UNSPECIFIED :
|
|
|
|
find_option (ioparm.access, ioparm.access_len, access_opt,
|
|
|
|
"Bad ACCESS parameter in OPEN statement");
|
|
|
|
|
|
|
|
flags.action = (ioparm.action == NULL) ? ACTION_UNSPECIFIED :
|
|
|
|
find_option (ioparm.action, ioparm.action_len, action_opt,
|
|
|
|
"Bad ACTION parameter in OPEN statement");
|
|
|
|
|
|
|
|
flags.blank = (ioparm.blank == NULL) ? BLANK_UNSPECIFIED :
|
|
|
|
find_option (ioparm.blank, ioparm.blank_len, blank_opt,
|
|
|
|
"Bad BLANK parameter in OPEN statement");
|
|
|
|
|
|
|
|
flags.delim = (ioparm.delim == NULL) ? DELIM_UNSPECIFIED :
|
|
|
|
find_option (ioparm.delim, ioparm.delim_len, delim_opt,
|
|
|
|
"Bad DELIM parameter in OPEN statement");
|
|
|
|
|
|
|
|
flags.pad = (ioparm.pad == NULL) ? PAD_UNSPECIFIED :
|
|
|
|
find_option (ioparm.pad, ioparm.pad_len, pad_opt,
|
|
|
|
"Bad PAD parameter in OPEN statement");
|
|
|
|
|
|
|
|
flags.form = (ioparm.form == NULL) ? FORM_UNSPECIFIED :
|
|
|
|
find_option (ioparm.form, ioparm.form_len, form_opt,
|
|
|
|
"Bad FORM parameter in OPEN statement");
|
|
|
|
|
|
|
|
flags.position = (ioparm.position == NULL) ? POSITION_UNSPECIFIED :
|
|
|
|
find_option (ioparm.position, ioparm.position_len, position_opt,
|
|
|
|
"Bad POSITION parameter in OPEN statement");
|
|
|
|
|
|
|
|
flags.status = (ioparm.status == NULL) ? STATUS_UNSPECIFIED :
|
|
|
|
find_option (ioparm.status, ioparm.status_len, status_opt,
|
|
|
|
"Bad STATUS parameter in OPEN statement");
|
|
|
|
|
|
|
|
if (ioparm.unit < 0)
|
|
|
|
generate_error (ERROR_BAD_OPTION, "Bad unit number in OPEN statement");
|
|
|
|
|
2004-08-14 00:01:02 +02:00
|
|
|
if (flags.position != POSITION_UNSPECIFIED
|
|
|
|
&& flags.access == ACCESS_DIRECT)
|
2004-05-13 08:41:07 +02:00
|
|
|
generate_error (ERROR_BAD_OPTION,
|
|
|
|
"Cannot use POSITION with direct access files");
|
|
|
|
|
|
|
|
if (flags.position == POSITION_UNSPECIFIED)
|
|
|
|
flags.position = POSITION_ASIS;
|
|
|
|
|
|
|
|
if (ioparm.library_return != LIBRARY_OK)
|
2005-03-29 10:37:32 +02:00
|
|
|
{
|
|
|
|
library_end ();
|
2004-05-13 08:41:07 +02:00
|
|
|
return;
|
2005-03-29 10:37:32 +02:00
|
|
|
}
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
u = find_unit (ioparm.unit);
|
|
|
|
|
|
|
|
if (u == NULL)
|
|
|
|
new_unit (&flags);
|
|
|
|
else
|
|
|
|
already_open (u, &flags);
|
|
|
|
|
|
|
|
library_end ();
|
|
|
|
}
|