Commit 7fcb1804 by Tobias Schlüter

io.h, [...]: Fix formatting issues, update copyright years.

* io/io.h, io/list_read.c, io/open.c, io/transfer.c, io/write.c:
Fix formatting issues, update copyright years.

From-SVN: r86425
parent b3d1f5b4
/* Copyright (C) 2002-2003 Free Software Foundation, Inc.
/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
Contributed by Andy Vaught
This file is part of the GNU Fortran 95 runtime library (libgfortran).
......
/* Copyright (C) 2002-2003 Free Software Foundation, Inc.
/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
Contributed by Andy Vaught
This file is part of the GNU Fortran 95 runtime library (libgfortran).
......@@ -134,10 +133,10 @@ static st_option access_opt[] = {
};
/* test_endfile()-- 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. */
/* 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. */
void
test_endfile (gfc_unit * u)
......@@ -148,14 +147,14 @@ test_endfile (gfc_unit * u)
}
/* edit_modes()-- Change the modes of a file, those that are allowed
* to be changed. */
/* Change the modes of a file, those that are allowed * to be
changed. */
static void
edit_modes (gfc_unit * u, unit_flags * flags)
{
/* Complain about attempts to change the unchangeable */
/* Complain about attempts to change the unchangeable. */
if (flags->status != STATUS_UNSPECIFIED &&
u->flags.status != flags->position)
......@@ -178,7 +177,7 @@ edit_modes (gfc_unit * u, unit_flags * flags)
generate_error (ERROR_BAD_OPTION,
"Cannot change ACTION parameter in OPEN statement");
/* Status must be OLD if present */
/* Status must be OLD if present. */
if (flags->status != STATUS_UNSPECIFIED && flags->status != STATUS_OLD)
generate_error (ERROR_BAD_OPTION,
......@@ -203,7 +202,8 @@ edit_modes (gfc_unit * u, unit_flags * flags)
}
if (ioparm.library_return == LIBRARY_OK)
{ /* Change the changeable */
{
/* Change the changeable: */
if (flags->blank != BLANK_UNSPECIFIED)
u->flags.blank = flags->blank;
if (flags->delim != DELIM_UNSPECIFIED)
......@@ -227,7 +227,7 @@ edit_modes (gfc_unit * u, unit_flags * flags)
u->current_record = 0;
u->last_record = 0;
test_endfile (u); /* We might be at the end */
test_endfile (u); /* We might be at the end. */
break;
case POSITION_APPEND:
......@@ -235,7 +235,7 @@ edit_modes (gfc_unit * u, unit_flags * flags)
goto seek_error;
u->current_record = 0;
u->endfile = AT_ENDFILE; /* We are at the end */
u->endfile = AT_ENDFILE; /* We are at the end. */
break;
seek_error:
......@@ -245,7 +245,7 @@ edit_modes (gfc_unit * u, unit_flags * flags)
}
/* new_unit()-- Open an unused unit */
/* Open an unused unit. */
void
new_unit (unit_flags * flags)
......@@ -254,13 +254,13 @@ new_unit (unit_flags * flags)
stream *s;
char tmpname[5 /* fort. */ + 10 /* digits of unit number */ + 1 /* 0 */];
/* Change unspecifieds to defaults */
/* Change unspecifieds to defaults. */
if (flags->access == ACCESS_UNSPECIFIED)
flags->access = ACCESS_SEQUENTIAL;
if (flags->action == ACTION_UNSPECIFIED)
flags->action = ACTION_READWRITE; /* Processor dependent */
flags->action = ACTION_READWRITE; /* Processor dependent. */
if (flags->form == FORM_UNSPECIFIED)
flags->form = (flags->access == ACCESS_SEQUENTIAL)
......@@ -321,7 +321,7 @@ new_unit (unit_flags * flags)
if (flags->status == STATUS_UNSPECIFIED)
flags->status = STATUS_UNKNOWN;
/* Checks */
/* Checks. */
if (flags->access == ACCESS_DIRECT && ioparm.recl_in == 0)
{
......@@ -362,7 +362,7 @@ new_unit (unit_flags * flags)
internal_error ("new_unit(): Bad status");
}
/* Make sure the file isn't already open someplace else */
/* Make sure the file isn't already open someplace else. */
if (find_file () != NULL)
{
......@@ -370,7 +370,7 @@ new_unit (unit_flags * flags)
goto cleanup;
}
/* Open file */
/* Open file. */
s = open_external (flags->action, flags->status);
if (s == NULL)
......@@ -382,7 +382,7 @@ new_unit (unit_flags * flags)
if (flags->status == STATUS_NEW || flags->status == STATUS_REPLACE)
flags->status = STATUS_OLD;
/* Create the unit structure */
/* Create the unit structure. */
u = get_mem (sizeof (gfc_unit) + ioparm.file_len);
......@@ -390,15 +390,15 @@ new_unit (unit_flags * flags)
u->s = s;
u->flags = *flags;
/* Unspecified recl ends up with a processor dependent value */
/* Unspecified recl ends up with a processor dependent value. */
u->recl = (ioparm.recl_in != 0) ? ioparm.recl_in : DEFAULT_RECL;
u->last_record = 0;
u->current_record = 0;
/* If the file is direct access, calculate the maximum record number
* via a division now instead of letting the multiplication overflow
* later. */
via a division now instead of letting the multiplication overflow
later. */
if (flags->access == ACCESS_DIRECT)
u->maxrec = g.max_offset / u->recl;
......@@ -409,25 +409,24 @@ new_unit (unit_flags * flags)
insert_unit (u);
/* The file is now connected. Errors after this point leave the
* 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. */
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. */
test_endfile (u);
cleanup:
/* Free memory associated with a temporary filename */
/* Free memory associated with a temporary filename. */
if (flags->status == STATUS_SCRATCH)
free_mem (ioparm.file);
}
/* already_open()-- Open a unit which is already open. This involves
* changing the modes or closing what is there now and opening the new
* file. */
/* Open a unit which is already open. This involves changing the
modes or closing what is there now and opening the new file. */
static void
already_open (gfc_unit * u, unit_flags * flags)
......@@ -440,7 +439,7 @@ already_open (gfc_unit * u, unit_flags * flags)
}
/* If the file is connected to something else, close it and open a
* new unit */
new unit. */
if (!compare_file_filename (u->s, ioparm.file, ioparm.file_len))
{
......@@ -458,8 +457,7 @@ already_open (gfc_unit * u, unit_flags * flags)
}
/*************/
/* open file */
/* Open file. */
void
st_open (void)
......@@ -469,7 +467,7 @@ st_open (void)
library_start ();
/* Decode options */
/* Decode options. */
flags.access = (ioparm.access == NULL) ? ACCESS_UNSPECIFIED :
find_option (ioparm.access, ioparm.access_len, access_opt,
......
/* Copyright (C) 2002-2003 Free Software Foundation, Inc.
/* Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
Contributed by Andy Vaught
This file is part of the GNU Fortran 95 runtime library (libgfortran).
......@@ -104,9 +104,8 @@ extract_real (const void *p, int len)
}
/* calculate sign()-- Given a flag that indicate if a value is
* negative or not, return a sign_t that gives the sign that we need
* to produce. */
/* Given a flag that indicate if a value is negative or not, return a
sign_t that gives the sign that we need to produce. */
static sign_t
calculate_sign (int negative_flag)
......@@ -133,7 +132,7 @@ calculate_sign (int negative_flag)
}
/* calculate_exp()-- returns the value of 10**d. */
/* Returns the value of 10**d. */
static double
calculate_exp (int d)
......@@ -150,8 +149,7 @@ calculate_exp (int d)
}
/* calculate_G_format()-- geneate corresponding I/O format for
FMT_G output.
/* Generate corresponding I/O format for FMT_G output.
The rules to translate FMT_G to FMT_E or FNT_F from DEC fortran
LRM (table 11-2, Chapter 11, "I/O Formatting", P11-25) is:
......@@ -252,8 +250,7 @@ calculate_G_format (fnode *f, double value, int len, int *num_blank)
}
/* output_float() -- output a real number according to its format
which is FMT_G free */
/* Output a real number according to its format which is FMT_G free. */
static void
output_float (fnode *f, double value, int len)
......@@ -275,17 +272,17 @@ output_float (fnode *f, double value, int len)
int intval = 0, intlen = 0;
int j;
/* EXP value for this number */
/* EXP value for this number. */
neval = 0;
/* Width of EXP and it's sign*/
/* Width of EXP and it's sign. */
nesign = 0;
ft = f->format;
w = f->u.real.w;
d = f->u.real.d + 1;
/* Width of the EXP */
/* Width of the EXP. */
e = 0;
sca = g.scale_factor;
......@@ -295,7 +292,7 @@ output_float (fnode *f, double value, int len)
if (n < 0)
n = -n;
/* Width of the sign for the whole number */
/* Width of the sign for the whole number. */
nsign = (sign == SIGN_NONE ? 0 : 1);
digits = 0;
......@@ -312,8 +309,8 @@ output_float (fnode *f, double value, int len)
minv = 0.1;
maxv = 1.0;
/* Here calculate the new val of the number with consideration
of Globle Scale value */
/* Calculate the new val of the number with consideration
of global scale value. */
while (sca > 0)
{
minv *= 10.0;
......@@ -323,7 +320,7 @@ output_float (fnode *f, double value, int len)
neval --;
}
/* Now calculate the new Exp value for this number */
/* Now calculate the new Exp value for this number. */
sca = g.scale_factor;
while(sca >= 1)
{
......@@ -343,7 +340,7 @@ output_float (fnode *f, double value, int len)
maxv = 10.0;
}
/* OK, let's scale the number to appropriate range */
/* OK, let's scale the number to appropriate range. */
while (scale_flag && n > 0.0 && n < minv)
{
if (n < minv)
......@@ -362,11 +359,10 @@ output_float (fnode *f, double value, int len)
}
/* It is time to process the EXP part of the number.
Value of 'nesign' is 0 unless following codes is executed.
*/
Value of 'nesign' is 0 unless following codes is executed. */
if (ft != FMT_F)
{
/* Sign of the EXP value */
/* Sign of the EXP value. */
if (neval >= 0)
esign = SIGN_PLUS;
else
......@@ -375,7 +371,7 @@ output_float (fnode *f, double value, int len)
neval = - neval ;
}
/* Width of the EXP*/
/* Width of the EXP. */
e_new = 0;
j = neval;
while (j > 0)
......@@ -386,11 +382,11 @@ output_float (fnode *f, double value, int len)
if (e <= e_new)
e = e_new;
/* Got the width of EXP */
/* Got the width of EXP. */
if (e < digits)
e = digits ;
/* Minimum value of the width would be 2 */
/* Minimum value of the width would be 2. */
if (e < 2)
e = 2;
......@@ -424,7 +420,7 @@ output_float (fnode *f, double value, int len)
nesign -= 1;
nblank = w - (nsign + intlen + d + nesign);
}
/* don't let a leading '0' cause field overflow */
/* Don't let a leading '0' cause field overflow. */
if (nblank == -1 && ft == FMT_F && q[0] == '0')
{
q++;
......@@ -497,7 +493,7 @@ write_l (fnode * f, char *source, int len)
p[f->u.w - 1] = (n) ? 'T' : 'F';
}
/* write_float() -- output a real number according to its format */
/* Output a real number according to its format. */
static void
write_float (fnode *f, const char *source, int len)
......@@ -579,7 +575,7 @@ write_int (fnode *f, const char *source, int len, char *(*conv) (uint64_t))
n = extract_int (source, len);
/* Special case */
/* Special case: */
if (m == 0 && n == 0)
{
......@@ -606,7 +602,7 @@ write_int (fnode *f, const char *source, int len, char *(*conv) (uint64_t))
digits = strlen (q);
/* Select a width if none was specified. The idea here is to always
* print something. */
print something. */
if (w == 0)
w = ((digits < m) ? m : digits);
......@@ -619,7 +615,7 @@ write_int (fnode *f, const char *source, int len, char *(*conv) (uint64_t))
if (digits < m)
nzero = m - digits;
/* See if things will work */
/* See if things will work. */
nblank = w - (nzero + digits);
......@@ -654,7 +650,7 @@ write_decimal (fnode *f, const char *source, int len, char *(*conv) (int64_t))
n = extract_int (source, len);
/* Special case */
/* Special case: */
if (m == 0 && n == 0)
{
......@@ -679,7 +675,7 @@ write_decimal (fnode *f, const char *source, int len, char *(*conv) (int64_t))
digits = strlen (q);
/* Select a width if none was specified. The idea here is to always
* print something. */
print something. */
if (w == 0)
w = ((digits < m) ? m : digits) + nsign;
......@@ -692,7 +688,7 @@ write_decimal (fnode *f, const char *source, int len, char *(*conv) (int64_t))
if (digits < m)
nzero = m - digits;
/* See if things will work */
/* See if things will work. */
nblank = w - (nsign + nzero + digits);
......@@ -727,7 +723,7 @@ done:
}
/* otoa()-- Convert unsigned octal to ascii */
/* Convert unsigned octal to ascii. */
static char *
otoa (uint64_t n)
......@@ -755,7 +751,7 @@ otoa (uint64_t n)
}
/* btoa()-- Convert unsigned binary to ascii */
/* Convert unsigned binary to ascii. */
static char *
btoa (uint64_t n)
......@@ -816,6 +812,7 @@ write_z (fnode * f, const char *p, int len)
void
write_d (fnode *f, const char *p, int len)
{
write_float (f, p, len);
}
......@@ -823,6 +820,7 @@ write_d (fnode *f, const char *p, int len)
void
write_e (fnode *f, const char *p, int len)
{
write_float (f, p, len);
}
......@@ -830,6 +828,7 @@ write_e (fnode *f, const char *p, int len)
void
write_f (fnode *f, const char *p, int len)
{
write_float (f, p, len);
}
......@@ -837,6 +836,7 @@ write_f (fnode *f, const char *p, int len)
void
write_en (fnode *f, const char *p, int len)
{
write_float (f, p, len);
}
......@@ -844,11 +844,12 @@ write_en (fnode *f, const char *p, int len)
void
write_es (fnode *f, const char *p, int len)
{
write_float (f, p, len);
}
/* write_x()-- Take care of the X/TR descriptor */
/* Take care of the X/TR descriptor. */
void
write_x (fnode * f)
......@@ -863,11 +864,11 @@ write_x (fnode * f)
}
/* List-directed writing */
/* List-directed writing. */
/* write_char()-- Write a single character to the output. Returns
* nonzero if something goes wrong. */
/* Write a single character to the output. Returns nonzero if
something goes wrong. */
static int
write_char (char c)
......@@ -884,7 +885,7 @@ write_char (char c)
}
/* write_logical()-- Write a list-directed logical value */
/* Write a list-directed logical value. */
static void
write_logical (const char *source, int length)
......@@ -893,7 +894,7 @@ write_logical (const char *source, int length)
}
/* write_integer()-- Write a list-directed integer value. */
/* Write a list-directed integer value. */
static void
write_integer (const char *source, int length)
......@@ -939,9 +940,8 @@ write_integer (const char *source, int length)
}
/* write_character()-- Write a list-directed string. We have to worry
* about delimiting the strings if the file has been opened in that
* mode. */
/* Write a list-directed string. We have to worry about delimiting
the strings if the file has been opened in that mode. */
static void
write_character (const char *source, int length)
......@@ -995,8 +995,8 @@ write_character (const char *source, int length)
}
/* Output the Real number with default format.
REAL(4) is 1PG14.7E2, and REAL(8) is 1PG23.15E3 */
/* Output a real number with default format.
This is 1PG14.7E2 for REAL(4) and 1PG23.15E3 for REAL(8). */
static void
write_real (const char *source, int length)
......@@ -1038,7 +1038,7 @@ write_complex (const char *source, int len)
}
/* write_separator()-- Write the separator between items. */
/* Write the separator between items. */
static void
write_separator (void)
......@@ -1053,9 +1053,9 @@ write_separator (void)
}
/* list_formatted_write()-- Write an item with list formatting.
* TODO: handle skipping to the next record correctly, particularly
* with strings. */
/* Write an item with list formatting.
TODO: handle skipping to the next record correctly, particularly
with strings. */
void
list_formatted_write (bt type, void *p, int len)
......@@ -1160,4 +1160,3 @@ namelist_write (void)
write_character("/",1);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment