summaryrefslogtreecommitdiffstats
path: root/libgfortran
diff options
context:
space:
mode:
authorjb <jb@138bc75d-0d04-0410-961f-82ee72b054a4>2010-04-01 20:51:45 +0000
committerjb <jb@138bc75d-0d04-0410-961f-82ee72b054a4>2010-04-01 20:51:45 +0000
commit8c3cef8bfc0bf78036a71395783cbf998a0972b1 (patch)
tree8d1943a03f30a22bbdc1e27eb7d77d0ac4227a38 /libgfortran
parent19cd92661a45396936b4b64ae487b7e3d68d2a02 (diff)
downloadppe42-gcc-8c3cef8bfc0bf78036a71395783cbf998a0972b1.tar.gz
ppe42-gcc-8c3cef8bfc0bf78036a71395783cbf998a0972b1.zip
PR libfortran/43605 FTELL intrinsic, take 2.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@157932 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog7
-rw-r--r--libgfortran/io/intrinsics.c31
2 files changed, 23 insertions, 15 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index a57e53aabf2..d0985674a18 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,10 @@
+2010-04-01 Janne Blomqvist <jb@gcc.gnu.org>
+
+ PR libfortran/43605
+ * io/intrinsics.c (gf_ftell): New function, seek to correct offset.
+ (ftell): Call gf_ftell.
+ (FTELL_SUB): Likewise.
+
2010-04-01 Paul Thomas <pault@gcc.gnu.org>
* io/transfer.c : Update copyright.
diff --git a/libgfortran/io/intrinsics.c b/libgfortran/io/intrinsics.c
index 4beb0135c86..f2f532b9291 100644
--- a/libgfortran/io/intrinsics.c
+++ b/libgfortran/io/intrinsics.c
@@ -260,19 +260,27 @@ fseek_sub (int * unit, GFC_IO_INT * offset, int * whence, int * status)
/* FTELL intrinsic */
+static gfc_offset
+gf_ftell (int unit)
+{
+ gfc_unit * u = find_unit (unit);
+ if (u == NULL)
+ return -1;
+ int pos = fbuf_reset (u);
+ if (pos != 0)
+ sseek (u->s, pos, SEEK_CUR);
+ gfc_offset ret = stell (u->s);
+ unlock_unit (u);
+ return ret;
+}
+
extern size_t PREFIX(ftell) (int *);
export_proto_np(PREFIX(ftell));
size_t
PREFIX(ftell) (int * unit)
{
- gfc_unit * u = find_unit (*unit);
- gfc_offset ret;
- if (u == NULL)
- return ((size_t) -1);
- ret = stell (u->s) + fbuf_reset (u);
- unlock_unit (u);
- return ret;
+ return gf_ftell (*unit);
}
#define FTELL_SUB(kind) \
@@ -281,14 +289,7 @@ PREFIX(ftell) (int * unit)
void \
ftell_i ## kind ## _sub (int * unit, GFC_INTEGER_ ## kind * offset) \
{ \
- gfc_unit * u = find_unit (*unit); \
- if (u == NULL) \
- *offset = -1; \
- else \
- { \
- *offset = stell (u->s) + fbuf_reset (u); \
- unlock_unit (u); \
- } \
+ *offset = gf_ftell (*unit); \
}
FTELL_SUB(1)
OpenPOWER on IntegriCloud