]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/base/lib_getch.c
ncurses 5.7 - patch 20091031
[ncurses.git] / ncurses / base / lib_getch.c
index 8609a90659ee42246f0cf721ae254b023b3b7284..f6520c068edc2dff613007b05723c373954a13cb 100644 (file)
@@ -42,7 +42,7 @@
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_getch.c,v 1.106 2009/07/25 17:02:03 tom Exp $")
+MODULE_ID("$Id: lib_getch.c,v 1.109 2009/10/24 21:58:34 tom Exp $")
 
 #include <fifo_defs.h>
 
@@ -110,9 +110,9 @@ NCURSES_SP_NAME(get_escdelay) (NCURSES_SP_DCL0)
 
 #if NCURSES_SP_FUNCS
 NCURSES_EXPORT(int)
-get_escdelay (void)
+get_escdelay(void)
 {
-    return NCURSES_SP_NAME(get_escdelay)(CURRENT_SCREEN);
+    return NCURSES_SP_NAME(get_escdelay) (CURRENT_SCREEN);
 }
 #endif
 #endif /* NCURSES_EXT_FUNCS */
@@ -380,7 +380,7 @@ _nc_wgetch(WINDOW *win,
     long event_delay = -1;
 #endif
 
-    T((T_CALLED("_nc_wgetch(%p)"), win));
+    T((T_CALLED("_nc_wgetch(%p)"), (void *) win));
 
     *result = 0;
 
@@ -467,7 +467,7 @@ _nc_wgetch(WINDOW *win,
            }
 #endif
            if (!rc) {
-               returnCode(ERR);
+               goto check_sigwinch;
            }
        }
        /* else go on to read data available */
@@ -529,12 +529,19 @@ _nc_wgetch(WINDOW *win,
     }
 
     if (ch == ERR) {
+      check_sigwinch:
 #if USE_SIZECHANGE
        if (_nc_handle_sigwinch(sp)) {
            _nc_update_screensize(sp);
            /* resizeterm can push KEY_RESIZE */
            if (cooked_key_in_fifo()) {
                *result = fifo_pull(sp);
+               /*
+                * Get the ERR from queue -- it is from WINCH,
+                * so we should take it out, the "error" is handled.
+                */
+               if (fifo_peek(sp) == -1)
+                   fifo_pull(sp);
                returnCode(*result >= KEY_MIN ? KEY_CODE_YES : OK);
            }
        }
@@ -611,7 +618,7 @@ wgetch(WINDOW *win)
     int code;
     unsigned long value;
 
-    T((T_CALLED("wgetch(%p)"), win));
+    T((T_CALLED("wgetch(%p)"), (void *) win));
     code = _nc_wgetch(win,
                      &value,
                      _nc_use_meta(win)
@@ -685,7 +692,7 @@ kgetch(SCREEN *sp EVENTLIST_2nd(_nc_eventlist * evl))
            break;
        }
        TR(TRACE_IEVENT, ("ptr=%p, ch=%d, value=%d",
-                         ptr, ptr->ch, ptr->value));
+                         (void *) ptr, ptr->ch, ptr->value));
 
        if (ptr->value != 0) {  /* sequence terminated */
            TR(TRACE_IEVENT, ("end of sequence"));