-/* Copyright (C) 2002, 2003, 2005, 2007, 2009 Free Software Foundation, Inc.
+/* Copyright (C) 2002, 2003, 2005, 2007, 2009, 2010
+ Free Software Foundation, Inc.
Contributed by Andy Vaught
This file is part of the GNU Fortran 95 runtime library (libgfortran).
#include "io.h"
#include "unix.h"
+#include <string.h>
static const char undefined[] = "UNDEFINED";
if ((cf & IOPARM_INQUIRE_HAS_NAME) != 0
&& u != NULL && u->flags.status != STATUS_SCRATCH)
+ {
+#ifdef HAVE_TTYNAME
+ if (u->unit_number == options.stdin_unit
+ || u->unit_number == options.stdout_unit
+ || u->unit_number == options.stderr_unit)
+ {
+ char * tmp = ttyname (((unix_stream *) u->s)->fd);
+ if (tmp != NULL)
+ {
+ int tmplen = strlen (tmp);
+ fstrcpy (iqp->name, iqp->name_len, tmp, tmplen);
+ }
+ else /* If ttyname does not work, go with the default. */
+ fstrcpy (iqp->name, iqp->name_len, u->file, u->file_len);
+ }
+ else
+ fstrcpy (iqp->name, iqp->name_len, u->file, u->file_len);
+#elif defined __MINGW32__
+ if (u->unit_number == options.stdin_unit)
+ fstrcpy (iqp->name, iqp->name_len, "CONIN$", sizeof("CONIN$"));
+ else if (u->unit_number == options.stdout_unit)
+ fstrcpy (iqp->name, iqp->name_len, "CONOUT$", sizeof("CONOUT$"));
+ else if (u->unit_number == options.stderr_unit)
+ fstrcpy (iqp->name, iqp->name_len, "CONERR$", sizeof("CONERR$"));
+ else
+ fstrcpy (iqp->name, iqp->name_len, u->file, u->file_len);
+#else
fstrcpy (iqp->name, iqp->name_len, u->file, u->file_len);
+#endif
+ }
if ((cf & IOPARM_INQUIRE_HAS_ACCESS) != 0)
{