diff options
| author | Stefan Monnier | 2004-01-21 20:19:41 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2004-01-21 20:19:41 +0000 |
| commit | d92f48d3ab09a639f7c2244d54187846899e803e (patch) | |
| tree | 47391ffe392b96738322bca4c0f5d3d863d468fc /src | |
| parent | 438fc6c0c090e041fdfc1cac31ba99942c9248c8 (diff) | |
| download | emacs-d92f48d3ab09a639f7c2244d54187846899e803e.tar.gz emacs-d92f48d3ab09a639f7c2244d54187846899e803e.zip | |
(kbd_buffer_gcpro): Remove.
(kbd_buffer_store_event, clear_event, Fdiscard_input)
(stuff_buffered_input, init_keyboard, syms_of_keyboard):
Don't intitialize and/or maintain the variable any more. It was made
redundant by my commit of 2003-06-15.
Diffstat (limited to 'src')
| -rw-r--r-- | src/keyboard.c | 48 |
1 files changed, 1 insertions, 47 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index d6a743489a1..36dabad804f 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -479,36 +479,6 @@ extern char *pending_malloc_warning; | |||
| 479 | 479 | ||
| 480 | static struct input_event kbd_buffer[KBD_BUFFER_SIZE]; | 480 | static struct input_event kbd_buffer[KBD_BUFFER_SIZE]; |
| 481 | 481 | ||
| 482 | /* Vector to GCPRO the Lisp objects referenced from kbd_buffer. | ||
| 483 | |||
| 484 | The interrupt-level event handlers will never enqueue an event on a | ||
| 485 | frame which is not in Vframe_list, and once an event is dequeued, | ||
| 486 | internal_last_event_frame or the event itself points to the frame. | ||
| 487 | So that's all fine. | ||
| 488 | |||
| 489 | But while the event is sitting in the queue, it's completely | ||
| 490 | unprotected. Suppose the user types one command which will run for | ||
| 491 | a while and then delete a frame, and then types another event at | ||
| 492 | the frame that will be deleted, before the command gets around to | ||
| 493 | it. Suppose there are no references to this frame elsewhere in | ||
| 494 | Emacs, and a GC occurs before the second event is dequeued. Now we | ||
| 495 | have an event referring to a freed frame, which will crash Emacs | ||
| 496 | when it is dequeued. | ||
| 497 | |||
| 498 | Similar things happen when an event on a scroll bar is enqueued; the | ||
| 499 | window may be deleted while the event is in the queue. | ||
| 500 | |||
| 501 | So, we use this vector to protect the Lisp_Objects in the event | ||
| 502 | queue. That way, they'll be dequeued as dead frames or windows, | ||
| 503 | but still valid Lisp objects. | ||
| 504 | |||
| 505 | If kbd_buffer[i].kind != NO_EVENT, then | ||
| 506 | |||
| 507 | AREF (kbd_buffer_gcpro, 2 * i) == kbd_buffer[i].frame_or_window. | ||
| 508 | AREF (kbd_buffer_gcpro, 2 * i + 1) == kbd_buffer[i].arg. */ | ||
| 509 | |||
| 510 | static Lisp_Object kbd_buffer_gcpro; | ||
| 511 | |||
| 512 | /* Pointer to next available character in kbd_buffer. | 482 | /* Pointer to next available character in kbd_buffer. |
| 513 | If kbd_fetch_ptr == kbd_store_ptr, the buffer is empty. | 483 | If kbd_fetch_ptr == kbd_store_ptr, the buffer is empty. |
| 514 | This may be kbd_buffer + KBD_BUFFER_SIZE, meaning that the | 484 | This may be kbd_buffer + KBD_BUFFER_SIZE, meaning that the |
| @@ -3634,7 +3604,6 @@ kbd_buffer_store_event (event) | |||
| 3634 | Discard the event if it would fill the last slot. */ | 3604 | Discard the event if it would fill the last slot. */ |
| 3635 | if (kbd_fetch_ptr - 1 != kbd_store_ptr) | 3605 | if (kbd_fetch_ptr - 1 != kbd_store_ptr) |
| 3636 | { | 3606 | { |
| 3637 | int idx; | ||
| 3638 | 3607 | ||
| 3639 | #if 0 /* The SELECTION_REQUEST_EVENT case looks bogus, and it's error | 3608 | #if 0 /* The SELECTION_REQUEST_EVENT case looks bogus, and it's error |
| 3640 | prone to assign individual members for other events, in case | 3609 | prone to assign individual members for other events, in case |
| @@ -3664,9 +3633,6 @@ kbd_buffer_store_event (event) | |||
| 3664 | *kbd_store_ptr = *event; | 3633 | *kbd_store_ptr = *event; |
| 3665 | #endif | 3634 | #endif |
| 3666 | 3635 | ||
| 3667 | idx = 2 * (kbd_store_ptr - kbd_buffer); | ||
| 3668 | ASET (kbd_buffer_gcpro, idx, event->frame_or_window); | ||
| 3669 | ASET (kbd_buffer_gcpro, idx + 1, event->arg); | ||
| 3670 | ++kbd_store_ptr; | 3636 | ++kbd_store_ptr; |
| 3671 | } | 3637 | } |
| 3672 | } | 3638 | } |
| @@ -3782,9 +3748,6 @@ static INLINE void | |||
| 3782 | clear_event (event) | 3748 | clear_event (event) |
| 3783 | struct input_event *event; | 3749 | struct input_event *event; |
| 3784 | { | 3750 | { |
| 3785 | int idx = 2 * (event - kbd_buffer); | ||
| 3786 | ASET (kbd_buffer_gcpro, idx, Qnil); | ||
| 3787 | ASET (kbd_buffer_gcpro, idx + 1, Qnil); | ||
| 3788 | event->kind = NO_EVENT; | 3751 | event->kind = NO_EVENT; |
| 3789 | } | 3752 | } |
| 3790 | 3753 | ||
| @@ -10073,7 +10036,6 @@ Also end any kbd macro being defined. */) | |||
| 10073 | discard_tty_input (); | 10036 | discard_tty_input (); |
| 10074 | 10037 | ||
| 10075 | kbd_fetch_ptr = kbd_store_ptr; | 10038 | kbd_fetch_ptr = kbd_store_ptr; |
| 10076 | Ffillarray (kbd_buffer_gcpro, Qnil); | ||
| 10077 | input_pending = 0; | 10039 | input_pending = 0; |
| 10078 | 10040 | ||
| 10079 | return Qnil; | 10041 | return Qnil; |
| @@ -10164,17 +10126,13 @@ stuff_buffered_input (stuffstring) | |||
| 10164 | Should we ignore anything that was typed in at the "wrong" kboard? */ | 10126 | Should we ignore anything that was typed in at the "wrong" kboard? */ |
| 10165 | for (; kbd_fetch_ptr != kbd_store_ptr; kbd_fetch_ptr++) | 10127 | for (; kbd_fetch_ptr != kbd_store_ptr; kbd_fetch_ptr++) |
| 10166 | { | 10128 | { |
| 10167 | int idx; | ||
| 10168 | 10129 | ||
| 10169 | if (kbd_fetch_ptr == kbd_buffer + KBD_BUFFER_SIZE) | 10130 | if (kbd_fetch_ptr == kbd_buffer + KBD_BUFFER_SIZE) |
| 10170 | kbd_fetch_ptr = kbd_buffer; | 10131 | kbd_fetch_ptr = kbd_buffer; |
| 10171 | if (kbd_fetch_ptr->kind == ASCII_KEYSTROKE_EVENT) | 10132 | if (kbd_fetch_ptr->kind == ASCII_KEYSTROKE_EVENT) |
| 10172 | stuff_char (kbd_fetch_ptr->code); | 10133 | stuff_char (kbd_fetch_ptr->code); |
| 10173 | 10134 | ||
| 10174 | kbd_fetch_ptr->kind = NO_EVENT; | 10135 | clear_event (kbd_fetch_ptr); |
| 10175 | idx = 2 * (kbd_fetch_ptr - kbd_buffer); | ||
| 10176 | ASET (kbd_buffer_gcpro, idx, Qnil); | ||
| 10177 | ASET (kbd_buffer_gcpro, idx + 1, Qnil); | ||
| 10178 | } | 10136 | } |
| 10179 | 10137 | ||
| 10180 | input_pending = 0; | 10138 | input_pending = 0; |
| @@ -10574,7 +10532,6 @@ init_keyboard () | |||
| 10574 | recent_keys_index = 0; | 10532 | recent_keys_index = 0; |
| 10575 | kbd_fetch_ptr = kbd_buffer; | 10533 | kbd_fetch_ptr = kbd_buffer; |
| 10576 | kbd_store_ptr = kbd_buffer; | 10534 | kbd_store_ptr = kbd_buffer; |
| 10577 | kbd_buffer_gcpro = Fmake_vector (make_number (2 * KBD_BUFFER_SIZE), Qnil); | ||
| 10578 | #ifdef HAVE_MOUSE | 10535 | #ifdef HAVE_MOUSE |
| 10579 | do_mouse_tracking = Qnil; | 10536 | do_mouse_tracking = Qnil; |
| 10580 | #endif | 10537 | #endif |
| @@ -10865,9 +10822,6 @@ syms_of_keyboard () | |||
| 10865 | Fset (Qextended_command_history, Qnil); | 10822 | Fset (Qextended_command_history, Qnil); |
| 10866 | staticpro (&Qextended_command_history); | 10823 | staticpro (&Qextended_command_history); |
| 10867 | 10824 | ||
| 10868 | kbd_buffer_gcpro = Fmake_vector (make_number (2 * KBD_BUFFER_SIZE), Qnil); | ||
| 10869 | staticpro (&kbd_buffer_gcpro); | ||
| 10870 | |||
| 10871 | accent_key_syms = Qnil; | 10825 | accent_key_syms = Qnil; |
| 10872 | staticpro (&accent_key_syms); | 10826 | staticpro (&accent_key_syms); |
| 10873 | 10827 | ||