Commit db0d1bae by Liu Hao Committed by Jonathan Yong

pretty-print.c [_WIN32] (colorize_init): Remove.

2017-10-11  Liu Hao  <lh_mouse@126.com>

	* pretty-print.c [_WIN32] (colorize_init): Remove.  Use
	the generic version below instead.
	(should_colorize): Recognize Windows consoles as terminals
	for MinGW targets.
	* pretty-print.c [__MINGW32__] (write_all): New function.
	[__MINGW32__] (find_esc_head): Likewise.
	[__MINGW32__] (find_esc_terminator): Likewise.
	[__MINGW32__] (eat_esc_sequence): Likewise.
	[__MINGW32__] (mingw_ansi_fputs): New function that handles
	ANSI escape codes.
	(pp_write_text_to_stream): Use mingw_ansi_fputs instead of fputs
	for MinGW targets.

From-SVN: r253645
parent 85866209
2017-10-11 Liu Hao <lh_mouse@126.com>
* pretty-print.c [_WIN32] (colorize_init): Remove. Use
the generic version below instead.
(should_colorize): Recognize Windows consoles as terminals
for MinGW targets.
* pretty-print.c [__MINGW32__] (write_all): New function.
[__MINGW32__] (find_esc_head): Likewise.
[__MINGW32__] (find_esc_terminator): Likewise.
[__MINGW32__] (eat_esc_sequence): Likewise.
[__MINGW32__] (mingw_ansi_fputs): New function that handles
ANSI escape codes.
(pp_write_text_to_stream): Use mingw_ansi_fputs instead of fputs
for MinGW targets.
2017-10-11 Richard Biener <rguenther@suse.de> 2017-10-11 Richard Biener <rguenther@suse.de>
* tree-ssa-loop-niter.c (infer_loop_bounds_from_pointer_arith): * tree-ssa-loop-niter.c (infer_loop_bounds_from_pointer_arith):
...@@ -20,6 +20,10 @@ ...@@ -20,6 +20,10 @@
#include "system.h" #include "system.h"
#include "diagnostic-color.h" #include "diagnostic-color.h"
#ifdef __MINGW32__
# include <windows.h>
#endif
/* Select Graphic Rendition (SGR, "\33[...m") strings. */ /* Select Graphic Rendition (SGR, "\33[...m") strings. */
/* Also Erase in Line (EL) to Right ("\33[K") by default. */ /* Also Erase in Line (EL) to Right ("\33[K") by default. */
/* Why have EL to Right after SGR? /* Why have EL to Right after SGR?
...@@ -275,23 +279,28 @@ parse_gcc_colors (void) ...@@ -275,23 +279,28 @@ parse_gcc_colors (void)
return true; return true;
} }
#if defined(_WIN32)
bool
colorize_init (diagnostic_color_rule_t)
{
return false;
}
#else
/* Return true if we should use color when in auto mode, false otherwise. */ /* Return true if we should use color when in auto mode, false otherwise. */
static bool static bool
should_colorize (void) should_colorize (void)
{ {
#ifdef __MINGW32__
/* For consistency reasons, one should check the handle returned by
_get_osfhandle(_fileno(stderr)) because the function
pp_write_text_to_stream() in pretty-print.c calls fputs() on
that stream. However, the code below for non-Windows doesn't seem
to care about it either... */
HANDLE h;
DWORD m;
h = GetStdHandle (STD_ERROR_HANDLE);
return (h != INVALID_HANDLE_VALUE) && (h != NULL)
&& GetConsoleMode (h, &m);
#else
char const *t = getenv ("TERM"); char const *t = getenv ("TERM");
return t && strcmp (t, "dumb") != 0 && isatty (STDERR_FILENO); return t && strcmp (t, "dumb") != 0 && isatty (STDERR_FILENO);
#endif
} }
bool bool
colorize_init (diagnostic_color_rule_t rule) colorize_init (diagnostic_color_rule_t rule)
{ {
...@@ -310,4 +319,3 @@ colorize_init (diagnostic_color_rule_t rule) ...@@ -310,4 +319,3 @@ colorize_init (diagnostic_color_rule_t rule)
gcc_unreachable (); gcc_unreachable ();
} }
} }
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment