diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 3fb523210..a74484ea3 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2009-09-30 Corinna Vinschen + + * fhandler_console.cc (beep): Move up to avoid forward declaration. + (fhandler_console::read): Just beep on characters invalid in current + charset. Add comment. + 2009-09-29 Eric Blake * syscalls.cc (rename): Fix regression in rename("dir","d/"). diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc index 251a8279a..632ec1dcb 100644 --- a/winsup/cygwin/fhandler_console.cc +++ b/winsup/cygwin/fhandler_console.cc @@ -58,6 +58,23 @@ static console_state NO_COPY *shared_console_info; dev_console NO_COPY *fhandler_console::dev_state; +static void +beep () +{ + reg_key r (HKEY_CURRENT_USER, KEY_ALL_ACCESS, "AppEvents", "Schemes", "Apps", + ".Default", ".Default", ".Current", NULL); + if (r.created ()) + { + char *buf = NULL; + UINT len = GetWindowsDirectory (buf, 0); + buf = (char *) alloca (len += sizeof ("\\media\\ding.wav")); + UINT res = GetWindowsDirectory (buf, len); + if (res && res <= len) + r.set_string ("", strcat (buf, "\\media\\ding.wav")); + } + MessageBeep (MB_OK); +} + /* Allocate and initialize the shared record for the current console. Returns a pointer to shared_console_info. */ tty_min * @@ -350,7 +367,18 @@ fhandler_console::read (void *pv, size_t& buflen) && ((control_key_state & CTRL_PRESSED) == 0 || (wch <= 0x1f || wch == 0x7f)); if (!meta) - toadd = tmp + 1; + { + /* Determine if the character is in the current multibyte + charset. The test is easy. If the multibyte sequence + is > 1 and the first byte is ASCII CAN, the character + has been translated into the ASCII CAN + UTF-8 replacement + sequence. If so, just ignore the keypress. + FIXME: Is there a better solution? */ + if (nread > 1 && tmp[1] == 0x18) + beep (); + else + toadd = tmp + 1; + } else if (dev_state->metabit) { tmp[1] |= 0x80; @@ -1415,23 +1443,6 @@ bad_escape: } } -static void -beep () -{ - reg_key r (HKEY_CURRENT_USER, KEY_ALL_ACCESS, "AppEvents", "Schemes", "Apps", - ".Default", ".Default", ".Current", NULL); - if (r.created ()) - { - char *buf = NULL; - UINT len = GetWindowsDirectory (buf, 0); - buf = (char *) alloca (len += sizeof ("\\media\\ding.wav")); - UINT res = GetWindowsDirectory (buf, len); - if (res && res <= len) - r.set_string ("", strcat (buf, "\\media\\ding.wav")); - } - MessageBeep (MB_OK); -} - /* This gets called when we found an invalid input character. We just print a half filled square (UTF 0x2592). We have no chance to figure out the "meaning" of the input char anyway. */