parent
5f02b9dbcd
commit
6a0f6e7799
|
@ -1,3 +1,16 @@
|
||||||
|
2011-01-27 Janne Blomqvist <jb@gcc.gnu.org>
|
||||||
|
|
||||||
|
PR libfortran/47432
|
||||||
|
* config.h.in: Regenerated.
|
||||||
|
* configure: Regenerated.
|
||||||
|
* configure.ac: Add check for ttyname_r.
|
||||||
|
* io/unix.h: Add TTY_NAME_MAX, change stream_ttyname prototype.
|
||||||
|
* io/unix.c (stream_ttyname): Use ttyname_r if available, conform
|
||||||
|
to new prototype.
|
||||||
|
* io/inquire.c (inquire_via_unit): Use changed stream_ttyname.
|
||||||
|
* io/intrinsics.c (ttynam_sub): Likewise.
|
||||||
|
(ttynam): Likewise.
|
||||||
|
|
||||||
2011-01-27 Janne Blomqvist <jb@gcc.gnu.org>
|
2011-01-27 Janne Blomqvist <jb@gcc.gnu.org>
|
||||||
|
|
||||||
PR libfortran/47491
|
PR libfortran/47491
|
||||||
|
|
|
@ -807,6 +807,9 @@
|
||||||
/* Define to 1 if you have the `ttyname' function. */
|
/* Define to 1 if you have the `ttyname' function. */
|
||||||
#undef HAVE_TTYNAME
|
#undef HAVE_TTYNAME
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `ttyname_r' function. */
|
||||||
|
#undef HAVE_TTYNAME_R
|
||||||
|
|
||||||
/* Define to 1 if the system has the type `uintptr_t'. */
|
/* Define to 1 if the system has the type `uintptr_t'. */
|
||||||
#undef HAVE_UINTPTR_T
|
#undef HAVE_UINTPTR_T
|
||||||
|
|
||||||
|
|
|
@ -16367,7 +16367,7 @@ _ACEOF
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
for ac_func in localtime_r gmtime_r strerror_r getpwuid_r
|
for ac_func in localtime_r gmtime_r strerror_r getpwuid_r ttyname_r
|
||||||
do :
|
do :
|
||||||
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
||||||
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
|
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
|
||||||
|
|
|
@ -251,7 +251,7 @@ AC_CHECK_FUNCS(chdir strerror getlogin gethostname kill link symlink perror)
|
||||||
AC_CHECK_FUNCS(sleep time ttyname signal alarm ctime clock access fork execl)
|
AC_CHECK_FUNCS(sleep time ttyname signal alarm ctime clock access fork execl)
|
||||||
AC_CHECK_FUNCS(wait setmode execvp pipe dup2 close fdopen strcasestr getrlimit)
|
AC_CHECK_FUNCS(wait setmode execvp pipe dup2 close fdopen strcasestr getrlimit)
|
||||||
AC_CHECK_FUNCS(gettimeofday stat fstat lstat getpwuid vsnprintf dup getcwd)
|
AC_CHECK_FUNCS(gettimeofday stat fstat lstat getpwuid vsnprintf dup getcwd)
|
||||||
AC_CHECK_FUNCS(localtime_r gmtime_r strerror_r getpwuid_r)
|
AC_CHECK_FUNCS(localtime_r gmtime_r strerror_r getpwuid_r ttyname_r)
|
||||||
|
|
||||||
# Check for glibc backtrace functions
|
# Check for glibc backtrace functions
|
||||||
AC_CHECK_FUNCS(backtrace backtrace_symbols)
|
AC_CHECK_FUNCS(backtrace backtrace_symbols)
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* Copyright (C) 2002, 2003, 2005, 2007, 2009, 2010
|
/* Copyright (C) 2002, 2003, 2005, 2007, 2009, 2010, 2011
|
||||||
Free Software Foundation, Inc.
|
Free Software Foundation, Inc.
|
||||||
Contributed by Andy Vaught
|
Contributed by Andy Vaught
|
||||||
|
|
||||||
This file is part of the GNU Fortran 95 runtime library (libgfortran).
|
This file is part of the GNU Fortran runtime library (libgfortran).
|
||||||
|
|
||||||
Libgfortran is free software; you can redistribute it and/or modify
|
Libgfortran is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -68,16 +68,17 @@ inquire_via_unit (st_parameter_inquire *iqp, gfc_unit * u)
|
||||||
if ((cf & IOPARM_INQUIRE_HAS_NAME) != 0
|
if ((cf & IOPARM_INQUIRE_HAS_NAME) != 0
|
||||||
&& u != NULL && u->flags.status != STATUS_SCRATCH)
|
&& u != NULL && u->flags.status != STATUS_SCRATCH)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_TTYNAME
|
#if defined(HAVE_TTYNAME_R) || defined(HAVE_TTYNAME)
|
||||||
if (u->unit_number == options.stdin_unit
|
if (u->unit_number == options.stdin_unit
|
||||||
|| u->unit_number == options.stdout_unit
|
|| u->unit_number == options.stdout_unit
|
||||||
|| u->unit_number == options.stderr_unit)
|
|| u->unit_number == options.stderr_unit)
|
||||||
{
|
{
|
||||||
char * tmp = stream_ttyname (u->s);
|
int err = stream_ttyname (u->s, iqp->name, iqp->name_len);
|
||||||
if (tmp != NULL)
|
if (err == 0)
|
||||||
{
|
{
|
||||||
int tmplen = strlen (tmp);
|
gfc_charlen_type tmplen = strlen (iqp->name);
|
||||||
fstrcpy (iqp->name, iqp->name_len, tmp, tmplen);
|
if (iqp->name_len > tmplen)
|
||||||
|
memset (&iqp->name[tmplen], ' ', iqp->name_len - tmplen);
|
||||||
}
|
}
|
||||||
else /* If ttyname does not work, go with the default. */
|
else /* If ttyname does not work, go with the default. */
|
||||||
fstrcpy (iqp->name, iqp->name_len, u->file, u->file_len);
|
fstrcpy (iqp->name, iqp->name_len, u->file, u->file_len);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/* Implementation of the FGET, FGETC, FPUT, FPUTC, FLUSH
|
/* Implementation of the FGET, FGETC, FPUT, FPUTC, FLUSH
|
||||||
FTELL, TTYNAM and ISATTY intrinsics.
|
FTELL, TTYNAM and ISATTY intrinsics.
|
||||||
Copyright (C) 2005, 2007, 2009, 2010 Free Software Foundation, Inc.
|
Copyright (C) 2005, 2007, 2009, 2010, 2011 Free Software
|
||||||
|
Foundation, Inc.
|
||||||
|
|
||||||
This file is part of the GNU Fortran runtime library (libgfortran).
|
This file is part of the GNU Fortran runtime library (libgfortran).
|
||||||
|
|
||||||
|
@ -351,22 +352,23 @@ void
|
||||||
ttynam_sub (int *unit, char * name, gfc_charlen_type name_len)
|
ttynam_sub (int *unit, char * name, gfc_charlen_type name_len)
|
||||||
{
|
{
|
||||||
gfc_unit *u;
|
gfc_unit *u;
|
||||||
char * n;
|
int nlen;
|
||||||
int i;
|
int err = 1;
|
||||||
|
|
||||||
memset (name, ' ', name_len);
|
|
||||||
u = find_unit (*unit);
|
u = find_unit (*unit);
|
||||||
if (u != NULL)
|
if (u != NULL)
|
||||||
{
|
{
|
||||||
n = stream_ttyname (u->s);
|
err = stream_ttyname (u->s, name, name_len);
|
||||||
if (n != NULL)
|
if (err == 0)
|
||||||
{
|
{
|
||||||
i = 0;
|
nlen = strlen (name);
|
||||||
while (*n && i < name_len)
|
memset (&name[nlen], ' ', name_len - nlen);
|
||||||
name[i++] = *(n++);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unlock_unit (u);
|
unlock_unit (u);
|
||||||
}
|
}
|
||||||
|
if (err != 0)
|
||||||
|
memset (name, ' ', name_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -381,14 +383,15 @@ ttynam (char ** name, gfc_charlen_type * name_len, int unit)
|
||||||
u = find_unit (unit);
|
u = find_unit (unit);
|
||||||
if (u != NULL)
|
if (u != NULL)
|
||||||
{
|
{
|
||||||
*name = stream_ttyname (u->s);
|
*name = get_mem (TTY_NAME_MAX);
|
||||||
if (*name != NULL)
|
int err = stream_ttyname (u->s, *name, TTY_NAME_MAX);
|
||||||
|
if (err == 0)
|
||||||
{
|
{
|
||||||
*name_len = strlen (*name);
|
*name_len = strlen (*name);
|
||||||
*name = strdup (*name);
|
|
||||||
unlock_unit (u);
|
unlock_unit (u);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
free (*name);
|
||||||
unlock_unit (u);
|
unlock_unit (u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1811,18 +1811,29 @@ stream_isatty (stream *s)
|
||||||
return isatty (((unix_stream *) s)->fd);
|
return isatty (((unix_stream *) s)->fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
int
|
||||||
#ifdef HAVE_TTYNAME
|
stream_ttyname (stream *s __attribute__ ((unused)),
|
||||||
stream_ttyname (stream *s)
|
char * buf __attribute__ ((unused)),
|
||||||
|
size_t buflen __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
return ttyname (((unix_stream *) s)->fd);
|
#ifdef HAVE_TTYNAME_R
|
||||||
}
|
return ttyname_r (((unix_stream *) s)->fd, buf, buflen);
|
||||||
|
#elif defined HAVE_TTYNAME
|
||||||
|
char *p;
|
||||||
|
size_t plen;
|
||||||
|
p = ttyname (((unix_stream *) s)->fd);
|
||||||
|
if (!p)
|
||||||
|
return errno;
|
||||||
|
plen = strlen (p);
|
||||||
|
if (buflen < plen)
|
||||||
|
plen = buflen;
|
||||||
|
memcpy (buf, p, plen);
|
||||||
|
return 0;
|
||||||
#else
|
#else
|
||||||
stream_ttyname (stream *s __attribute__ ((unused)))
|
return ENOSYS;
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -170,7 +170,16 @@ internal_proto(flush_if_preconnected);
|
||||||
extern int stream_isatty (stream *);
|
extern int stream_isatty (stream *);
|
||||||
internal_proto(stream_isatty);
|
internal_proto(stream_isatty);
|
||||||
|
|
||||||
extern char * stream_ttyname (stream *);
|
#ifndef TTY_NAME_MAX
|
||||||
|
#ifdef _POSIX_TTY_NAME_MAX
|
||||||
|
#define TTY_NAME_MAX _POSIX_TTY_NAME_MAX
|
||||||
|
#else
|
||||||
|
/* sysconf(_SC_TTY_NAME_MAX) = 32 which should be enough. */
|
||||||
|
#define TTY_NAME_MAX 32
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern int stream_ttyname (stream *, char *, size_t);
|
||||||
internal_proto(stream_ttyname);
|
internal_proto(stream_ttyname);
|
||||||
|
|
||||||
extern int unpack_filename (char *, const char *, int);
|
extern int unpack_filename (char *, const char *, int);
|
||||||
|
|
Loading…
Reference in New Issue