This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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]

[patch,commited] Add configure check for ttyname()


Some platforms (MinGW, for example) don't have ttyname(). I added a configure check and use the new HAVE_TTYNAME macro to protect the call to this function.

Commited as obvious after testing on i686-linux and i386-mingw32, on mainline and 4.0.

FX
Index: libgfortran/ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libgfortran/ChangeLog,v
retrieving revision 1.291
diff -p -u -r1.291 ChangeLog
--- libgfortran/ChangeLog	2 Sep 2005 13:29:51 -0000	1.291
+++ libgfortran/ChangeLog	2 Sep 2005 20:09:12 -0000
@@ -1,3 +1,11 @@
+2005-09-02  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
+
+	* io/unix.c (stream_ttyname): Protect use of ttyname by
+	HAVE_TTYNAME macro.
+	* configure.ac: Add check for ttyname.
+	* config.h.in: Regenerate.
+	* configure: Regenerate.
+
 2005-09-02  Andreas Jaeger  <aj@suse.de>
 
 	* libgfortran.h: Add prototype for init_compile_options.
Index: libgfortran/config.h.in
===================================================================
RCS file: /cvs/gcc/gcc/libgfortran/config.h.in,v
retrieving revision 1.23
diff -p -u -r1.23 config.h.in
--- libgfortran/config.h.in	27 Aug 2005 16:01:51 -0000	1.23
+++ libgfortran/config.h.in	2 Sep 2005 20:09:12 -0000
@@ -288,6 +288,9 @@
 /* libm includes truncf */
 #undef HAVE_TRUNCF
 
+/* Define to 1 if you have the `ttyname' function. */
+#undef HAVE_TTYNAME
+
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
 
Index: libgfortran/configure
===================================================================
RCS file: /cvs/gcc/gcc/libgfortran/configure,v
retrieving revision 1.41
diff -p -u -r1.41 configure
--- libgfortran/configure	27 Aug 2005 16:01:51 -0000	1.41
+++ libgfortran/configure	2 Sep 2005 20:09:12 -0000
@@ -7409,7 +7409,8 @@ done
 
 
 
-for ac_func in sleep time
+
+for ac_func in sleep time ttyname
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
 echo "$as_me:$LINENO: checking for $ac_func" >&5
Index: libgfortran/configure.ac
===================================================================
RCS file: /cvs/gcc/gcc/libgfortran/configure.ac,v
retrieving revision 1.31
diff -p -u -r1.31 configure.ac
--- libgfortran/configure.ac	27 Aug 2005 16:01:53 -0000	1.31
+++ libgfortran/configure.ac	2 Sep 2005 20:09:12 -0000
@@ -171,7 +171,7 @@ AC_CHECK_LIB([m],[csin],[need_math="no"]
 # Check for library functions.
 AC_CHECK_FUNCS(getrusage times mkstemp strtof strtold snprintf ftruncate chsize)
 AC_CHECK_FUNCS(chdir strerror getlogin gethostname kill link symlink perror)
-AC_CHECK_FUNCS(sleep time)
+AC_CHECK_FUNCS(sleep time ttyname)
 
 # Check libc for getgid, getpid, getuid
 AC_CHECK_LIB([c],[getgid],[AC_DEFINE([HAVE_GETGID],[1],[libc includes getgid])])
Index: libgfortran/io/unix.c
===================================================================
RCS file: /cvs/gcc/gcc/libgfortran/io/unix.c,v
retrieving revision 1.35
diff -p -u -r1.35 unix.c
--- libgfortran/io/unix.c	27 Aug 2005 16:01:54 -0000	1.35
+++ libgfortran/io/unix.c	2 Sep 2005 20:09:12 -0000
@@ -1548,7 +1548,11 @@ stream_isatty (stream *s)
 char *
 stream_ttyname (stream *s)
 {
+#ifdef HAVE_TTYNAME
   return ttyname (((unix_stream *) s)->fd);
+#else
+  return NULL;
+#endif
 }
 
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]