aboutsummaryrefslogtreecommitdiff
path: root/libgfortran/io/fbuf.h
diff options
context:
space:
mode:
authorJanne Blomqvist <jb@gcc.gnu.org>2018-01-07 12:17:52 +0200
committerJanne Blomqvist <jb@gcc.gnu.org>2018-01-07 12:17:52 +0200
commitea99ec5bd62c0d14023aac0316f4286193db9434 (patch)
tree36694f3e28c6ca161e719f0dc4e69779533ff1fa /libgfortran/io/fbuf.h
parentc7c9468a6c1e21bb140f62d97d427352d90556bc (diff)
PR 78534, 83704 Handle large formatted I/O
In order to handle large characters when doing formatted I/O, use size_t and ptrdiff_t for lengths. Compared to the previous patch, based on discussions on IRC use size_t for sizes that don't need to be negative rather than ptrdiff_t everywhere. Regtested on x86_64-pc-linux-gnu, approved as part of the PR 78534 approval, committed to trunk. libgfortran/ChangeLog: 2018-01-07 Janne Blomqvist <jb@gcc.gnu.org> PR fortran/78534 PR fortran/83704 * io/fbuf.c (fbuf_init): Use size_t instead of int for length. (fbuf_debug): Convert debug output to unsigned long. (fbuf_reset): Use ptrdiff_t for return value. (fbuf_alloc): Use size_t for length argument. (fbuf_flush): Handle large buffers. (fbuf_flush_list): Likewise. (fbuf_seek): Use ptrdiff_t for offset and return value. (fbuf_read): Use size_t for length argument. (fbuf_getc_refill): Use size_t to match fbuf_read. * io/fbuf.h (struct fbuf): Use size_t for lengths. (fbuf_init): Use size_t instead of int for length. (fbuf_reset): Use ptrdiff_t for return value. (fbuf_alloc): Use size_t for length argument. (fbuf_seek): Use ptrdiff_t for offset and return value. (fbuf_read): Use size_t for length argument. * io/io.h (read_block_form): Likewise. (read_block_form4): Likewise. (write_block): Likewise. (read_a): Likewise. (read_a_char4): Likewise. (read_x): Likewise. (write_a): Likewise. (write_a_char4): Likewise. * io/list_read.c (list_formatted_read_scalar): Use size_t to handle large buffers. * io/read.c (read_l): Likewise. (read_utf8): Likewise. (read_utf8_char1): Likewise. (read_default_char1): Likewise. (read_utf8_char4): Likewise. (read_default_char4): Likewise. (read_a): Likewise. (read_a_char4): Likewise. (eat_leading_spaces): Likewise. (next_char): Likewise. (read_decimal): Likewise. (read_radix): Likewise. (read_f): Likewise. (read_x): Likewise. * io/transfer.c (read_sf_internal): Likewise. (read_sf): Likewise. (read_block_form): Likewise. (read_block_form4): Likewise. (write_block): Likewise. (formatted_transfer_scalar_write): Likewise. (next_record_w): Likewise. * io/unix.c (mem_alloc_r): Likewise. (mem_alloc_r4): Likewise. (mem_alloc_w): Likewise. (mem_alloc_w4): Likewise. (mem_read): Likewise. (mem_read4): Likewise. (mem_write): Likewise. (mem_write4): Likewise. (open_internal): Likewise. (open_internal4): Likewise. * io/unix.h (open_internal): Likewise. (open_internal4): Likewise. (mem_alloc_w): Likewise. (mem_alloc_r): Likewise. (mem_alloc_w4): Likewise. (mem_alloc_r4): Likewise. * io/write.c (write_check_cc): Likewise. (write_cc): Likewise. (write_a): Likewise. (write_a_char4): Likewise. From-SVN: r256322
Diffstat (limited to 'libgfortran/io/fbuf.h')
-rw-r--r--libgfortran/io/fbuf.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/libgfortran/io/fbuf.h b/libgfortran/io/fbuf.h
index 8dd94dbc08e..71b6d0fcccf 100644
--- a/libgfortran/io/fbuf.h
+++ b/libgfortran/io/fbuf.h
@@ -39,21 +39,21 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
struct fbuf
{
char *buf; /* Start of buffer. */
- int len; /* Length of buffer. */
- int act; /* Active bytes in buffer. */
- int pos; /* Current position in buffer. */
+ size_t len; /* Length of buffer. */
+ size_t act; /* Active bytes in buffer. */
+ size_t pos; /* Current position in buffer. */
};
-extern void fbuf_init (gfc_unit *, int);
+extern void fbuf_init (gfc_unit *, size_t);
internal_proto(fbuf_init);
extern void fbuf_destroy (gfc_unit *);
internal_proto(fbuf_destroy);
-extern int fbuf_reset (gfc_unit *);
+extern ptrdiff_t fbuf_reset (gfc_unit *);
internal_proto(fbuf_reset);
-extern char *fbuf_alloc (gfc_unit *, int);
+extern char *fbuf_alloc (gfc_unit *, size_t);
internal_proto(fbuf_alloc);
extern int fbuf_flush (gfc_unit *, unit_mode);
@@ -62,10 +62,10 @@ internal_proto(fbuf_flush);
extern int fbuf_flush_list (gfc_unit *, unit_mode);
internal_proto(fbuf_flush_list);
-extern int fbuf_seek (gfc_unit *, int, int);
+extern ptrdiff_t fbuf_seek (gfc_unit *, ptrdiff_t, int);
internal_proto(fbuf_seek);
-extern char *fbuf_read (gfc_unit *, int *);
+extern char *fbuf_read (gfc_unit *, size_t *);
internal_proto(fbuf_read);
/* Never call this function, only use fbuf_getc(). */