+2004-05-15 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de>
+
+ 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.
+
2004-05-15 Bud Davis <bdavis9659@comcast.net>
PR fortran/15311
void
st_backspace (void)
{
- unit_t *u;
+ gfc_unit *u;
library_start ();
st_close (void)
{
close_status status;
- unit_t *u;
+ gfc_unit *u;
library_start ();
void
st_endfile (void)
{
- unit_t *u;
+ gfc_unit *u;
library_start ();
/* inquire_via_unit()-- Inquiry via unit number. The unit might not exist. */
static void
-inquire_via_unit (unit_t * u)
+inquire_via_unit (gfc_unit * u)
{
const char *p;
void
st_inquire (void)
{
- unit_t *u;
+ gfc_unit *u;
library_start ();
#define DEFAULT_RECL 10000
-typedef struct unit_t
+typedef struct gfc_unit
{
int unit_number;
stream *s;
- struct unit_t *left, *right; /* Treap links. */
+ struct gfc_unit *left, *right; /* Treap links. */
int priority;
int read_bad, current_record;
int file_len;
char file[1]; /* Filename is allocated at the end of the structure. */
}
-unit_t;
+gfc_unit;
/* Global variables. Putting these in a structure makes it easier to
maintain, particularly with the constraint of a prefix. */
int reversion_flag; /* Format reversion has occurred. */
int first_item;
- unit_t *unit_root;
+ gfc_unit *unit_root;
int seen_dollar;
enum {READING, WRITING} mode;
#define current_unit prefix(current_unit)
-extern unit_t *current_unit;
+extern gfc_unit *current_unit;
/* Format tokens. Only about half of these can be stored in the
format nodes. */
int compare_file_filename (stream *, const char *, int);
#define find_file prefix(find_file)
-unit_t *find_file (void);
+gfc_unit *find_file (void);
#define stream_at_bof prefix(stream_at_bof)
int stream_at_bof (stream *);
int stream_at_eof (stream *);
#define delete_file prefix(delete_file)
-int delete_file (unit_t *);
+int delete_file (gfc_unit *);
#define file_exists prefix(file_exists)
int file_exists (void);
/* unit.c */
#define insert_unit prefix(insert_unix)
-void insert_unit (unit_t *);
+void insert_unit (gfc_unit *);
#define close_unit prefix(close_unit)
-int close_unit (unit_t *);
+int close_unit (gfc_unit *);
#define is_internal_unit prefix(is_internal_unit)
int is_internal_unit (void);
#define find_unit prefix(find_unit)
-unit_t *find_unit (int);
+gfc_unit *find_unit (int);
#define get_unit prefix(get_unit)
-unit_t *get_unit (int);
+gfc_unit *get_unit (int);
/* open.c */
#define test_endfile prefix(test_endfile)
-void test_endfile (unit_t *);
+void test_endfile (gfc_unit *);
#define new_unit prefix(new_unit)
void new_unit (unit_flags *);
* state from AFTER_ENDFILE to AT_ENDFILE. */
void
-test_endfile (unit_t * u)
+test_endfile (gfc_unit * u)
{
if (u->endfile == NO_ENDFILE && file_length (u->s) == file_position (u->s))
* to be changed. */
static void
-edit_modes (unit_t * u, unit_flags * flags)
+edit_modes (gfc_unit * u, unit_flags * flags)
{
/* Complain about attempts to change the unchangeable */
void
new_unit (unit_flags * flags)
{
- unit_t *u;
+ gfc_unit *u;
stream *s;
char tmpname[5 /* fort. */ + 10 /* digits of unit number */ + 1 /* 0 */];
/* Create the unit structure */
- u = get_mem (sizeof (unit_t) + ioparm.file_len);
+ u = get_mem (sizeof (gfc_unit) + ioparm.file_len);
u->unit_number = ioparm.unit;
u->s = s;
* file. */
static void
-already_open (unit_t * u, unit_flags * flags)
+already_open (gfc_unit * u, unit_flags * flags)
{
if (ioparm.file == NULL)
st_open (void)
{
unit_flags flags;
- unit_t *u = NULL;
+ gfc_unit *u = NULL;
library_start ();
void
st_rewind (void)
{
- unit_t *u;
+ gfc_unit *u;
library_start ();
* transferred.
*/
-unit_t *current_unit;
+gfc_unit *current_unit;
static int sf_seen_eor = 0;
char scratch[SCRATCH_SIZE];
#define CACHE_SIZE 3
-static unit_t internal_unit, *unit_cache[CACHE_SIZE];
+static gfc_unit internal_unit, *unit_cache[CACHE_SIZE];
/* This implementation is based on Stefan Nilsson's article in the
/* rotate_left()-- Rotate the treap left */
-static unit_t *
-rotate_left (unit_t * t)
+static gfc_unit *
+rotate_left (gfc_unit * t)
{
- unit_t *temp;
+ gfc_unit *temp;
temp = t->right;
t->right = t->right->left;
/* rotate_right()-- Rotate the treap right */
-static unit_t *
-rotate_right (unit_t * t)
+static gfc_unit *
+rotate_right (gfc_unit * t)
{
- unit_t *temp;
+ gfc_unit *temp;
temp = t->left;
t->left = t->left->right;
/* insert()-- Recursive insertion function. Returns the updated treap. */
-static unit_t *
-insert (unit_t * new, unit_t * t)
+static gfc_unit *
+insert (gfc_unit * new, gfc_unit * t)
{
int c;
* an error to insert a key that already exists. */
void
-insert_unit (unit_t * new)
+insert_unit (gfc_unit * new)
{
new->priority = pseudo_random ();
}
-static unit_t *
-delete_root (unit_t * t)
+static gfc_unit *
+delete_root (gfc_unit * t)
{
- unit_t *temp;
+ gfc_unit *temp;
if (t->left == NULL)
return t->right;
* must just point to a treap structure with the key to be deleted.
* Returns the new root node of the tree. */
-static unit_t *
-delete_treap (unit_t * old, unit_t * t)
+static gfc_unit *
+delete_treap (gfc_unit * old, gfc_unit * t)
{
int c;
/* delete_unit()-- Delete a unit from a tree */
static void
-delete_unit (unit_t * old)
+delete_unit (gfc_unit * old)
{
g.unit_root = delete_treap (old, g.unit_root);
/* find_unit()-- Given an integer, return a pointer to the unit
* structure. Returns NULL if the unit does not exist. */
-unit_t *
+gfc_unit *
find_unit (int n)
{
- unit_t *p;
+ gfc_unit *p;
int c;
for (c = 0; c < CACHE_SIZE; c++)
/* get_unit()-- Returns the unit structure associated with the integer
* unit or the internal file. */
-unit_t *
+gfc_unit *
get_unit (int read_flag)
{
- unit_t *u;
+ gfc_unit *u;
if (ioparm.internal_unit != NULL)
{
init_units (void)
{
offset_t m, n;
- unit_t *u;
+ gfc_unit *u;
int i;
if (options.stdin_unit >= 0)
{ /* STDIN */
- u = get_mem (sizeof (unit_t));
+ u = get_mem (sizeof (gfc_unit));
u->unit_number = options.stdin_unit;
u->s = input_stream ();
if (options.stdout_unit >= 0)
{ /* STDOUT */
- u = get_mem (sizeof (unit_t));
+ u = get_mem (sizeof (gfc_unit));
u->unit_number = options.stdout_unit;
u->s = output_stream ();
* associated with the stream is freed. Returns nonzero on I/O error. */
int
-close_unit (unit_t * u)
+close_unit (gfc_unit * u)
{
int i, rc;
/* find_file0()-- Recursive work function for find_file() */
-static unit_t *
-find_file0 (unit_t * u, struct stat *st1)
+static gfc_unit *
+find_file0 (gfc_unit * u, struct stat *st1)
{
struct stat st2;
- unit_t *v;
+ gfc_unit *v;
if (u == NULL)
return NULL;
/* find_file()-- Take the current filename and see if there is a unit
* that has the file already open. Returns a pointer to the unit if so. */
-unit_t *
+gfc_unit *
find_file (void)
{
char path[PATH_MAX + 1];
* with the unit. Returns nonzero if something went wrong. */
int
-delete_file (unit_t * u)
+delete_file (gfc_unit * u)
{
char path[PATH_MAX + 1];