[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc-fortran
Subject:    Re: [Patch, Fortran] Better error messages for type/rank checks
From:       Mikael Morin <mikael.morin () sfr ! fr>
Date:       2013-05-31 20:53:16
Message-ID: 51A90DBC.40101 () sfr ! fr
[Download RAW message or body]

Le 31/05/2013 14:28, Janus Weil a écrit :
>> Wouldn't it work to use the TIOCGWINSZ ioctl only if isatty() reports
>> that we're outputting to a terminal?
> 
> Good point. Updated patch attached, which imposes no limit if we're
> not outputting to a terminal (as suggested by Mikael).
> 
> Ok for trunk, or am I missing anything else? (Testing welcome ...)
> 
> Cheers,
> Janus
> 
> Index: gcc/fortran/error.c
> ===================================================================
> --- gcc/fortran/error.c	(revision 199530)
> +++ gcc/fortran/error.c	(working copy)
> @@ -30,6 +30,13 @@ along with GCC; see the file COPYING3.  If not see
>  #include "flags.h"
>  #include "gfortran.h"
>  
> +#if !(defined (_WIN32) || defined (VMS) || defined (__vxworks) || \
> +      defined (__Lynx__) || defined (__ANDROID__))
We should better use autoconf rather than hard-coding platforms here.

> +/* UNIX-like systems */
> +#include <sys/ioctl.h>
> +#endif
> +
> +
>  static int suppress_errors = 0;
>  
>  static int warnings_not_errors = 0; 
> @@ -59,9 +66,24 @@ gfc_pop_suppress_errors (void)
>  }
>  
>  
> +/* Determine terminal width (for trimming source lines in output).  */
> +
>  static int
>  get_terminal_width (void)
>  {
> +  /* Only limit the width if we're outputting to a terminal.  */
> +  if (!isatty (STDERR_FILENO))
> +    return INT_MAX;
Guard it with HAVE_UNISTD_H or HAVE_ISATTY ?

> +  
> +  /* Method #1: Use ioctl (not available on all systems).  */
> +#ifdef TIOCGWINSZ
> +  struct winsize w;
> +  ioctl (0, TIOCGWINSZ, &w);
You should check the ioctl result.  I bet it returns non-zero in
Manfred's (pathological) case...
Actually, I have just checked; it does.

The rest looks good.
Mikael
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic