OSDN Git Service

* fhandler_console.cc: Remove VK_DIVIDE detection.
authorcgf <cgf>
Sun, 30 Jul 2000 17:58:48 +0000 (17:58 +0000)
committercgf <cgf>
Sun, 30 Jul 2000 17:58:48 +0000 (17:58 +0000)
(get_nonascii_key): Simplify previous patch to return ascii char if it is
non-zero.  Add a second "temporary buffer" argument to help with thread safety.
* select.cc (peek_console): Pass a temporary buffer argument to
get_nonascii_key.

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

index 5c1ae3c..4638a80 100644 (file)
@@ -1,3 +1,12 @@
+Sun Jul 30 13:54:35 2000  Christopher Faylor <cgf@cygnus.com>
+
+       * fhandler_console.cc: Remove VK_DIVIDE detection.
+       (get_nonascii_key): Simplify previous patch to return ascii char if it
+       is non-zero.  Add a second "temporary buffer" argument to help with
+       thread safety.
+       * select.cc (peek_console): Pass a temporary buffer argument to
+       get_nonascii_key.
+
 Sat Jul 29 14:32:12 2000  Christopher Faylor <cgf@cygnus.com>
 
        * fhandler_console.cc: Add VK_DIVIDE detection.  Return virtual keycode
index 5ee8e9a..4c0bb5f 100644 (file)
@@ -40,7 +40,7 @@ static struct
 
 #define use_tty ISSTATE (myself, PID_USETTY)
 
-const char * get_nonascii_key (INPUT_RECORD& input_rec);
+const char * get_nonascii_key (INPUT_RECORD&, char *);
 
 HANDLE console_shared_h;
 
@@ -206,7 +206,7 @@ fhandler_console::read (void *pv, size_t buflen)
          /* arrow/function keys */
          (input_rec.Event.KeyEvent.dwControlKeyState & ENHANCED_KEY))
        {
-         toadd = get_nonascii_key (input_rec);
+         toadd = get_nonascii_key (input_rec, tmp);
          if (!toadd)
            continue;
          nread = strlen (toadd);
@@ -1297,13 +1297,11 @@ static struct {
   {VK_NUMPAD5, {"\033[G",      NULL,           NULL,           NULL}},
   {VK_CLEAR,   {"\033[G",      NULL,           NULL,           NULL}},
   {'6',                {NULL,          NULL,           "\036",         NULL}},
-  /* FIXME: Should this be \033OQ? */
-  {VK_DIVIDE,  {"/",           "/",            "/",            "/"}},
   {0,          {"",            NULL,           NULL,           NULL}}
 };
 
 const char *
-get_nonascii_key (INPUT_RECORD& input_rec)
+get_nonascii_key (INPUT_RECORD& input_rec, char *tmp)
 {
 #define NORMAL  0
 #define SHIFT  1
@@ -1324,12 +1322,11 @@ get_nonascii_key (INPUT_RECORD& input_rec)
     if (input_rec.Event.KeyEvent.wVirtualKeyCode == keytable[i].vk)
       return keytable[i].val[modifier_index];
 
-  if (input_rec.Event.KeyEvent.wVirtualKeyCode < ' ')
+  if (input_rec.Event.KeyEvent.uChar.AsciiChar)
     {
-      /* FIXME: Probably not thread-safe */
-      static char buf[2];
-      buf[0] = input_rec.Event.KeyEvent.wVirtualKeyCode;
-      return buf;
+      tmp[0] = input_rec.Event.KeyEvent.uChar.AsciiChar;
+      tmp[1] = '\0';
+      return tmp;
     }
   return NULL;
 }
index fa29331..951d80d 100644 (file)
@@ -597,7 +597,7 @@ fhandler_pipe::select_except (select_record *s)
 static int
 peek_console (select_record *me, int ignra)
 {
-  extern const char * get_nonascii_key (INPUT_RECORD& input_rec);
+  extern const char * get_nonascii_key (INPUT_RECORD& input_rec, char *);
   fhandler_console *fh = (fhandler_console *)me->fh;
 
   if (!me->read_selected)
@@ -618,6 +618,7 @@ peek_console (select_record *me, int ignra)
   INPUT_RECORD irec;
   DWORD events_read;
   HANDLE h;
+  char tmpbuf[17];
   set_handle_or_return_if_not_open (h, me);
 
   for (;;)
@@ -630,7 +631,7 @@ peek_console (select_record *me, int ignra)
        if (irec.EventType == WINDOW_BUFFER_SIZE_EVENT)
          kill_pgrp (fh->tc->getpgid (), SIGWINCH);
        else if (irec.EventType == KEY_EVENT && irec.Event.KeyEvent.bKeyDown == TRUE &&
-                (irec.Event.KeyEvent.uChar.AsciiChar || get_nonascii_key (irec)))
+                (irec.Event.KeyEvent.uChar.AsciiChar || get_nonascii_key (irec, tmpbuf)))
          return me->read_ready = 1;
 
        /* Read and discard the event */