• Paul Eggert's avatar
    Fix bug that munged selection info · 1552e673
    Paul Eggert authored
    On some optimizing C compilers, copying a structure did not
    copy the padding bytes between elements, and the type punning
    between struct input_data and struct selection_input_data did
    not work.  Change the C code to use a proper union type instead.
    Problem reported by YAMAMOTO Mitsuharu (Bug#20756).
    * src/keyboard.c (kbd_buffer, kbd_fetch_ptr, kbd_store_ptr)
    (readable_events, discard_mouse_events, kbd_buffer_events_waiting)
    (kbd_buffer_get_event, process_special_events, stuff_buffered_input)
    (mark_kboards):
    Use union buffered_input_event, not struct input_event.
    (clear_event, deliver_input_available_signal, process_special_events):
    Remove unnecessary forward decls.
    (kbd_buffer_store_buffered_event): New function, mostly just the
    old kbd_buffer_store_event_hold, except its argument is of type
    union buffered_input_event, not struct input_event.
    (kbd_buffer_unget_event): Define only if HAVE_X11, since it's
    not needed otherwise.  Argument is now of type
    struct selection_input_event *, not struct input_event *.
    All callers changed.
    (clear_event): Arg is now of type union buffered_input_event *,
    not struct input_event *.  All callers changed.
    * src/keyboard.h [HAVE_X11]: Include "xterm.h".
    (union buffered_input_event): New type.
    (kbd_buffer_store_event_hold): Now an inline function,
    defined here.
    * src/termhooks.h (EVENT_KIND_WIDTH): New constant.
    (struct input_event): Use it.
    * src/xselect.c (struct selection_event_queue):
    Make elements be of type struct selection_input_event,
    not struct input_event.
    (selection_input_event_equal): New static function.
    (x_queue_event): Use it.
    (x_queue_event, x_decline_selection_request)
    (x_selection_current_request, x_reply_selection_request)
    (x_handle_selection_request, x_handle_selection_clear)
    (x_handle_selection_event): Use struct selection_input_event,
    not struct input_event.  All callers changed.
    (x_convert_selection): Omit unused first arg.  All callers changed.
    (Fx_disown_selection_internal): Omit unnecessary union.
    * src/xterm.c (handle_one_xevent): Use new union buffered_input_event
    rather than rolling our own equivalent.  Prefer sie.kind when
    setting up that kind of structure.
    Call kbd_buffer_store_buffered_event, not kbd_buffer_store_event_hold.
    * src/xterm.h (struct selection_input_event: Use EVENT_KIND_WIDTH.
    (SELECTION_EVENT_DISPLAY, SELECTION_EVENT_DPYINFO)
    (SELECTION_EVENT_REQUESTOR, SELECTION_EVENT_SELECTION)
    (SELECTION_EVENT_TARGET, SELECTION_EVENT_PROPERTY)
    (SELECTION_EVENT_TIME, x_handle_selection_event):
    Arg is now of type struct selection_input_event *)
    not struct input_event *.  All callers changed.
    1552e673
xterm.c 366 KB