[Patch, Fortran] Detecting the terminal width
Janus Weil
janus@gcc.gnu.org
Sat Jun 1 08:42:00 GMT 2013
>> 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.
Ok. Unfortunately I'm not much of a autoconf hero (better to say: not
at all). Is the new patch in the attachment sufficient (probably not
...)? I can not test it on my system with --enable-maintainer-mode
because I get:
configure.ac:2: error: Please use exactly Autoconf 2.64 instead of 2.69.
Why on earth does GCC require an old autoconf version?
>> +/* 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 ?
Done.
>> + /* 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...
Also done.
> The rest looks good.
Thanks for the feedback, Mikael. New patch attached ...
Cheers,
Janus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: terminal_width_v3.diff
Type: application/octet-stream
Size: 1798 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20130601/421b940b/attachment.obj>
More information about the Fortran
mailing list