This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
gcc/fortran: 2007-05-01 Daniel Franke <franke.daniel@gmail.com>
PR fortran/22539 * intrinsic.c (add_subroutines): Added FSEEK. * intrinsic.h (gfc_resolve_fseek_sub, gfc_check_fseek_sub): New. * iresolve.c (gfc_resolve_fseek_sub): New. * check.c (gfc_check_fseek_sub): New. * intrinsic.texi (FSEEK): Updated.
libgfortran: 2007-05-01 Daniel Franke <franke.daniel@gmail.com>
PR fortran/22539 * io/intrinsics.c (fseek_sub): New. * gfortran.map (fseek_sub): New.
gcc/testsuite: 2007-05-01 Daniel Franke <franke.daniel@gmail.com>
PR fortran/22539 * gfortran.dg/fseek.f90: New test.
Regtested on i686-pc-linux-gnu, no regressions. Ok for mainline?
Index: intrinsic.texi
===================================================================
--- intrinsic.texi (revision 124320)
+++ intrinsic.texi (working copy)
@@ -3966,11 +3966,31 @@
@cindex file operation, seek
@cindex file operation, position
-Not yet implemented in GNU Fortran.
-
@table @asis
@item @emph{Description}:
+Attempts to move @var{UNIT} to the specified @var{OFFSET}. If @var{WHENCE} +is set to 0, the @var{OFFSET} is taken as an absolute value @code{SEEK_SET},
+if set to 1, @var{OFFSET} is taken to be relative to the current position +@code{SEEK_CUR}, and if set to 2 relative to the end of the file @code{SEEK_END}.
+On error, @var{STATUS} is set to a value unequal zero.
-@item @emph{Return value}:
+@multitable @columnfractions .15 .70
+@item @var{UNIT} @tab Shall be a scalar of type @code{INTEGER}.
+@item @var{OFFSET} @tab Shall be a scalar of type @code{INTEGER}.
+@item @var{WHENCE} @tab Shall be a scalar of type @code{INTEGER}.
+Its value shall be either 0, 1 or 2.
+@item @var{STATUS} @tab (Optional) shall be the be a scalar of +type @code{INTEGER}.
Index: io/intrinsics.c
===================================================================
--- io/intrinsics.c (revision 124260)
+++ io/intrinsics.c (working copy)
@@ -228,7 +228,34 @@
}
}
+/* FSEEK intrinsic */
+extern void fseek_sub (int *, GFC_IO_INT *, int *, int *);
+export_proto(fseek_sub);
+
+void
+fseek_sub (int * unit, GFC_IO_INT * offset, int * whence, int * status)
+{
+ gfc_unit * u = find_unit (*unit);
+
+ if (status) *status = 0;
+
+ if (u == NULL || !is_seekable(u->s))
+ {
+ if (status) *status = -1; /* EBADF */
+ }
+ else if (*whence == 0)
+ sseek(u->s, *offset); /* SEEK_SET */
+ else if (*whence == 1)
+ sseek(u->s, file_position(u->s) + *offset); /* SEEK_CUR */
+ else if (*whence == 2)
+ sseek(u->s, file_length(u->s) + *offset); /* SEEK_END */
+ else if (status)
+ *status = -1; /* EINVAL */
+}
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |