]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
pretty-print: Don't translate escape sequences to windows console API
authorPeter Damianov <peter0x44@disroot.org>
Mon, 3 Jun 2024 17:07:10 +0000 (10:07 -0700)
committerJonathan Yong <10walls@gmail.com>
Sun, 16 Jun 2024 01:40:26 +0000 (01:40 +0000)
Modern versions of windows (after windows 10 v1511) support VT100 escape
sequences, so translation for them is not necessary. The translation also
mangles embedded warning documentation links.

gcc/ChangeLog:
* pretty-print.cc (mingw_ansi_fputs): Don't translate escape sequences if
the console has ENABLE_VIRTUAL_TERMINAL_PROCESSING.

Signed-off-by: Peter Damianov <peter0x44@disroot.org>
gcc/pretty-print.cc

index 639e2b8815868e683722855b82a1cddbf65a9dd1..ec44172f24df579c1a957f6ec22750fd1e183ff8 100644 (file)
@@ -674,8 +674,9 @@ mingw_ansi_fputs (const char *str, FILE *fp)
   /* Don't mess up stdio functions with Windows APIs.  */
   fflush (fp);
 
-  if (GetConsoleMode (h, &mode))
-    /* If it is a console, translate ANSI escape codes as needed.  */
+  if (GetConsoleMode (h, &mode) && !(mode & ENABLE_VIRTUAL_TERMINAL_PROCESSING))
+    /* If it is a console, and doesn't support ANSI escape codes, translate
+       them as needed.  */
     for (;;)
       {
        if ((esc_code = find_esc_head (&prefix_len, &esc_head, read)) == 0)