diff options
| author | Kim F. Storm | 2004-02-17 00:29:13 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2004-02-17 00:29:13 +0000 |
| commit | 7371cef007664b35e4c038dc7056a0568e814486 (patch) | |
| tree | 272ba2f83b28833d65dd2ba5ca17795e4f33d463 /src | |
| parent | b9568dfc774d8f4eef30229e898a5b8dff755e41 (diff) | |
| download | emacs-7371cef007664b35e4c038dc7056a0568e814486.tar.gz emacs-7371cef007664b35e4c038dc7056a0568e814486.zip | |
(in_read_avail_input): New static variable to handle re-entrancy.
(read_avail_input): Change buf to pinter to read_avail_input_buf.
Use in_read_avail_input to handle re-entrance; when re-entered,
fully initialize and use tmp_buf array instead of read_avail_input_buf.
Diffstat (limited to 'src')
| -rw-r--r-- | src/keyboard.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index 22610212c26..7c317660cc2 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -6581,13 +6581,17 @@ read_avail_input (expected) | |||
| 6581 | int expected; | 6581 | int expected; |
| 6582 | { | 6582 | { |
| 6583 | struct input_event *buf = read_avail_input_buf; | 6583 | struct input_event *buf = read_avail_input_buf; |
| 6584 | struct input_event tmp_buf[KBD_BUFFER_SIZE]; | ||
| 6584 | register int i; | 6585 | register int i; |
| 6585 | int nread; | 6586 | int nread; |
| 6586 | 6587 | ||
| 6587 | /* Trivial hack to make read_avail_input re-entrant. */ | 6588 | /* Trivial hack to make read_avail_input re-entrant. */ |
| 6588 | if (in_read_avail_input) | 6589 | if (in_read_avail_input++) |
| 6589 | return 0; | 6590 | { |
| 6590 | in_read_avail_input = 1; | 6591 | buf = tmp_buf; |
| 6592 | for (i = 0; i < KBD_BUFFER_SIZE; i++) | ||
| 6593 | EVENT_INIT (buf[i]); | ||
| 6594 | } | ||
| 6591 | 6595 | ||
| 6592 | if (read_socket_hook) | 6596 | if (read_socket_hook) |
| 6593 | /* No need for FIONREAD or fcntl; just say don't wait. */ | 6597 | /* No need for FIONREAD or fcntl; just say don't wait. */ |
| @@ -6602,12 +6606,16 @@ read_avail_input (expected) | |||
| 6602 | 6606 | ||
| 6603 | /* Determine how many characters we should *try* to read. */ | 6607 | /* Determine how many characters we should *try* to read. */ |
| 6604 | #ifdef WINDOWSNT | 6608 | #ifdef WINDOWSNT |
| 6605 | return (in_read_avail_input = 0); | 6609 | --in_read_avail_input; |
| 6610 | return 0; | ||
| 6606 | #else /* not WINDOWSNT */ | 6611 | #else /* not WINDOWSNT */ |
| 6607 | #ifdef MSDOS | 6612 | #ifdef MSDOS |
| 6608 | n_to_read = dos_keysns (); | 6613 | n_to_read = dos_keysns (); |
| 6609 | if (n_to_read == 0) | 6614 | if (n_to_read == 0) |
| 6610 | return (in_read_avail_input = 0); | 6615 | { |
| 6616 | --in_read_avail_input; | ||
| 6617 | return 0; | ||
| 6618 | } | ||
| 6611 | #else /* not MSDOS */ | 6619 | #else /* not MSDOS */ |
| 6612 | #ifdef FIONREAD | 6620 | #ifdef FIONREAD |
| 6613 | /* Find out how much input is available. */ | 6621 | /* Find out how much input is available. */ |
| @@ -6625,7 +6633,10 @@ read_avail_input (expected) | |||
| 6625 | n_to_read = 0; | 6633 | n_to_read = 0; |
| 6626 | } | 6634 | } |
| 6627 | if (n_to_read == 0) | 6635 | if (n_to_read == 0) |
| 6628 | return (in_read_avail_input = 0); | 6636 | { |
| 6637 | --in_read_avail_input; | ||
| 6638 | return 0; | ||
| 6639 | } | ||
| 6629 | if (n_to_read > sizeof cbuf) | 6640 | if (n_to_read > sizeof cbuf) |
| 6630 | n_to_read = sizeof cbuf; | 6641 | n_to_read = sizeof cbuf; |
| 6631 | #else /* no FIONREAD */ | 6642 | #else /* no FIONREAD */ |
| @@ -6717,10 +6728,10 @@ read_avail_input (expected) | |||
| 6717 | } | 6728 | } |
| 6718 | 6729 | ||
| 6719 | /* Clear used events */ | 6730 | /* Clear used events */ |
| 6720 | for (i = 0; i < nread; i++) | 6731 | if (--in_read_avail_input == 0) |
| 6721 | EVENT_INIT (buf[i]); | 6732 | for (i = 0; i < nread; i++) |
| 6733 | EVENT_INIT (buf[i]); | ||
| 6722 | 6734 | ||
| 6723 | in_read_avail_input = 0; | ||
| 6724 | return nread; | 6735 | return nread; |
| 6725 | } | 6736 | } |
| 6726 | #endif /* not VMS */ | 6737 | #endif /* not VMS */ |