aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorTobias Burnus <burnus@net-b.de>2014-12-11 09:20:24 +0100
committerTobias Burnus <burnus@gcc.gnu.org>2014-12-11 09:20:24 +0100
commitc9db45aaf49be681ba6e16203ab4b455bfa9746e (patch)
treee31e886ed230649c1e858eb51f469565c87e1754 /gcc/fortran
parent01ca36af914385acfc864adfae6923768581888a (diff)
downloadgcc-c9db45aaf49be681ba6e16203ab4b455bfa9746e.zip
gcc-c9db45aaf49be681ba6e16203ab4b455bfa9746e.tar.gz
gcc-c9db45aaf49be681ba6e16203ab4b455bfa9746e.tar.bz2
diagnostic.c (get_terminal_width): Renamed from
2014-12-11 Tobias Burnus <burnus@net-b.de> Manuel López-Ibáñez <manu@gcc.gnu.org> gcc/ * diagnostic.c (get_terminal_width): Renamed from * getenv_columns, removed static, and additionally use ioctl to get width. (diagnostic_set_caret_max_width): Update call. * diagnostic.h (get_terminal_width): Add prototype. * opts.c (print_specific_help): Use it for x_help_columns. * doc/invoke.texi (fdiagnostics-show-caret): Document how the width is set. gcc/fortran/ * error.c (gfc_get_terminal_width): Renamed from get_terminal_width and use same-named common function. (gfc_error_init_1): Update call. Co-Authored-By: Manuel López-Ibáñez <manu@gcc.gnu.org> From-SVN: r218619
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/ChangeLog11
-rw-r--r--gcc/fortran/error.c38
2 files changed, 14 insertions, 35 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index cce4036..8534a45 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,14 @@
+2014-12-11 Tobias Burnus <burnus@net-b.de>
+ Manuel López-Ibáñez <manu@gcc.gnu.org>
+
+ * diagnostic.c (get_terminal_width): Renamed from getenv_columns,
+ removed static, and additionally use ioctl to get width.
+ (diagnostic_set_caret_max_width): Update call.
+ * diagnostic.h (get_terminal_width): Add prototype.
+ * opts.c (print_specific_help): Use it for x_help_columns.
+ * doc/invoke.texi (fdiagnostics-show-caret): Document how the
+ width is set.
+
2014-12-10 Bernd Edlinger <bernd.edlinger@hotmail.de>
PR fortran/60718
diff --git a/gcc/fortran/error.c b/gcc/fortran/error.c
index a93c7f9..851ba90 100644
--- a/gcc/fortran/error.c
+++ b/gcc/fortran/error.c
@@ -30,14 +30,6 @@ along with GCC; see the file COPYING3. If not see
#include "flags.h"
#include "gfortran.h"
-#ifdef HAVE_TERMIOS_H
-# include <termios.h>
-#endif
-
-#ifdef GWINSZ_IN_SYS_IOCTL
-# include <sys/ioctl.h>
-#endif
-
#include "diagnostic.h"
#include "diagnostic-color.h"
#include "tree-diagnostic.h" /* tree_diagnostics_defaults */
@@ -83,33 +75,9 @@ gfc_pop_suppress_errors (void)
/* Determine terminal width (for trimming source lines in output). */
static int
-get_terminal_width (void)
+gfc_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)
- {
- int value = atoi (p);
- if (value > 0)
- return value;
- }
-
- /* If both fail, use reasonable default. */
- return 80;
+ return isatty (STDERR_FILENO) ? get_terminal_width () : INT_MAX;
}
@@ -118,7 +86,7 @@ get_terminal_width (void)
void
gfc_error_init_1 (void)
{
- terminal_width = get_terminal_width ();
+ terminal_width = gfc_get_terminal_width ();
errors = 0;
warnings = 0;
gfc_buffer_error (false);