* [Patch, libfortran, committed] Move struct unix_stream back from unix.h to unix.c
@ 2010-11-04 19:39 Janne Blomqvist
0 siblings, 0 replies; only message in thread
From: Janne Blomqvist @ 2010-11-04 19:39 UTC (permalink / raw)
To: Fortran List, GCC Patches
[-- Attachment #1: Type: text/plain, Size: 596 bytes --]
Hi,
r162667 moved the definition of struct unix_stream from unix.c to
unix.h so that ttyname() could be used in inquire.c. The attached
patch moves the struct back and instead calls stream_ttyname() in
inquire.c. Committed r166325 as obvious.
2010-11-04 Janne Blomqvist <jb@gcc.gnu.org>
PR libfortran/44931
* io/inquire.c (inquire_via_unit): Use stream_ttyname() instead of
calling ttyname() directly.
* io/unix.h (unix_stream): Move struct to unix.c.
* io/unix.c: Move struct unix_stream here.
(stream_ttyname): Don't mark the argument as unused if it is used.
--
Janne Blomqvist
[-- Attachment #2: move-unix_stream.diff --]
[-- Type: text/x-patch, Size: 2975 bytes --]
diff --git a/libgfortran/io/inquire.c b/libgfortran/io/inquire.c
index c4994ed..24481cc 100644
--- a/libgfortran/io/inquire.c
+++ b/libgfortran/io/inquire.c
@@ -73,7 +73,7 @@ inquire_via_unit (st_parameter_inquire *iqp, gfc_unit * u)
|| u->unit_number == options.stdout_unit
|| u->unit_number == options.stderr_unit)
{
- char * tmp = ttyname (((unix_stream *) u->s)->fd);
+ char * tmp = stream_ttyname (u->s);
if (tmp != NULL)
{
int tmplen = strlen (tmp);
diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c
index d3def10..e55af18 100644
--- a/libgfortran/io/unix.c
+++ b/libgfortran/io/unix.c
@@ -167,6 +167,27 @@ fallback_access (const char *path, int mode)
static const int BUFFER_SIZE = 8192;
+typedef struct
+{
+ stream st;
+
+ gfc_offset buffer_offset; /* File offset of the start of the buffer */
+ gfc_offset physical_offset; /* Current physical file offset */
+ gfc_offset logical_offset; /* Current logical file offset */
+ gfc_offset file_length; /* Length of the file, -1 if not seekable. */
+
+ char *buffer; /* Pointer to the buffer. */
+ int fd; /* The POSIX file descriptor. */
+
+ int active; /* Length of valid bytes in the buffer */
+
+ int ndirty; /* Dirty bytes starting at buffer_offset */
+
+ int special_file; /* =1 if the fd refers to a special file */
+}
+unix_stream;
+
+
/* 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,
@@ -1786,14 +1807,18 @@ stream_isatty (stream *s)
}
char *
-stream_ttyname (stream *s __attribute__ ((unused)))
-{
#ifdef HAVE_TTYNAME
+stream_ttyname (stream *s)
+{
return ttyname (((unix_stream *) s)->fd);
+}
#else
+stream_ttyname (stream *s __attribute__ ((unused)))
+{
return NULL;
-#endif
}
+#endif
+
/* How files are stored: This is an operating-system specific issue,
diff --git a/libgfortran/io/unix.h b/libgfortran/io/unix.h
index 563b77e..0e147aa 100644
--- a/libgfortran/io/unix.h
+++ b/libgfortran/io/unix.h
@@ -42,27 +42,6 @@ struct stream
};
-typedef struct
-{
- stream st;
-
- gfc_offset buffer_offset; /* File offset of the start of the buffer */
- gfc_offset physical_offset; /* Current physical file offset */
- gfc_offset logical_offset; /* Current logical file offset */
- gfc_offset file_length; /* Length of the file, -1 if not seekable. */
-
- char *buffer; /* Pointer to the buffer. */
- int fd; /* The POSIX file descriptor. */
-
- int active; /* Length of valid bytes in the buffer */
-
- int ndirty; /* Dirty bytes starting at buffer_offset */
-
- int special_file; /* =1 if the fd refers to a special file */
-}
-unix_stream;
-
-
/* Inline functions for doing file I/O given a stream. */
static inline ssize_t
sread (stream * s, void * buf, ssize_t nbyte)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-11-04 19:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-04 19:39 [Patch, libfortran, committed] Move struct unix_stream back from unix.h to unix.c Janne Blomqvist
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).