aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa <[email protected]>2007-09-14 04:12:53 +0000
committerKenichi Handa <[email protected]>2007-09-14 04:12:53 +0000
commit25c460e52e2146c34d53c240519ec06cd2f1d20d (patch)
treea08ab8efa1572377e9359c637511c4417419fbe9 /src
parente1b19750b67c2aeaeebf0b950406fc851d7de806 (diff)
(handle_one_xevent): Skip decoding if nbytes is zero.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog4
-rw-r--r--src/xterm.c67
2 files changed, 38 insertions, 33 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 2e4a32f4c9..4dd7d11c1a 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2007-09-14 Kenichi Handa <[email protected]>
+
+ * xterm.c (handle_one_xevent): Skip decoding if nbytes is zero.
+
2007-09-13 Jason Rumney <[email protected]>
* fringe.c (w32_init_fringe, mac_init_fringe): Add rif argument.
diff --git a/src/xterm.c b/src/xterm.c
index 9e85967ba4..fcf5e0b219 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -6538,42 +6538,43 @@ handle_one_xevent (dpyinfo, eventp, finish, hold_quit)
gives us composition information. */
coding.composing = COMPOSITION_DISABLED;
- for (i = 0; i < nbytes; i++)
+ if (nbytes > 0)
{
- STORE_KEYSYM_FOR_DEBUG (copy_bufptr[i]);
- }
+ /* Decode the input data. */
+ int require;
+ unsigned char *p;
- {
- /* Decode the input data. */
- int require;
- unsigned char *p;
-
- require = decoding_buffer_size (&coding, nbytes);
- p = (unsigned char *) alloca (require);
- coding.mode |= CODING_MODE_LAST_BLOCK;
- /* We explicitly disable composition handling because
- key data should not contain any composition sequence. */
- coding.composing = COMPOSITION_DISABLED;
- decode_coding (&coding, copy_bufptr, p, nbytes, require);
- nbytes = coding.produced;
- nchars = coding.produced_char;
- copy_bufptr = p;
- }
+ for (i = 0; i < nbytes; i++)
+ {
+ STORE_KEYSYM_FOR_DEBUG (copy_bufptr[i]);
+ }
- /* Convert the input data to a sequence of
- character events. */
- for (i = 0; i < nbytes; i += len)
- {
- if (nchars == nbytes)
- c = copy_bufptr[i], len = 1;
- else
- c = STRING_CHAR_AND_LENGTH (copy_bufptr + i,
- nbytes - i, len);
- inev.ie.kind = (SINGLE_BYTE_CHAR_P (c)
- ? ASCII_KEYSTROKE_EVENT
- : MULTIBYTE_CHAR_KEYSTROKE_EVENT);
- inev.ie.code = c;
- kbd_buffer_store_event_hold (&inev.ie, hold_quit);
+ require = decoding_buffer_size (&coding, nbytes);
+ p = (unsigned char *) alloca (require);
+ coding.mode |= CODING_MODE_LAST_BLOCK;
+ /* We explicitly disable composition handling because
+ key data should not contain any composition sequence. */
+ coding.composing = COMPOSITION_DISABLED;
+ decode_coding (&coding, copy_bufptr, p, nbytes, require);
+ nbytes = coding.produced;
+ nchars = coding.produced_char;
+ copy_bufptr = p;
+
+ /* Convert the input data to a sequence of
+ character events. */
+ for (i = 0; i < nbytes; i += len)
+ {
+ if (nchars == nbytes)
+ c = copy_bufptr[i], len = 1;
+ else
+ c = STRING_CHAR_AND_LENGTH (copy_bufptr + i,
+ nbytes - i, len);
+ inev.ie.kind = (SINGLE_BYTE_CHAR_P (c)
+ ? ASCII_KEYSTROKE_EVENT
+ : MULTIBYTE_CHAR_KEYSTROKE_EVENT);
+ inev.ie.code = c;
+ kbd_buffer_store_event_hold (&inev.ie, hold_quit);
+ }
}
/* Previous code updated count by nchars rather than nbytes,