+2017-04-11 Jerry DeLisle <jvdelisle@gcc.gnu.org>
+
+ * close.c: Fix white space in pointer declarations and comment
+ formats where applicable.
+ * fbuf.c: Likewise.
+ * fbuf.h: Likewise.
+ * format.c: Likewise.
+ * inquire.c: Likewise.
+ * intrinsics.c: Likewise.
+ * list_read.c: Likewise.
+ * lock.c: Likewise.
+ * open.c: Likewise.
+ * read.c: Likewise.
+ * transfer.c: Likewise.
+ * unit.c: Likewise.
+ * unix.c: Likewise.
+ * unix.h: Likewise.
+ * write.c: Likewise.
+
2017-03-29 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libgfortran/78670
close_status status;
gfc_unit *u;
#if !HAVE_UNLINK_OPEN_FILE
- char * path;
+ char *path;
path = NULL;
#endif
void
-fbuf_init (gfc_unit * u, int len)
+fbuf_init (gfc_unit *u, int len)
{
if (len == 0)
len = 512; /* Default size. */
void
-fbuf_destroy (gfc_unit * u)
+fbuf_destroy (gfc_unit *u)
{
if (u->fbuf == NULL)
return;
static void
#ifdef FBUF_DEBUG
-fbuf_debug (gfc_unit * u, const char * format, ...)
+fbuf_debug (gfc_unit *u, const char *format, ...)
{
va_list args;
va_start(args, format);
fprintf (stderr, "''\n");
}
#else
-fbuf_debug (gfc_unit * u __attribute__ ((unused)),
- const char * format __attribute__ ((unused)),
+fbuf_debug (gfc_unit *u __attribute__ ((unused)),
+ const char *format __attribute__ ((unused)),
...) {}
#endif
modified. */
int
-fbuf_reset (gfc_unit * u)
+fbuf_reset (gfc_unit *u)
{
int seekval = 0;
reallocating if necessary. */
char *
-fbuf_alloc (gfc_unit * u, int len)
+fbuf_alloc (gfc_unit *u, int len)
{
int newlen;
char *dest;
if (u->fbuf->pos + len > u->fbuf->len)
{
/* Round up to nearest multiple of the current buffer length. */
- newlen = ((u->fbuf->pos + len) / u->fbuf->len + 1) * u->fbuf->len;
+ newlen = ((u->fbuf->pos + len) / u->fbuf->len + 1) *u->fbuf->len;
u->fbuf->buf = xrealloc (u->fbuf->buf, newlen);
u->fbuf->len = newlen;
}
mode. Return value is 0 for success, -1 on failure. */
int
-fbuf_flush (gfc_unit * u, unit_mode mode)
+fbuf_flush (gfc_unit *u, unit_mode mode)
{
int nwritten;
Return value is 0 for success, -1 on failure. */
int
-fbuf_flush_list (gfc_unit * u, unit_mode mode)
+fbuf_flush_list (gfc_unit *u, unit_mode mode)
{
int nwritten;
int
-fbuf_seek (gfc_unit * u, int off, int whence)
+fbuf_seek (gfc_unit *u, int off, int whence)
{
if (!u->fbuf)
return -1;
of bytes actually processed. */
char *
-fbuf_read (gfc_unit * u, int * len)
+fbuf_read (gfc_unit *u, int *len)
{
char *ptr;
int oldact, oldpos;
reading. Never call this function directly. */
int
-fbuf_getc_refill (gfc_unit * u)
+fbuf_getc_refill (gfc_unit *u)
{
int nread;
char *p;
extern int fbuf_reset (gfc_unit *);
internal_proto(fbuf_reset);
-extern char * fbuf_alloc (gfc_unit *, int);
+extern char *fbuf_alloc (gfc_unit *, int);
internal_proto(fbuf_alloc);
extern int fbuf_flush (gfc_unit *, unit_mode);
extern int fbuf_seek (gfc_unit *, int, int);
internal_proto(fbuf_seek);
-extern char * fbuf_read (gfc_unit *, int *);
+extern char *fbuf_read (gfc_unit *, int *);
internal_proto(fbuf_read);
/* Never call this function, only use fbuf_getc(). */
internal_proto(fbuf_getc_refill);
static inline int
-fbuf_getc (gfc_unit * u)
+fbuf_getc (gfc_unit *u)
{
if (u->fbuf->pos < u->fbuf->act)
return (unsigned char) u->fbuf->buf[u->fbuf->pos++];
}
static inline char *
-fbuf_getptr (gfc_unit * u)
+fbuf_getptr (gfc_unit *u)
{
return (char*) (u->fbuf->buf + u->fbuf->pos);
}
/* format.c-- parse a FORMAT string into a binary format suitable for
- * interpretation during I/O statements */
+ interpretation during I/O statements. */
#include "io.h"
#include "format.h"
/* next_char()-- Return the next character in the format string.
- * Returns -1 when the string is done. If the literal flag is set,
- * spaces are significant, otherwise they are not. */
+ Returns -1 when the string is done. If the literal flag is set,
+ spaces are significant, otherwise they are not. */
static int
next_char (format_data *fmt, int literal)
/* get_fnode()-- Allocate a new format node, inserting it into the
- * current singly linked list. These are initially allocated from the
- * static buffer. */
+ current singly linked list. These are initially allocated from the
+ static buffer. */
static fnode *
get_fnode (format_data *fmt, fnode **head, fnode **tail, format_token t)
/* format_lex()-- Simple lexical analyzer for getting the next token
- * in a FORMAT string. We support a one-level token pushback in the
- * fmt->saved_token variable. */
+ in a FORMAT string. We support a one-level token pushback in the
+ fmt->saved_token variable. */
static format_token
format_lex (format_data *fmt)
/* parse_format_list()-- Parse a format list. Assumes that a left
- * paren has already been seen. Returns a list representing the
- * parenthesis node which contains the rest of the list. */
+ paren has already been seen. Returns a list representing the
+ parenthesis node which contains the rest of the list. */
static fnode *
parse_format_list (st_parameter_dt *dtp, bool *seen_dd)
/* format_error()-- Generate an error message for a format statement.
- * If the node that gives the location of the error is NULL, the error
- * is assumed to happen at parse time, and the current location of the
- * parser is shown.
- *
- * We generate a message showing where the problem is. We take extra
- * care to print only the relevant part of the format if it is longer
- * than a standard 80 column display. */
+ If the node that gives the location of the error is NULL, the error
+ is assumed to happen at parse time, and the current location of the
+ parser is shown.
+
+ We generate a message showing where the problem is. We take extra
+ care to print only the relevant part of the format if it is longer
+ than a standard 80 column display. */
void
format_error (st_parameter_dt *dtp, const fnode *f, const char *message)
/* revert()-- Do reversion of the format. Control reverts to the left
- * parenthesis that matches the rightmost right parenthesis. From our
- * tree structure, we are looking for the rightmost parenthesis node
- * at the second level, the first level always being a single
- * parenthesis node. If this node doesn't exit, we use the top
- * level. */
+ parenthesis that matches the rightmost right parenthesis. From our
+ tree structure, we are looking for the rightmost parenthesis node
+ at the second level, the first level always being a single
+ parenthesis node. If this node doesn't exit, we use the top
+ level. */
static void
revert (st_parameter_dt *dtp)
/* next_format0()-- Get the next format node without worrying about
- * reversion. Returns NULL when we hit the end of the list.
- * Parenthesis nodes are incremented after the list has been
- * exhausted, other nodes are incremented before they are returned. */
+ reversion. Returns NULL when we hit the end of the list.
+ Parenthesis nodes are incremented after the list has been
+ exhausted, other nodes are incremented before they are returned. */
static const fnode *
-next_format0 (fnode * f)
+next_format0 (fnode *f)
{
const fnode *r;
/* next_format()-- Return the next format node. If the format list
- * ends up being exhausted, we do reversion. Reversion is only
- * allowed if we've seen a data descriptor since the
- * initialization or the last reversion. We return NULL if there
- * are no more data descriptors to return (which is an error
- * condition). */
+ ends up being exhausted, we do reversion. Reversion is only
+ allowed if we've seen a data descriptor since the
+ initialization or the last reversion. We return NULL if there
+ are no more data descriptors to return (which is an error
+ condition). */
const fnode *
next_format (st_parameter_dt *dtp)
}
/* Push the first reverted token and return a colon node in case
- * there are no more data items. */
+ there are no more data items. */
fmt->saved_format = f;
return &colon_node;
/* unget_format()-- Push the given format back so that it will be
- * returned on the next call to next_format() without affecting
- * counts. This is necessary when we've encountered a data
- * descriptor, but don't know what the data item is yet. The format
- * node is pushed back, and we return control to the main program,
- * which calls the library back with the data item (or not). */
+ returned on the next call to next_format() without affecting
+ counts. This is necessary when we've encountered a data
+ descriptor, but don't know what the data item is yet. The format
+ node is pushed back, and we return control to the main program,
+ which calls the library back with the data item (or not). */
void
unget_format (st_parameter_dt *dtp, const fnode *f)
/* inquire_via_unit()-- Inquiry via unit number. The unit might not exist. */
static void
-inquire_via_unit (st_parameter_inquire *iqp, gfc_unit * u)
+inquire_via_unit (st_parameter_inquire *iqp, gfc_unit *u)
{
const char *p;
GFC_INTEGER_4 cf = iqp->common.flags;
/* inquire_via_filename()-- Inquiry via filename. This subroutine is
- * only used if the filename is *not* connected to a unit number. */
+ only used if the filename is *not* connected to a unit number. */
static void
inquire_via_filename (st_parameter_inquire *iqp)
export_proto_np(PREFIX(fgetc));
int
-PREFIX(fgetc) (const int * unit, char * c, gfc_charlen_type c_len)
+PREFIX(fgetc) (const int *unit, char *c, gfc_charlen_type c_len)
{
int ret;
- gfc_unit * u = find_unit (*unit);
+ gfc_unit *u = find_unit (*unit);
if (u == NULL)
return -1;
(const int *, char *, GFC_INTEGER_ ## kind *, gfc_charlen_type); \
export_proto(fgetc_i ## kind ## _sub); \
void fgetc_i ## kind ## _sub \
- (const int * unit, char * c, GFC_INTEGER_ ## kind * st, gfc_charlen_type c_len) \
+ (const int *unit, char *c, GFC_INTEGER_ ## kind *st, gfc_charlen_type c_len) \
{ if (st != NULL) \
*st = PREFIX(fgetc) (unit, c, c_len); \
else \
export_proto_np(PREFIX(fget));
int
-PREFIX(fget) (char * c, gfc_charlen_type c_len)
+PREFIX(fget) (char *c, gfc_charlen_type c_len)
{
return PREFIX(fgetc) (&five, c, c_len);
}
(char *, GFC_INTEGER_ ## kind *, gfc_charlen_type); \
export_proto(fget_i ## kind ## _sub); \
void fget_i ## kind ## _sub \
- (char * c, GFC_INTEGER_ ## kind * st, gfc_charlen_type c_len) \
+ (char *c, GFC_INTEGER_ ## kind *st, gfc_charlen_type c_len) \
{ if (st != NULL) \
*st = PREFIX(fgetc) (&five, c, c_len); \
else \
export_proto_np(PREFIX(fputc));
int
-PREFIX(fputc) (const int * unit, char * c,
+PREFIX(fputc) (const int *unit, char *c,
gfc_charlen_type c_len __attribute__((unused)))
{
ssize_t s;
- gfc_unit * u = find_unit (*unit);
+ gfc_unit *u = find_unit (*unit);
if (u == NULL)
return -1;
(const int *, char *, GFC_INTEGER_ ## kind *, gfc_charlen_type); \
export_proto(fputc_i ## kind ## _sub); \
void fputc_i ## kind ## _sub \
- (const int * unit, char * c, GFC_INTEGER_ ## kind * st, gfc_charlen_type c_len) \
+ (const int *unit, char *c, GFC_INTEGER_ ## kind *st, gfc_charlen_type c_len) \
{ if (st != NULL) \
*st = PREFIX(fputc) (unit, c, c_len); \
else \
export_proto_np(PREFIX(fput));
int
-PREFIX(fput) (char * c, gfc_charlen_type c_len)
+PREFIX(fput) (char *c, gfc_charlen_type c_len)
{
return PREFIX(fputc) (&six, c, c_len);
}
(char *, GFC_INTEGER_ ## kind *, gfc_charlen_type); \
export_proto(fput_i ## kind ## _sub); \
void fput_i ## kind ## _sub \
- (char * c, GFC_INTEGER_ ## kind * st, gfc_charlen_type c_len) \
+ (char *c, GFC_INTEGER_ ## kind *st, gfc_charlen_type c_len) \
{ if (st != NULL) \
*st = PREFIX(fputc) (&six, c, c_len); \
else \
export_proto(fseek_sub);
void
-fseek_sub (int * unit, GFC_IO_INT * offset, int * whence, int * status)
+fseek_sub (int *unit, GFC_IO_INT *offset, int *whence, int *status)
{
- gfc_unit * u = find_unit (*unit);
+ gfc_unit *u = find_unit (*unit);
ssize_t result = -1;
if (u != NULL)
static gfc_offset
gf_ftell (int unit)
{
- gfc_unit * u = find_unit (unit);
+ gfc_unit *u = find_unit (unit);
if (u == NULL)
return -1;
int pos = fbuf_reset (u);
export_proto_np(PREFIX(ftell));
GFC_IO_INT
-PREFIX(ftell) (int * unit)
+PREFIX(ftell) (int *unit)
{
return gf_ftell (*unit);
}
extern void ftell_i ## kind ## _sub (int *, GFC_INTEGER_ ## kind *); \
export_proto(ftell_i ## kind ## _sub); \
void \
- ftell_i ## kind ## _sub (int * unit, GFC_INTEGER_ ## kind * offset) \
+ ftell_i ## kind ## _sub (int *unit, GFC_INTEGER_ ## kind *offset) \
{ \
*offset = gf_ftell (*unit); \
}
export_proto(ttynam_sub);
void
-ttynam_sub (int *unit, char * name, gfc_charlen_type name_len)
+ttynam_sub (int *unit, char *name, gfc_charlen_type name_len)
{
gfc_unit *u;
int nlen;
export_proto(ttynam);
void
-ttynam (char ** name, gfc_charlen_type * name_len, int unit)
+ttynam (char **name, gfc_charlen_type *name_len, int unit)
{
gfc_unit *u;
what it is right away. */
static void
-read_complex (st_parameter_dt *dtp, void * dest, int kind, size_t size)
+read_complex (st_parameter_dt *dtp, void *dest, int kind, size_t size)
{
char message[MSGLEN];
int c;
/* Parse a real number with a possible repeat count. */
static void
-read_real (st_parameter_dt *dtp, void * dest, int length)
+read_real (st_parameter_dt *dtp, void *dest, int length)
{
char message[MSGLEN];
int c;
namelist_info **prev_nl, char *, size_t)
calls:
static void nml_untouch_nodes (st_parameter_dt *dtp)
- static namelist_info * find_nml_node (st_parameter_dt *dtp,
- char * var_name)
- static int nml_parse_qualifier(descriptor_dimension * ad,
- array_loop_spec * ls, int rank, char *)
- static void nml_touch_nodes (namelist_info * nl)
+ static namelist_info *find_nml_node (st_parameter_dt *dtp,
+ char *var_name)
+ static int nml_parse_qualifier(descriptor_dimension *ad,
+ array_loop_spec *ls, int rank, char *)
+ static void nml_touch_nodes (namelist_info *nl)
static int nml_read_obj (namelist_info *nl, index_type offset,
namelist_info **prev_nl, char *, size_t,
index_type clow, index_type chigh)
static namelist_info *
-find_nml_node (st_parameter_dt *dtp, char * var_name)
+find_nml_node (st_parameter_dt *dtp, char *var_name)
{
- namelist_info * t = dtp->u.p.ionml;
+ namelist_info *t = dtp->u.p.ionml;
while (t != NULL)
{
if (strcmp (var_name, t->var_name) == 0)
to default values */
static void
-nml_touch_nodes (namelist_info * nl)
+nml_touch_nodes (namelist_info *nl)
{
index_type len = strlen (nl->var_name) + 1;
int dim;
- char * ext_name = xmalloc (len + 1);
+ char *ext_name = xmalloc (len + 1);
memcpy (ext_name, nl->var_name, len-1);
memcpy (ext_name + len - 1, "%", 2);
for (nl = nl->next; nl; nl = nl->next)
static void
nml_untouch_nodes (st_parameter_dt *dtp)
{
- namelist_info * t;
+ namelist_info *t;
for (t = dtp->u.p.ionml; t; t = t->next)
t->touched = 0;
return;
static void
nml_query (st_parameter_dt *dtp, char c)
{
- gfc_unit * temp_unit;
- namelist_info * nl;
+ gfc_unit *temp_unit;
+ namelist_info *nl;
index_type len;
- char * p;
+ char *p;
#ifdef HAVE_CRLF
static const index_type endlen = 2;
static const char endl[] = "\r\n";
error. */
static bool
-nml_read_obj (st_parameter_dt *dtp, namelist_info * nl, index_type offset,
+nml_read_obj (st_parameter_dt *dtp, namelist_info *nl, index_type offset,
namelist_info **pprev_nl, char *nml_err_msg,
size_t nml_err_msg_size, index_type clow, index_type chigh)
{
- namelist_info * cmp;
- char * obj_name;
+ namelist_info *cmp;
+ char *obj_name;
int nml_carry;
int len;
int dim;
index_type dlen;
index_type m;
size_t obj_name_len;
- void * pdata;
+ void *pdata;
/* If we have encountered a previous read error or this object has not been
touched in name parsing, just return. */
char *nml_err_msg, size_t nml_err_msg_size)
{
int c;
- namelist_info * nl;
- namelist_info * first_nl = NULL;
- namelist_info * root_nl = NULL;
+ namelist_info *nl;
+ namelist_info *first_nl = NULL;
+ namelist_info *root_nl = NULL;
int dim, parsed_rank;
int component_flag, qualifier_flag;
index_type clow, chigh;
void
free_ionml (st_parameter_dt *dtp)
{
- namelist_info * t1, *t2;
+ namelist_info *t1, *t2;
/* Delete the namelist, if it exists. */
AT_ENDFILE. */
static void
-test_endfile (gfc_unit * u)
+test_endfile (gfc_unit *u)
{
if (u->endfile == NO_ENDFILE)
{
changed. */
static void
-edit_modes (st_parameter_open *opp, gfc_unit * u, unit_flags * flags)
+edit_modes (st_parameter_open *opp, gfc_unit *u, unit_flags *flags)
{
/* Complain about attempts to change the unchangeable. */
/* Open an unused unit. */
gfc_unit *
-new_unit (st_parameter_open *opp, gfc_unit *u, unit_flags * flags)
+new_unit (st_parameter_open *opp, gfc_unit *u, unit_flags *flags)
{
gfc_unit *u2;
stream *s;
modes or closing what is there now and opening the new file. */
static void
-already_open (st_parameter_open *opp, gfc_unit * u, unit_flags * flags)
+already_open (st_parameter_open *opp, gfc_unit *u, unit_flags *flags)
{
if ((opp->common.flags & IOPARM_OPEN_HAS_FILE) == 0)
{
}
/* eat_leading_spaces()-- Given a character pointer and a width,
- * ignore the leading spaces. */
+ ignore the leading spaces. */
static char *
eat_leading_spaces (int *width, char *p)
/* read_decimal()-- Read a decimal integer value. The values here are
- * signed values. */
+ signed values. */
void
read_decimal (st_parameter_dt *dtp, const fnode *f, char *dest, int length)
/* read_radix()-- This function reads values for non-decimal radixes.
- * The difference here is that we treat the values here as unsigned
- * values for the purposes of overflow. If minus sign is present and
- * the top bit is set, the value will be incorrect. */
+ The difference here is that we treat the values here as unsigned
+ values for the purposes of overflow. If minus sign is present and
+ the top bit is set, the value will be incorrect. */
void
read_radix (st_parameter_dt *dtp, const fnode *f, char *dest, int length,
/* read_x()-- Deal with the X/TR descriptor. We just read some data
- * and never look at it. */
+ and never look at it. */
void
read_x (st_parameter_dt *dtp, int n)
/* Read sequential file - internal unit */
static char *
-read_sf_internal (st_parameter_dt *dtp, int * length)
+read_sf_internal (st_parameter_dt *dtp, int *length)
{
static char *empty_string[0];
char *base = NULL;
/* Read sequential file - external unit */
static char *
-read_sf (st_parameter_dt *dtp, int * length)
+read_sf (st_parameter_dt *dtp, int *length)
{
static char *empty_string[0];
int q, q2;
short reads. */
void *
-read_block_form (st_parameter_dt *dtp, int * nbytes)
+read_block_form (st_parameter_dt *dtp, int *nbytes)
{
char *source;
int norig;
a character(kind=4) variable. Note: Portions of this code borrowed from
read_sf_internal. */
void *
-read_block_form4 (st_parameter_dt *dtp, int * nbytes)
+read_block_form4 (st_parameter_dt *dtp, int *nbytes)
{
static gfc_char4_t *empty_string[0];
gfc_char4_t *source;
value is same as for POSIX write(). */
static ssize_t
-sset (stream * s, int c, ssize_t nbyte)
+sset (stream *s, int c, ssize_t nbyte)
{
#define WRITE_CHUNK 256
char p[WRITE_CHUNK];
fbuf_seek (dtp->u.p.current_unit, 0, SEEK_END);
if (dtp->u.p.cc.len > 0)
{
- char * p = fbuf_alloc (dtp->u.p.current_unit, dtp->u.p.cc.len);
+ char *p = fbuf_alloc (dtp->u.p.current_unit, dtp->u.p.cc.len);
if (!p)
generate_error (&dtp->common, LIBERROR_OS, NULL);
fbuf_seek (dtp->u.p.current_unit, 0, SEEK_END);
if (dtp->u.p.current_unit->flags.cc != CC_NONE)
{
- char * p = fbuf_alloc (dtp->u.p.current_unit, len);
+ char *p = fbuf_alloc (dtp->u.p.current_unit, len);
if (!p)
goto io_error;
#ifdef HAVE_CRLF
in a linked list of namelist_info types. */
static void
-set_nml_var (st_parameter_dt *dtp, void * var_addr, char * var_name,
+set_nml_var (st_parameter_dt *dtp, void *var_addr, char *var_name,
GFC_INTEGER_4 len, gfc_charlen_type string_length,
GFC_INTEGER_4 dtype, void *dtio_sub, void *vtable)
{
export_proto(st_set_nml_var);
void
-st_set_nml_var (st_parameter_dt *dtp, void * var_addr, char * var_name,
+st_set_nml_var (st_parameter_dt *dtp, void *var_addr, char *var_name,
GFC_INTEGER_4 len, gfc_charlen_type string_length,
GFC_INTEGER_4 dtype)
{
void
-st_set_nml_dtio_var (st_parameter_dt *dtp, void * var_addr, char * var_name,
+st_set_nml_dtio_var (st_parameter_dt *dtp, void *var_addr, char *var_name,
GFC_INTEGER_4 len, gfc_charlen_type string_length,
GFC_INTEGER_4 dtype, void *dtio_sub, void *vtable)
{
index_type stride, index_type lbound,
index_type ubound)
{
- namelist_info * nml;
+ namelist_info *nml;
int n;
n = (int)n_dim;
9.10.2 in F2003. */
void
-hit_eof (st_parameter_dt * dtp)
+hit_eof (st_parameter_dt *dtp)
{
dtp->u.p.current_unit->flags.position = POSITION_APPEND;
/* This implementation is based on Stefan Nilsson's article in the
- * July 1997 Doctor Dobb's Journal, "Treaps in Java". */
+ July 1997 Doctor Dobb's Journal, "Treaps in Java". */
/* pseudo_random()-- Simple linear congruential pseudorandom number
- * generator. The period of this generator is 44071, which is plenty
- * for our purposes. */
+ generator. The period of this generator is 44071, which is plenty
+ for our purposes. */
static int
pseudo_random (void)
/* rotate_left()-- Rotate the treap left */
static gfc_unit *
-rotate_left (gfc_unit * t)
+rotate_left (gfc_unit *t)
{
gfc_unit *temp;
/* rotate_right()-- Rotate the treap right */
static gfc_unit *
-rotate_right (gfc_unit * t)
+rotate_right (gfc_unit *t)
{
gfc_unit *temp;
/* destroy_unit_mutex()-- Destroy the mutex and free memory of unit. */
static void
-destroy_unit_mutex (gfc_unit * u)
+destroy_unit_mutex (gfc_unit *u)
{
__gthread_mutex_destroy (&u->lock);
free (u);
static gfc_unit *
-delete_root (gfc_unit * t)
+delete_root (gfc_unit *t)
{
gfc_unit *temp;
/* delete_treap()-- Delete an element from a tree. The 'old' value
- * does not necessarily have to point to the element to be deleted, it
- * must just point to a treap structure with the key to be deleted.
- * Returns the new root node of the tree. */
+ does not necessarily have to point to the element to be deleted, it
+ must just point to a treap structure with the key to be deleted.
+ Returns the new root node of the tree. */
static gfc_unit *
-delete_treap (gfc_unit * old, gfc_unit * t)
+delete_treap (gfc_unit *old, gfc_unit *t)
{
int c;
/* delete_unit()-- Delete a unit from a tree */
static void
-delete_unit (gfc_unit * old)
+delete_unit (gfc_unit *old)
{
unit_root = delete_treap (old, unit_root);
}
/* get_gfc_unit()-- Given an integer, return a pointer to the unit
- * structure. Returns NULL if the unit does not exist,
- * otherwise returns a locked unit. */
+ structure. Returns NULL if the unit does not exist,
+ otherwise returns a locked unit. */
static gfc_unit *
get_gfc_unit (int n, int do_create)
gfc_unit *
get_unit (st_parameter_dt *dtp, int do_create)
{
- gfc_unit * unit;
+ gfc_unit *unit;
if ((dtp->common.flags & IOPARM_DT_HAS_INTERNAL_UNIT) != 0)
{
ftruncate, returns 0 on success, -1 on failure. */
int
-unit_truncate (gfc_unit * u, gfc_offset pos, st_parameter_common * common)
+unit_truncate (gfc_unit *u, gfc_offset pos, st_parameter_common *common)
{
int ret;
/* fix_fd()-- Given a file descriptor, make sure it is not one of the
- * standard descriptors, returning a non-standard descriptor. If the
- * user specifies that system errors should go to standard output,
- * then closes standard output, we don't want the system errors to a
- * file that has been given file descriptor 1 or 0. We want to send
- * the error to the invalid descriptor. */
+ standard descriptors, returning a non-standard descriptor. If the
+ user specifies that system errors should go to standard output,
+ then closes standard output, we don't want the system errors to a
+ file that has been given file descriptor 1 or 0. We want to send
+ the error to the invalid descriptor. */
static int
fix_fd (int fd)
corresponding C stream. This is bugware for mixed C-Fortran codes
where the C code doesn't flush I/O before returning. */
void
-flush_if_preconnected (stream * s)
+flush_if_preconnected (stream *s)
{
int fd;
*********************************************************************/
static int
-raw_flush (unix_stream * s __attribute__ ((unused)))
+raw_flush (unix_stream *s __attribute__ ((unused)))
{
return 0;
}
static ssize_t
-raw_read (unix_stream * s, void * buf, ssize_t nbyte)
+raw_read (unix_stream *s, void *buf, ssize_t nbyte)
{
/* For read we can't do I/O in a loop like raw_write does, because
that will break applications that wait for interactive I/O. We
}
static ssize_t
-raw_write (unix_stream * s, const void * buf, ssize_t nbyte)
+raw_write (unix_stream *s, const void *buf, ssize_t nbyte)
{
ssize_t trans, bytes_left;
char *buf_st;
}
static gfc_offset
-raw_seek (unix_stream * s, gfc_offset offset, int whence)
+raw_seek (unix_stream *s, gfc_offset offset, int whence)
{
while (true)
{
}
static gfc_offset
-raw_tell (unix_stream * s)
+raw_tell (unix_stream *s)
{
while (true)
{
}
static gfc_offset
-raw_size (unix_stream * s)
+raw_size (unix_stream *s)
{
struct stat statbuf;
if (TEMP_FAILURE_RETRY (fstat (s->fd, &statbuf)) == -1)
}
static int
-raw_truncate (unix_stream * s, gfc_offset length)
+raw_truncate (unix_stream *s, gfc_offset length)
{
#ifdef __MINGW32__
HANDLE h;
}
static int
-raw_close (unix_stream * s)
+raw_close (unix_stream *s)
{
int retval;
}
static int
-raw_markeor (unix_stream * s __attribute__ ((unused)))
+raw_markeor (unix_stream *s __attribute__ ((unused)))
{
return 0;
}
};
static int
-raw_init (unix_stream * s)
+raw_init (unix_stream *s)
{
s->st.vptr = &raw_vtable;
*********************************************************************/
static int
-buf_flush (unix_stream * s)
+buf_flush (unix_stream *s)
{
int writelen;
}
static ssize_t
-buf_read (unix_stream * s, void * buf, ssize_t nbyte)
+buf_read (unix_stream *s, void *buf, ssize_t nbyte)
{
if (s->active == 0)
s->buffer_offset = s->logical_offset;
}
static ssize_t
-buf_write (unix_stream * s, const void * buf, ssize_t nbyte)
+buf_write (unix_stream *s, const void *buf, ssize_t nbyte)
{
if (s->ndirty == 0)
s->buffer_offset = s->logical_offset;
when writing sequential unformatted. */
static int
-buf_markeor (unix_stream * s)
+buf_markeor (unix_stream *s)
{
if (s->unbuffered || s->ndirty >= BUFFER_SIZE / 2)
return buf_flush (s);
}
static gfc_offset
-buf_seek (unix_stream * s, gfc_offset offset, int whence)
+buf_seek (unix_stream *s, gfc_offset offset, int whence)
{
switch (whence)
{
}
static gfc_offset
-buf_tell (unix_stream * s)
+buf_tell (unix_stream *s)
{
return buf_seek (s, 0, SEEK_CUR);
}
static gfc_offset
-buf_size (unix_stream * s)
+buf_size (unix_stream *s)
{
return s->file_length;
}
static int
-buf_truncate (unix_stream * s, gfc_offset length)
+buf_truncate (unix_stream *s, gfc_offset length)
{
int r;
}
static int
-buf_close (unix_stream * s)
+buf_close (unix_stream *s)
{
if (buf_flush (s) != 0)
return -1;
};
static int
-buf_init (unix_stream * s)
+buf_init (unix_stream *s)
{
s->st.vptr = &buf_vtable;
*********************************************************************/
char *
-mem_alloc_r (stream * strm, int * len)
+mem_alloc_r (stream *strm, int *len)
{
- unix_stream * s = (unix_stream *) strm;
+ unix_stream *s = (unix_stream *) strm;
gfc_offset n;
gfc_offset where = s->logical_offset;
char *
-mem_alloc_r4 (stream * strm, int * len)
+mem_alloc_r4 (stream *strm, int *len)
{
- unix_stream * s = (unix_stream *) strm;
+ unix_stream *s = (unix_stream *) strm;
gfc_offset n;
gfc_offset where = s->logical_offset;
char *
-mem_alloc_w (stream * strm, int * len)
+mem_alloc_w (stream *strm, int *len)
{
- unix_stream * s = (unix_stream *) strm;
+ unix_stream *s = (unix_stream *)strm;
gfc_offset m;
gfc_offset where = s->logical_offset;
gfc_char4_t *
-mem_alloc_w4 (stream * strm, int * len)
+mem_alloc_w4 (stream *strm, int *len)
{
- unix_stream * s = (unix_stream *) strm;
+ unix_stream *s = (unix_stream *)strm;
gfc_offset m;
gfc_offset where = s->logical_offset;
gfc_char4_t *result = (gfc_char4_t *) s->buffer;
/* Stream read function for character(kind=1) internal units. */
static ssize_t
-mem_read (stream * s, void * buf, ssize_t nbytes)
+mem_read (stream *s, void *buf, ssize_t nbytes)
{
void *p;
int nb = nbytes;
/* Stream read function for chracter(kind=4) internal units. */
static ssize_t
-mem_read4 (stream * s, void * buf, ssize_t nbytes)
+mem_read4 (stream *s, void *buf, ssize_t nbytes)
{
void *p;
int nb = nbytes;
/* Stream write function for character(kind=1) internal units. */
static ssize_t
-mem_write (stream * s, const void * buf, ssize_t nbytes)
+mem_write (stream *s, const void *buf, ssize_t nbytes)
{
void *p;
int nb = nbytes;
/* Stream write function for character(kind=4) internal units. */
static ssize_t
-mem_write4 (stream * s, const void * buf, ssize_t nwords)
+mem_write4 (stream *s, const void *buf, ssize_t nwords)
{
gfc_char4_t *p;
int nw = nwords;
static gfc_offset
-mem_seek (stream * strm, gfc_offset offset, int whence)
+mem_seek (stream *strm, gfc_offset offset, int whence)
{
- unix_stream * s = (unix_stream *) strm;
+ unix_stream *s = (unix_stream *)strm;
switch (whence)
{
case SEEK_SET:
static gfc_offset
-mem_tell (stream * s)
+mem_tell (stream *s)
{
return ((unix_stream *)s)->logical_offset;
}
static int
-mem_truncate (unix_stream * s __attribute__ ((unused)),
+mem_truncate (unix_stream *s __attribute__ ((unused)),
gfc_offset length __attribute__ ((unused)))
{
return 0;
static int
-mem_flush (unix_stream * s __attribute__ ((unused)))
+mem_flush (unix_stream *s __attribute__ ((unused)))
{
return 0;
}
static int
-mem_close (unix_stream * s)
+mem_close (unix_stream *s)
{
free (s);
s->st.vptr = &mem4_vtable;
- return (stream *) s;
+ return (stream *)s;
}
/* fd_to_stream()-- Given an open file descriptor, build a stream
- * around it. */
+ around it. */
static stream *
fd_to_stream (int fd, bool unformatted)
slash = "";
/* Take care that the template is longer in the mktemp() branch. */
- char * template = xmalloc (tempdirlen + 23);
+ char *template = xmalloc (tempdirlen + 23);
#ifdef HAVE_MKSTEMP
snprintf (template, tempdirlen + 23, "%s%sgfortrantmpXXXXXX",
/* tempfile()-- Generate a temporary filename for a scratch file and
- * open it. mkstemp() opens the file for reading and writing, but the
- * library mode prevents anything that is not allowed. The descriptor
- * is returned, which is -1 on error. The template is pointed to by
- * opp->file, which is copied into the unit structure
- * and freed later. */
+ open it. mkstemp() opens the file for reading and writing, but the
+ library mode prevents anything that is not allowed. The descriptor
+ is returned, which is -1 on error. The template is pointed to by
+ opp->file, which is copied into the unit structure
+ and freed later. */
static int
tempfile (st_parameter_open *opp)
/* regular_file2()-- Open a regular file.
- * Change flags->action if it is ACTION_UNSPECIFIED on entry,
- * unless an error occurs.
- * Returns the descriptor, which is less than zero on error. */
+ Change flags->action if it is ACTION_UNSPECIFIED on entry,
+ unless an error occurs.
+ Returns the descriptor, which is less than zero on error. */
static int
regular_file2 (const char *path, st_parameter_open *opp, unit_flags *flags)
}
/* open_external()-- Open an external file, unix specific version.
- * Change flags->action if it is ACTION_UNSPECIFIED on entry.
- * Returns NULL on operating system error. */
+ Change flags->action if it is ACTION_UNSPECIFIED on entry.
+ Returns NULL on operating system error. */
stream *
open_external (st_parameter_open *opp, unit_flags *flags)
else
{
/* regular_file resets flags->action if it is ACTION_UNSPECIFIED and
- * if it succeeds */
+ if it succeeds */
fd = regular_file (opp, flags);
#ifndef O_CLOEXEC
set_close_on_exec (fd);
/* input_stream()-- Return a stream pointer to the default input stream.
- * Called on initialization. */
+ Called on initialization. */
stream *
input_stream (void)
/* output_stream()-- Return a stream pointer to the default output stream.
- * Called on initialization. */
+ Called on initialization. */
stream *
output_stream (void)
{
- stream * s;
+ stream *s;
#if defined(HAVE_CRLF) && defined(HAVE_SETMODE)
setmode (STDOUT_FILENO, O_BINARY);
/* error_stream()-- Return a stream pointer to the default error stream.
- * Called on initialization. */
+ Called on initialization. */
stream *
error_stream (void)
{
- stream * s;
+ stream *s;
#if defined(HAVE_CRLF) && defined(HAVE_SETMODE)
setmode (STDERR_FILENO, O_BINARY);
/* compare_file_filename()-- Given an open stream and a fortran string
- * that is a filename, figure out if the file is the same as the
- * filename. */
+ that is a filename, figure out if the file is the same as the
+ filename. */
int
compare_file_filename (gfc_unit *u, const char *name, int len)
char *path = fc_strdup (name, len);
/* If the filename doesn't exist, then there is no match with the
- * existing file. */
+ existing file. */
if (TEMP_FAILURE_RETRY (stat (path, &st)) < 0)
{
/* 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. */
+ that has the file already open. Returns a pointer to the unit if so. */
gfc_unit *
find_file (const char *file, gfc_charlen_type file_len)
/* file_exists()-- Returns nonzero if the current filename exists on
- * the system */
+ the system */
int
file_exists (const char *file, gfc_charlen_type file_len)
static const char yes[] = "YES", no[] = "NO", unknown[] = "UNKNOWN";
/* inquire_sequential()-- Given a fortran string, determine if the
- * file is suitable for sequential access. Returns a C-style
- * string. */
+ file is suitable for sequential access. Returns a C-style
+ string. */
const char *
inquire_sequential (const char *string, int len)
/* inquire_direct()-- Given a fortran string, determine if the file is
- * suitable for direct access. Returns a C-style string. */
+ suitable for direct access. Returns a C-style string. */
const char *
inquire_direct (const char *string, int len)
/* inquire_formatted()-- Given a fortran string, determine if the file
- * is suitable for formatted form. Returns a C-style string. */
+ is suitable for formatted form. Returns a C-style string. */
const char *
inquire_formatted (const char *string, int len)
/* inquire_unformatted()-- Given a fortran string, determine if the file
- * is suitable for unformatted form. Returns a C-style string. */
+ is suitable for unformatted form. Returns a C-style string. */
const char *
inquire_unformatted (const char *string, int len)
/* inquire_access()-- Given a fortran string, determine if the file is
- * suitable for access. */
+ suitable for access. */
static const char *
inquire_access (const char *string, int len, int mode)
/* inquire_read()-- Given a fortran string, determine if the file is
- * suitable for READ access. */
+ suitable for READ access. */
const char *
inquire_read (const char *string, int len)
/* inquire_write()-- Given a fortran string, determine if the file is
- * suitable for READ access. */
+ suitable for READ access. */
const char *
inquire_write (const char *string, int len)
/* inquire_readwrite()-- Given a fortran string, determine if the file is
- * suitable for read and write access. */
+ suitable for read and write access. */
const char *
inquire_readwrite (const char *string, int len)
int
stream_ttyname (stream *s __attribute__ ((unused)),
- char * buf __attribute__ ((unused)),
+ char *buf __attribute__ ((unused)),
size_t buflen __attribute__ ((unused)))
{
#ifdef HAVE_TTYNAME_R
- return ttyname_r (((unix_stream *) s)->fd, buf, buflen);
+ return ttyname_r (((unix_stream *)s)->fd, buf, buflen);
#elif defined HAVE_TTYNAME
char *p;
size_t plen;
- p = ttyname (((unix_stream *) s)->fd);
+ p = ttyname (((unix_stream *)s)->fd);
if (!p)
return errno;
plen = strlen (p);
/* Inline functions for doing file I/O given a stream. */
static inline ssize_t
-sread (stream * s, void * buf, ssize_t nbyte)
+sread (stream *s, void *buf, ssize_t nbyte)
{
return s->vptr->read (s, buf, nbyte);
}
static inline ssize_t
-swrite (stream * s, const void * buf, ssize_t nbyte)
+swrite (stream *s, const void *buf, ssize_t nbyte)
{
return s->vptr->write (s, buf, nbyte);
}
static inline gfc_offset
-sseek (stream * s, gfc_offset offset, int whence)
+sseek (stream *s, gfc_offset offset, int whence)
{
return s->vptr->seek (s, offset, whence);
}
static inline gfc_offset
-stell (stream * s)
+stell (stream *s)
{
return s->vptr->tell (s);
}
static inline gfc_offset
-ssize (stream * s)
+ssize (stream *s)
{
return s->vptr->size (s);
}
static inline int
-struncate (stream * s, gfc_offset length)
+struncate (stream *s, gfc_offset length)
{
return s->vptr->trunc (s, length);
}
static inline int
-sflush (stream * s)
+sflush (stream *s)
{
return s->vptr->flush (s);
}
static inline int
-sclose (stream * s)
+sclose (stream *s)
{
return s->vptr->close (s);
}
static inline int
-smarkeor (stream * s)
+smarkeor (stream *s)
{
return s->vptr->markeor (s);
}
extern stream *open_internal4 (char *, int, gfc_offset);
internal_proto(open_internal4);
-extern char * mem_alloc_w (stream *, int *);
+extern char *mem_alloc_w (stream *, int *);
internal_proto(mem_alloc_w);
-extern char * mem_alloc_r (stream *, int *);
+extern char *mem_alloc_r (stream *, int *);
internal_proto(mem_alloc_r);
-extern gfc_char4_t * mem_alloc_w4 (stream *, int *);
+extern gfc_char4_t *mem_alloc_w4 (stream *, int *);
internal_proto(mem_alloc_w4);
-extern char * mem_alloc_r4 (stream *, int *);
+extern char *mem_alloc_r4 (stream *, int *);
internal_proto(mem_alloc_r4);
extern stream *input_stream (void);
if (unlikely (is_char4_unit (dtp)))
{
- gfc_char4_t * p4 = (gfc_char4_t *) p;
+ gfc_char4_t *p4 = (gfc_char4_t *)p;
if (nblank < 0)
{
memset4 (p4, '*', w);
static namelist_info *
-nml_write_obj (st_parameter_dt *dtp, namelist_info * obj, index_type offset,
- namelist_info * base, char * base_name)
+nml_write_obj (st_parameter_dt *dtp, namelist_info *obj, index_type offset,
+ namelist_info *base, char *base_name)
{
int rep_ctr;
int num;
size_t clen;
index_type elem_ctr;
size_t obj_name_len;
- void * p;
+ void *p;
char cup;
- char * obj_name;
- char * ext_name;
- char * q;
+ char *obj_name;
+ char *ext_name;
+ char *q;
size_t ext_name_len;
char rep_buff[NML_DIGITS];
- namelist_info * cmp;
- namelist_info * retval = obj->next;
+ namelist_info *cmp;
+ namelist_info *retval = obj->next;
size_t base_name_len;
size_t base_var_name_len;
size_t tot_len;
if ((elem_ctr < (nelem - 1)) &&
(obj->type != BT_DERIVED) &&
- !memcmp (p, (void*)(p + obj_size ), obj_size ))
+ !memcmp (p, (void *)(p + obj_size ), obj_size ))
{
rep_ctr++;
}
void
namelist_write (st_parameter_dt *dtp)
{
- namelist_info * t1, *t2, *dummy = NULL;
+ namelist_info *t1, *t2, *dummy = NULL;
index_type i;
index_type dummy_offset = 0;
char c;
- char * dummy_name = NULL;
+ char *dummy_name = NULL;
/* Set the delimiter for namelist output. */
switch (dtp->u.p.current_unit->delim_status)