public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: console: Revise the code checking if the console is legacy. Date: Wed, 13 Nov 2019 09:28:00 -0000 [thread overview] Message-ID: <20191113092833.67436.qmail@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=8f8522c82a43c926119a5764ff009e4e5c26bbdf commit 8f8522c82a43c926119a5764ff009e4e5c26bbdf Author: Takashi Yano <takashi.yano@nifty.ne.jp> Date: Wed Nov 13 03:04:59 2019 +0900 Cygwin: console: Revise the code checking if the console is legacy. - Accessing shared_console_info before initializing causes access violation in checking if the console is legacy mode. This patch fixes this issue. This solves the problem reported in: https://www.cygwin.com/ml/cygwin-patches/2019-q4/msg00099.html Diff: --- winsup/cygwin/fhandler_console.cc | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc index d875ad6..0b1c82f 100644 --- a/winsup/cygwin/fhandler_console.cc +++ b/winsup/cygwin/fhandler_console.cc @@ -56,6 +56,7 @@ details. */ #define srBottom ((con.scroll_region.Bottom < 0) ? \ con.b.srWindow.Bottom : \ con.b.srWindow.Top + con.scroll_region.Bottom) +#define con_is_legacy (shared_console_info && con.is_legacy) const unsigned fhandler_console::MAX_WRITE_CHARS = 16384; @@ -309,7 +310,7 @@ fhandler_console::set_cursor_maybe () { con.fillin (get_output_handle ()); /* Nothing to do for xterm compatible mode. */ - if (wincap.has_con_24bit_colors () && !con.is_legacy) + if (wincap.has_con_24bit_colors () && !con_is_legacy) return; if (con.dwLastCursorPosition.X != con.b.dwCursorPosition.X || con.dwLastCursorPosition.Y != con.b.dwCursorPosition.Y) @@ -349,7 +350,7 @@ fhandler_console::send_winch_maybe () { con.scroll_region.Top = 0; con.scroll_region.Bottom = -1; - if (wincap.has_con_24bit_colors () && !con.is_legacy) + if (wincap.has_con_24bit_colors () && !con_is_legacy) fix_tab_position (get_output_handle (), con.dwWinSize.X); get_ttyp ()->kill_pgrp (SIGWINCH); return true; @@ -483,7 +484,7 @@ sig_exit: fhandler_console::input_states fhandler_console::process_input_message (void) { - if (wincap.has_con_24bit_colors () && !con.is_legacy) + if (wincap.has_con_24bit_colors () && !con_is_legacy) { DWORD dwMode; /* Enable xterm compatible mode in input */ @@ -589,7 +590,7 @@ fhandler_console::process_input_message (void) } /* Allow Ctrl-Space to emit ^@ */ else if (input_rec[i].Event.KeyEvent.wVirtualKeyCode - == ((wincap.has_con_24bit_colors () && !con.is_legacy) ? + == ((wincap.has_con_24bit_colors () && !con_is_legacy) ? '2' : VK_SPACE) && (ctrl_key_state & CTRL_PRESSED) && !(ctrl_key_state & ALT_PRESSED)) @@ -1029,7 +1030,7 @@ fhandler_console::open (int flags, mode_t) else con.is_legacy = false; /* Enable xterm compatible mode in input */ - if (!con.is_legacy) + if (!con_is_legacy) { GetConsoleMode (get_handle (), &dwMode); dwMode |= ENABLE_VIRTUAL_TERMINAL_INPUT; @@ -1037,14 +1038,14 @@ fhandler_console::open (int flags, mode_t) con.is_legacy = true; } extern int sawTERM; - if (con.is_legacy && !sawTERM) + if (con_is_legacy && !sawTERM) setenv ("TERM", "cygwin", 1); } DWORD cflags; if (GetConsoleMode (get_handle (), &cflags)) SetConsoleMode (get_handle (), ENABLE_WINDOW_INPUT - | ((wincap.has_con_24bit_colors () && !con.is_legacy) ? + | ((wincap.has_con_24bit_colors () && !con_is_legacy) ? 0 : ENABLE_MOUSE_INPUT) | cflags); @@ -1074,7 +1075,7 @@ fhandler_console::close () output_mutex = NULL; if (shared_console_info && getpid () == con.owner && - wincap.has_con_24bit_colors () && !con.is_legacy) + wincap.has_con_24bit_colors () && !con_is_legacy) { DWORD dwMode; /* Disable xterm compatible mode in input */ @@ -1221,7 +1222,7 @@ fhandler_console::output_tcsetattr (int, struct termios const *t) acquire_output_mutex (INFINITE); DWORD flags = ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT; /* If system has 24 bit color capability, use xterm compatible mode. */ - if (wincap.has_con_24bit_colors () && !con.is_legacy) + if (wincap.has_con_24bit_colors () && !con_is_legacy) { flags |= ENABLE_VIRTUAL_TERMINAL_PROCESSING; if (!(t->c_oflag & OPOST) || !(t->c_oflag & ONLCR)) @@ -1286,10 +1287,10 @@ fhandler_console::input_tcsetattr (int, struct termios const *t) } flags |= ENABLE_WINDOW_INPUT | - ((wincap.has_con_24bit_colors () && !con.is_legacy) ? + ((wincap.has_con_24bit_colors () && !con_is_legacy) ? 0 : ENABLE_MOUSE_INPUT); /* if system has 24 bit color capability, use xterm compatible mode. */ - if (wincap.has_con_24bit_colors () && !con.is_legacy) + if (wincap.has_con_24bit_colors () && !con_is_legacy) flags |= ENABLE_VIRTUAL_TERMINAL_INPUT; int res; @@ -1663,7 +1664,7 @@ bool fhandler_console::write_console (PWCHAR buf, DWORD len, DWORD& done) { bool need_fix_tab_position = false; /* Check if screen will be alternated. */ - if (wincap.has_con_24bit_colors () && !con.is_legacy + if (wincap.has_con_24bit_colors () && !con_is_legacy && memmem (buf, len*sizeof (WCHAR), L"\033[?1049", 7*sizeof (WCHAR))) need_fix_tab_position = true; @@ -2511,7 +2512,7 @@ fhandler_console::write_normal (const unsigned char *src, memset (&ps, 0, sizeof ps); while (found < end && found - src < CONVERT_LIMIT - && ((wincap.has_con_24bit_colors () && !con.is_legacy) + && ((wincap.has_con_24bit_colors () && !con_is_legacy) || base_chars[*found] == NOR) ) { switch (ret = f_mbtowc (_REENT, NULL, (const char *) found, @@ -2972,7 +2973,7 @@ fhandler_console::fixup_after_fork_exec (bool execing) { set_unit (); setup_io_mutex (); - if (wincap.has_con_24bit_colors () && !con.is_legacy) + if (wincap.has_con_24bit_colors () && !con_is_legacy) { DWORD dwMode; /* Disable xterm compatible mode in input */
reply other threads:[~2019-11-13 9:28 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20191113092833.67436.qmail@sourceware.org \ --to=corinna@sourceware.org \ --cc=cygwin-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).