From patchwork Sat Jun 1 15:33:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mikael Morin X-Patchwork-Id: 248082 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id DC4142C007B for ; Sun, 2 Jun 2013 01:34:28 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; q=dns; s=default; b=e0ZSfCtm7Jr0OW/wT GHWnWAhgQ23md74XvpS3Ej2Qq+1uP+ZS/EX7OOYvnUQSPI+LcrzrS+CX9sfg+jR3 q9iiNLAa7nj4k7Vsz2aoUl3PV02Y9ePCL04BLpM0U2ba1Opx3HVeNOBjaQtHblvw v03dhzcF0lsyPGsKMNRTCrptzg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; s=default; bh=mw9lN1TB825OPOlqXnOrME+ Q/YY=; b=io8hHIDBa4PfNgSvYPD2qu7t2/5j2e8+8XBDXExW6+HW4Z8q7negQvb XPP0G/mHJJR40UH+TbLBna/bcYKhSkXEGHVe8OMo7IYqsbMdH5hbagyiEyBezTMb EFkyqj9xFVIQPcRu/OdbPyxCxnUJTB3RLMVKNMd5TqmMTUk41qqg= Received: (qmail 32366 invoked by alias); 1 Jun 2013 15:34:17 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 32331 invoked by uid 89); 1 Jun 2013 15:34:17 -0000 X-Spam-SWARE-Status: No, score=-3.1 required=5.0 tests=AWL, BAYES_00, KHOP_THREADED, RCVD_IN_DNSWL_NONE, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.1 X-Spam-User: qpsmtpd, 3 recipients Received: from smtp22.services.sfr.fr (HELO smtp22.services.sfr.fr) (93.17.128.10) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Sat, 01 Jun 2013 15:34:15 +0000 Received: from filter.sfr.fr (localhost [127.0.0.1]) by msfrf2221.sfr.fr (SMTP Server) with ESMTP id 97E777000050; Sat, 1 Jun 2013 17:34:12 +0200 (CEST) Received: from [192.168.1.58] (209.183.72.86.rev.sfr.net [86.72.183.209]) by msfrf2221.sfr.fr (SMTP Server) with ESMTP id E7BE77000059; Sat, 1 Jun 2013 17:34:11 +0200 (CEST) X-SFR-UUID: 20130601153411949.E7BE77000059@msfrf2221.sfr.fr Message-ID: <51AA143B.7080401@sfr.fr> Date: Sat, 01 Jun 2013 17:33:15 +0200 From: Mikael Morin User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130530 Thunderbird/17.0.6 MIME-Version: 1.0 To: Janus Weil CC: Janne Blomqvist , Manfred Schwarb , Tobias Burnus , gfortran , gcc-patches Subject: Re: [Patch, Fortran] Detecting the terminal width References: In-Reply-To: X-Virus-Found: No Le 01/06/2013 10:42, Janus Weil a écrit : > Ok. Unfortunately I'm not much of a autoconf hero (better to say: not > at all). Any person using autoconf is some of a hero. ;-) > 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? There is an answer here: http://gcc.gnu.org/ml/gcc-help/2011-01/msg00248.html The bottom line is: GCC versions the generated files, so require exactly one autoconf. And I suppose it just hasn't been updated to require the latest one. > New patch attached ... Tobias doesn't seem to argue (too much) against it, so OK. Attached is what I get with autoconf-2.64/automake-1.11.1 Thanks Mikael Index: config.in =================================================================== --- config.in (révision 199575) +++ config.in (copie de travail) @@ -199,6 +199,12 @@ #endif +/* Define to 1 if `TIOCGWINSZ' requires . */ +#ifndef USED_FOR_TARGET +#undef GWINSZ_IN_SYS_IOCTL +#endif + + /* mcontext_t fields start with __ */ #ifndef USED_FOR_TARGET #undef HAS_MCONTEXT_T_UNDERSCORES @@ -1247,7 +1253,7 @@ #endif -/* Define if your AIX linker supports a large TOC. */ +/* Define if your PowerPC64 linker supports a large TOC. */ #ifndef USED_FOR_TARGET #undef HAVE_LD_LARGE_TOC #endif Index: configure =================================================================== --- configure (révision 199575) +++ configure (copie de travail) @@ -8293,6 +8293,66 @@ $as_echo "#define HAVE_SYS_WAIT_H 1" >>confdefs.h fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether termios.h defines TIOCGWINSZ" >&5 +$as_echo_n "checking whether termios.h defines TIOCGWINSZ... " >&6; } +if test "${ac_cv_sys_tiocgwinsz_in_termios_h+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#ifdef TIOCGWINSZ + yes +#endif + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "yes" >/dev/null 2>&1; then : + ac_cv_sys_tiocgwinsz_in_termios_h=yes +else + ac_cv_sys_tiocgwinsz_in_termios_h=no +fi +rm -f conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_tiocgwinsz_in_termios_h" >&5 +$as_echo "$ac_cv_sys_tiocgwinsz_in_termios_h" >&6; } + +if test $ac_cv_sys_tiocgwinsz_in_termios_h != yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether sys/ioctl.h defines TIOCGWINSZ" >&5 +$as_echo_n "checking whether sys/ioctl.h defines TIOCGWINSZ... " >&6; } +if test "${ac_cv_sys_tiocgwinsz_in_sys_ioctl_h+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#ifdef TIOCGWINSZ + yes +#endif + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "yes" >/dev/null 2>&1; then : + ac_cv_sys_tiocgwinsz_in_sys_ioctl_h=yes +else + ac_cv_sys_tiocgwinsz_in_sys_ioctl_h=no +fi +rm -f conftest* + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_tiocgwinsz_in_sys_ioctl_h" >&5 +$as_echo "$ac_cv_sys_tiocgwinsz_in_sys_ioctl_h" >&6; } + + if test $ac_cv_sys_tiocgwinsz_in_sys_ioctl_h = yes; then + +$as_echo "#define GWINSZ_IN_SYS_IOCTL 1" >>confdefs.h + + fi +fi + for ac_header in limits.h stddef.h string.h strings.h stdlib.h time.h iconv.h \ fcntl.h unistd.h sys/file.h sys/time.h sys/mman.h \ sys/resource.h sys/param.h sys/times.h sys/stat.h \ @@ -17834,7 +17894,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 17837 "configure" +#line 17897 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -17940,7 +18000,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 17943 "configure" +#line 18003 "configure" #include "confdefs.h" #if HAVE_DLFCN_H Index: configure.ac =================================================================== --- configure.ac (révision 199575) +++ configure.ac (copie de travail) @@ -939,6 +939,7 @@ AC_HEADER_STDC AC_HEADER_TIME ACX_HEADER_STRING AC_HEADER_SYS_WAIT +AC_HEADER_TIOCGWINSZ AC_CHECK_HEADERS(limits.h stddef.h string.h strings.h stdlib.h time.h iconv.h \ fcntl.h unistd.h sys/file.h sys/time.h sys/mman.h \ sys/resource.h sys/param.h sys/times.h sys/stat.h \ Index: fortran/error.c =================================================================== --- fortran/error.c (révision 199575) +++ fortran/error.c (copie de travail) @@ -30,6 +30,15 @@ along with GCC; see the file COPYING3. If not see #include "flags.h" #include "gfortran.h" +#ifdef HAVE_TERMIOS_H +# include +#endif + +#ifdef GWINSZ_IN_SYS_IOCTL +# include +#endif + + static int suppress_errors = 0; static int warnings_not_errors = 0; @@ -59,9 +68,26 @@ 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. */ +#ifdef HAVE_UNISTD_H + if (!isatty (STDERR_FILENO)) + return INT_MAX; +#endif + + /* Method #1: Use ioctl (not available on all systems). */ +#ifdef TIOCGWINSZ + struct winsize w; + w.ws_col = 0; + if (ioctl (0, TIOCGWINSZ, &w) == 0 && w.ws_col > 0) + return w.ws_col; +#endif + + /* Method #2: Query environment variable $COLUMNS. */ const char *p = getenv ("COLUMNS"); if (p) { @@ -69,7 +95,8 @@ get_terminal_width (void) if (value > 0) return value; } - /* Use a reasonable default. */ + + /* If both fail, use reasonable default. */ return 80; }