+2012-09-20 Paul Eggert <eggert@cs.ucla.edu>
+
+ 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 <lekktu@gmail.com>
* w32gui.h (XParseGeometry): Do not declare.
#ifdef USABLE_SIGIO
- gobble_input (0);
+ gobble_input ();
#endif
wait_reading_process_output (sec, nsec, reading ? -1 : 1, do_display,
/* 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 *,
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
{
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
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;
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))
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)
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
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
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;
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. */
{
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
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. */
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);
pthread_sigmask (SIG_SETMASK, &procmask, 0);
}
-
- return nstored;
}
\f
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);
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);
}
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.
NSColorPboardType,
NSFontPboardType, nil] retain];
-
+
[NSApp run];
ns_do_open_file = YES;
return dpyinfo;
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. */
int
w32_console_read_socket (struct terminal *terminal,
- int expected,
struct input_event *hold_quit)
{
int nev, add;
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,
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
*/
static int
-w32_read_socket (struct terminal *terminal, int expected,
+w32_read_socket (struct terminal *terminal,
struct input_event *hold_quit)
{
int count = 0;
/* 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;