]> sourceware.org Git - newlib-cygwin.git/commitdiff
* fhandler_console.cc (beep): Move up to avoid forward declaration.
authorCorinna Vinschen <corinna@vinschen.de>
Wed, 30 Sep 2009 09:23:45 +0000 (09:23 +0000)
committerCorinna Vinschen <corinna@vinschen.de>
Wed, 30 Sep 2009 09:23:45 +0000 (09:23 +0000)
(fhandler_console::read): Just beep on characters invalid in current
charset.  Add comment.

winsup/cygwin/ChangeLog
winsup/cygwin/fhandler_console.cc

index 3fb5232107fc7f3df0ef160749f53e12288ef7ef..a74484ea3ee335442f48c007ab423c738dbaecae 100644 (file)
@@ -1,3 +1,9 @@
+2009-09-30  Corinna Vinschen  <corinna@vinschen.de>
+
+       * 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  <ebb9@byu.net>
 
        * syscalls.cc (rename): Fix regression in rename("dir","d/").
index 251a8279a587dfc5e7e1078bb76f4c3dbd944faa..632ec1dcbd48a23f9d149f3c563a059c39b6a92f 100644 (file)
@@ -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. */
This page took 0.039802 seconds and 5 git commands to generate.