]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR 44931 Move struct unix_stream to unix.c
authorJanne Blomqvist <jb@gcc.gnu.org>
Thu, 4 Nov 2010 19:29:28 +0000 (21:29 +0200)
committerJanne Blomqvist <jb@gcc.gnu.org>
Thu, 4 Nov 2010 19:29:28 +0000 (21:29 +0200)
From-SVN: r166325

libgfortran/ChangeLog
libgfortran/io/inquire.c
libgfortran/io/unix.c
libgfortran/io/unix.h

index 2e134c715457b2aedf7626b4439b9d529b03ff9f..f7fe9e1d39128199e0d1a9f2fcf2d291c3378ada 100644 (file)
@@ -1,3 +1,12 @@
+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.
+
 2010-11-04  Janne Blomqvist  <jb@gcc.gnu.org>
 
        * io/unix.h (struct unix_stream): Remove prot member.
index c4994ed179a28b6e93dfca5cb929ff978f3858c7..24481ccccbe7773df290068420cd7752eb934e32 100644 (file)
@@ -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);
index d3def10a1d89bcdfef48839769af816caa11e6ea..e55af18a1bfe958ca9f9e880d12dd8a93ee795f6 100644 (file)
@@ -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,
index 563b77ee0ced9cd14fa85db948a2410736d1413f..0e147aab565c2aa3bae795f3969a2e65ff9ca013 100644 (file)
@@ -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)