From f75beb4787372df3dcc50cbb07407f45ff04bf04 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 19 Sep 2012 18:37:07 -0700 Subject: [PATCH] Omit unused arg EXPECTED from socket hooks. * keyboard.c (gobble_input, read_avail_input, tty_read_avail_input): * nsterm.m (ns_term_init): * termhooks.h (struct terminal.read_socket_hook): * w32inevt.c (w32_console_read_socket): * w32term.c (w32_read_socket): * xterm.c (XTread_socket): Omit unused arg EXPECTED. All callers changed. (store_user_signal_events): Return void, not int, since callers no longer care about the return value. All uses changed. --- src/ChangeLog | 13 +++++++++++++ src/dispnew.c | 2 +- src/keyboard.c | 47 +++++++++++++++++++---------------------------- src/keyboard.h | 5 ++--- src/nsterm.m | 5 ++--- src/termhooks.h | 15 +++------------ src/w32inevt.c | 1 - src/w32inevt.h | 2 +- src/w32term.c | 4 +--- src/xterm.c | 12 ++++-------- 10 files changed, 46 insertions(+), 60 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 2ee57d8531c..7f9cac9fa21 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,16 @@ +2012-09-20 Paul Eggert + + Omit unused arg EXPECTED from socket hooks. + * keyboard.c (gobble_input, read_avail_input, tty_read_avail_input): + * nsterm.m (ns_term_init): + * termhooks.h (struct terminal.read_socket_hook): + * w32inevt.c (w32_console_read_socket): + * w32term.c (w32_read_socket): + * xterm.c (XTread_socket): + Omit unused arg EXPECTED. All callers changed. + (store_user_signal_events): Return void, not int, since callers no + longer care about the return value. All uses changed. + 2012-09-20 Juanma Barranquero * w32gui.h (XParseGeometry): Do not declare. diff --git a/src/dispnew.c b/src/dispnew.c index 5827316a7b7..fc966581adb 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -5971,7 +5971,7 @@ sit_for (Lisp_Object timeout, bool reading, int do_display) #ifdef USABLE_SIGIO - gobble_input (0); + gobble_input (); #endif wait_reading_process_output (sec, nsec, reading ? -1 : 1, do_display, diff --git a/src/keyboard.c b/src/keyboard.c index 01644b3832d..098d3530ef8 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -413,7 +413,7 @@ static EMACS_TIME timer_last_idleness_start_time; /* Function for init_keyboard to call with no args (if nonzero). */ static void (*keyboard_init_hook) (void); -static int read_avail_input (int); +static int read_avail_input (void); static void get_input_pending (int *, int); static int readable_events (int); static Lisp_Object read_char_x_menu_prompt (ptrdiff_t, Lisp_Object *, @@ -448,7 +448,7 @@ static void timer_stop_idle (void); static void timer_resume_idle (void); static void deliver_user_signal (int); static char *find_user_signal_name (int); -static int store_user_signal_events (void); +static void store_user_signal_events (void); /* These setters are used only in this file, so they can be private. */ static inline void @@ -2010,7 +2010,7 @@ poll_for_input_1 (void) { if (interrupt_input_blocked == 0 && !waiting_for_input) - read_avail_input (0); + read_avail_input (); } /* Timer callback function for poll_timer. TIMER is equal to @@ -3843,7 +3843,7 @@ kbd_buffer_get_event (KBOARD **kbp, interrupt handlers have not read it, read it now. */ #ifdef USABLE_SIGIO - gobble_input (0); + gobble_input (); #endif if (kbd_fetch_ptr != kbd_store_ptr) break; @@ -3869,8 +3869,7 @@ kbd_buffer_get_event (KBOARD **kbp, wait_reading_process_output (0, 0, -1, 1, Qnil, NULL, 0); if (!interrupt_input && kbd_fetch_ptr == kbd_store_ptr) - /* Pass 1 for EXPECT since we just waited to have input. */ - read_avail_input (1); + read_avail_input (); } if (CONSP (Vunread_command_events)) @@ -6734,14 +6733,14 @@ get_input_pending (int *addr, int flags) return; /* Try to read some input and see how much we get. */ - gobble_input (0); + gobble_input (); *addr = (!NILP (Vquit_flag) || readable_events (flags)); } /* Interface to read_avail_input, blocking SIGIO or SIGALRM if necessary. */ void -gobble_input (int expected) +gobble_input (void) { #ifdef USABLE_SIGIO if (interrupt_input) @@ -6750,7 +6749,7 @@ gobble_input (int expected) sigemptyset (&blocked); sigaddset (&blocked, SIGIO); pthread_sigmask (SIG_BLOCK, &blocked, &procmask); - read_avail_input (expected); + read_avail_input (); pthread_sigmask (SIG_SETMASK, &procmask, 0); } else @@ -6764,13 +6763,13 @@ gobble_input (int expected) sigemptyset (&blocked); sigaddset (&blocked, SIGALRM); pthread_sigmask (SIG_BLOCK, &blocked, &procmask); - read_avail_input (expected); + read_avail_input (); pthread_sigmask (SIG_SETMASK, &procmask, 0); } else #endif #endif - read_avail_input (expected); + read_avail_input (); } /* Put a BUFFER_SWITCH_EVENT in the buffer @@ -6826,15 +6825,14 @@ record_asynch_buffer_change (void) this is a bad time to try to read input. */ static int -read_avail_input (int expected) +read_avail_input (void) { int nread = 0; int err = 0; struct terminal *t; /* Store pending user signal events, if any. */ - if (store_user_signal_events ()) - expected = 0; + store_user_signal_events (); /* Loop through the available terminals, and call their input hooks. */ t = terminal_list; @@ -6851,11 +6849,8 @@ read_avail_input (int expected) hold_quit.kind = NO_EVENT; /* No need for FIONREAD or fcntl; just say don't wait. */ - while (nr = (*t->read_socket_hook) (t, expected, &hold_quit), nr > 0) - { - nread += nr; - expected = 0; - } + while (0 < (nr = (*t->read_socket_hook) (t, &hold_quit))) + nread += nr; if (nr == -1) /* Not OK to read input now. */ { @@ -6950,7 +6945,6 @@ decode_keyboard_code (struct tty_display_info *tty, int tty_read_avail_input (struct terminal *terminal, - int expected, struct input_event *hold_quit) { /* Using KBD_BUFFER_SIZE - 1 here avoids reading more than @@ -7170,8 +7164,7 @@ handle_async_input (void) while (1) { - int nread; - nread = read_avail_input (1); + int nread = read_avail_input (); /* -1 means it's not ok to read the input now. UNBLOCK_INPUT will read it later; now, avoid infinite loop. 0 means there was no keyboard input available. */ @@ -7323,25 +7316,25 @@ find_user_signal_name (int sig) return NULL; } -static int +static void store_user_signal_events (void) { struct user_signal_info *p; struct input_event buf; - int nstored = 0; + bool buf_initialized = 0; for (p = user_signals; p; p = p->next) if (p->npending > 0) { sigset_t blocked, procmask; - if (nstored == 0) + if (! buf_initialized) { memset (&buf, 0, sizeof buf); buf.kind = USER_SIGNAL_EVENT; buf.frame_or_window = selected_frame; + buf_initialized = 1; } - nstored += p->npending; sigemptyset (&blocked); sigaddset (&blocked, p->sig); @@ -7357,8 +7350,6 @@ store_user_signal_events (void) pthread_sigmask (SIG_SETMASK, &procmask, 0); } - - return nstored; } diff --git a/src/keyboard.h b/src/keyboard.h index 91484b3649b..3601f68be9f 100644 --- a/src/keyboard.h +++ b/src/keyboard.h @@ -523,7 +523,7 @@ extern void input_poll_signal (int); extern void start_polling (void); extern void stop_polling (void); extern void set_poll_suppress_count (int); -extern void gobble_input (int); +extern void gobble_input (void); extern int input_polling_used (void); extern void clear_input_pending (void); extern int requeued_events_pending_p (void); @@ -547,8 +547,7 @@ extern Lisp_Object menu_item_eval_property (Lisp_Object); extern int kbd_buffer_events_waiting (int); extern void add_user_signal (int, const char *); -extern int tty_read_avail_input (struct terminal *, int, - struct input_event *); +extern int tty_read_avail_input (struct terminal *, struct input_event *); extern EMACS_TIME timer_check (void); extern void mark_kboards (void); diff --git a/src/nsterm.m b/src/nsterm.m index 0b26508dbd0..aa869e3ff44 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -3336,8 +3336,7 @@ ns_send_appdefined (int value) } static int -ns_read_socket (struct terminal *terminal, int expected, - struct input_event *hold_quit) +ns_read_socket (struct terminal *terminal, struct input_event *hold_quit) /* -------------------------------------------------------------------------- External (hook): Post an event to ourself and keep reading events until we read it back again. In effect process all events which were waiting. @@ -4204,7 +4203,7 @@ ns_term_init (Lisp_Object display_name) NSColorPboardType, NSFontPboardType, nil] retain]; - + [NSApp run]; ns_do_open_file = YES; return dpyinfo; diff --git a/src/termhooks.h b/src/termhooks.h index 46962a1217d..53e401de409 100644 --- a/src/termhooks.h +++ b/src/termhooks.h @@ -592,23 +592,14 @@ struct terminal TERMINAL indicates which terminal device to read from. Input events should be read into BUF, the size of which is given in - SIZE. EXPECTED is non-zero if the caller suspects that new input - is available. + SIZE. A positive return value indicates that that many input events - where read into BUF. + were read into BUF. Zero means no events were immediately available. A value of -1 means a transient read error, while -2 indicates - that the device was closed (hangup), and it should be deleted. - - XXX Please note that a non-zero value of EXPECTED only means that - there is available input on at least one of the currently opened - terminal devices -- but not necessarily on this device. - Therefore, in most cases EXPECTED should be simply ignored. - - XXX This documentation needs to be updated. */ + that the device was closed (hangup), and it should be deleted. */ int (*read_socket_hook) (struct terminal *terminal, - int expected, struct input_event *hold_quit); /* Called when a frame's display becomes entirely up to date. */ diff --git a/src/w32inevt.c b/src/w32inevt.c index d4cc620335c..a96d8d70483 100644 --- a/src/w32inevt.c +++ b/src/w32inevt.c @@ -744,7 +744,6 @@ maybe_generate_resize_event (void) int w32_console_read_socket (struct terminal *terminal, - int expected, struct input_event *hold_quit) { int nev, add; diff --git a/src/w32inevt.h b/src/w32inevt.h index c874e58ef39..319688b877b 100644 --- a/src/w32inevt.h +++ b/src/w32inevt.h @@ -21,7 +21,7 @@ along with GNU Emacs. If not, see . */ extern int w32_console_unicode_input; -extern int w32_console_read_socket (struct terminal *term, int numchars, +extern int w32_console_read_socket (struct terminal *term, struct input_event *hold_quit); extern void w32_console_mouse_position (FRAME_PTR *f, int insist, Lisp_Object *bar_window, diff --git a/src/w32term.c b/src/w32term.c index 6244728b264..b8227c52fed 100644 --- a/src/w32term.c +++ b/src/w32term.c @@ -4137,8 +4137,6 @@ static char dbcs_lead = 0; We return the number of characters stored into the buffer, thus pretending to be `read'. - EXPECTED is nonzero if the caller knows input is available. - Some of these messages are reposted back to the message queue since the system calls the windows proc directly in a context where we cannot return the data nor can we guarantee the state we are in. So if we dispatch them @@ -4149,7 +4147,7 @@ static char dbcs_lead = 0; */ static int -w32_read_socket (struct terminal *terminal, int expected, +w32_read_socket (struct terminal *terminal, struct input_event *hold_quit) { int count = 0; diff --git a/src/xterm.c b/src/xterm.c index 9ab53dc087a..8c955d0e576 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -7109,19 +7109,15 @@ x_dispatch_event (XEvent *event, Display *display) /* Read events coming from the X server. - This routine is called by the SIGIO handler only if SYNC_INPUT is - not defined. - We return as soon as there are no more events to be read. + Return as soon as there are no more events to be read. - We return the number of characters stored into the buffer, + Return the number of characters stored into the buffer, thus pretending to be `read' (except the characters we store in the keyboard buffer can be multibyte, so are not necessarily - C chars). - - EXPECTED is nonzero if the caller knows input is available. */ + C chars). */ static int -XTread_socket (struct terminal *terminal, int expected, struct input_event *hold_quit) +XTread_socket (struct terminal *terminal, struct input_event *hold_quit) { int count = 0; int event_found = 0; -- 2.39.2