diff options
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/w32term.c | 107 |
2 files changed, 45 insertions, 67 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 0288554acd0..f7d6c07a086 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2008-02-05 Jason Rumney <jasonr@gnu.org> | ||
| 2 | |||
| 3 | * w32term.c (w32_read_socket) <WM_CHAR>: Use locale-coding-system | ||
| 4 | instead of using mule-unicode-* charsets directly. | ||
| 5 | |||
| 1 | 2008-02-05 Juanma Barranquero <lekktu@gmail.com> | 6 | 2008-02-05 Juanma Barranquero <lekktu@gmail.com> |
| 2 | 7 | ||
| 3 | * unexec.c (make_hdr): | 8 | * unexec.c (make_hdr): |
diff --git a/src/w32term.c b/src/w32term.c index 23b79008402..2b007b14b44 100644 --- a/src/w32term.c +++ b/src/w32term.c | |||
| @@ -4338,7 +4338,7 @@ w32_read_socket (sd, expected, hold_quit) | |||
| 4338 | } | 4338 | } |
| 4339 | } | 4339 | } |
| 4340 | 4340 | ||
| 4341 | /* Now process unicode input as per xterm.c */ | 4341 | /* Process unicode input for ASCII and ISO Control only. */ |
| 4342 | if (code < 0x80) | 4342 | if (code < 0x80) |
| 4343 | { | 4343 | { |
| 4344 | inev.kind = ASCII_KEYSTROKE_EVENT; | 4344 | inev.kind = ASCII_KEYSTROKE_EVENT; |
| @@ -4346,82 +4346,56 @@ w32_read_socket (sd, expected, hold_quit) | |||
| 4346 | } | 4346 | } |
| 4347 | else if (code < 0xA0) | 4347 | else if (code < 0xA0) |
| 4348 | inev.code = MAKE_CHAR (CHARSET_8_BIT_CONTROL, code, 0); | 4348 | inev.code = MAKE_CHAR (CHARSET_8_BIT_CONTROL, code, 0); |
| 4349 | else if (code < 0x100) | ||
| 4350 | inev.code = MAKE_CHAR (charset_latin_iso8859_1, code, 0); | ||
| 4351 | else | 4349 | else |
| 4352 | { | 4350 | { |
| 4353 | int c1, c2; | 4351 | /* Many locales do not have full mapping from |
| 4354 | int charset_id; | 4352 | unicode on save, so use the locale coding to |
| 4355 | 4353 | decode them. Windows only allows non-Unicode | |
| 4356 | if (code < 0x2500) | 4354 | Windows to receive characters in the system |
| 4357 | { | 4355 | locale anyway, so this doesn't really limit |
| 4358 | charset_id = charset_mule_unicode_0100_24ff; | 4356 | us. */ |
| 4359 | code -= 0x100; | 4357 | int nbytes, nchars, require, i, len; |
| 4360 | } | 4358 | unsigned char *dest; |
| 4361 | else if (code < 0x3400) | 4359 | struct coding_system coding; |
| 4360 | |||
| 4361 | if (dbcs[0] == 0) | ||
| 4362 | { | 4362 | { |
| 4363 | charset_id = charset_mule_unicode_2500_33ff; | 4363 | nbytes = 1; |
| 4364 | code -= 0x2500; | 4364 | dbcs[0] = dbcs[1]; |
| 4365 | } | ||
| 4366 | else if (code >= 0xE000) | ||
| 4367 | { | ||
| 4368 | charset_id = charset_mule_unicode_e000_ffff; | ||
| 4369 | code -= 0xE000; | ||
| 4370 | } | 4365 | } |
| 4371 | else | 4366 | else |
| 4372 | { | 4367 | nbytes = 2; |
| 4373 | /* Not in the unicode range that we can handle in | ||
| 4374 | Emacs-22, so decode the original character | ||
| 4375 | using the locale */ | ||
| 4376 | int nbytes, nchars, require, i, len; | ||
| 4377 | unsigned char *dest; | ||
| 4378 | struct coding_system coding; | ||
| 4379 | |||
| 4380 | if (dbcs[0] == 0) | ||
| 4381 | { | ||
| 4382 | nbytes = 1; | ||
| 4383 | dbcs[0] = dbcs[1]; | ||
| 4384 | } | ||
| 4385 | else | ||
| 4386 | nbytes = 2; | ||
| 4387 | 4368 | ||
| 4388 | setup_coding_system (Vlocale_coding_system, &coding); | 4369 | setup_coding_system (Vlocale_coding_system, &coding); |
| 4389 | coding.src_multibyte = 0; | 4370 | coding.src_multibyte = 0; |
| 4390 | coding.dst_multibyte = 1; | 4371 | coding.dst_multibyte = 1; |
| 4391 | coding.composing = COMPOSITION_DISABLED; | 4372 | coding.composing = COMPOSITION_DISABLED; |
| 4392 | require = decoding_buffer_size (&coding, nbytes); | 4373 | require = decoding_buffer_size (&coding, nbytes); |
| 4393 | dest = (unsigned char *) alloca (require); | 4374 | dest = (unsigned char *) alloca (require); |
| 4394 | coding.mode |= CODING_MODE_LAST_BLOCK; | 4375 | coding.mode |= CODING_MODE_LAST_BLOCK; |
| 4395 | 4376 | ||
| 4396 | decode_coding (&coding, dbcs, dest, nbytes, require); | 4377 | decode_coding (&coding, dbcs, dest, nbytes, require); |
| 4397 | nbytes = coding.produced; | 4378 | nbytes = coding.produced; |
| 4398 | nchars = coding.produced_char; | 4379 | nchars = coding.produced_char; |
| 4399 | 4380 | ||
| 4400 | for (i = 0; i < nbytes; i += len) | 4381 | for (i = 0; i < nbytes; i += len) |
| 4382 | { | ||
| 4383 | if (nchars == nbytes) | ||
| 4401 | { | 4384 | { |
| 4402 | if (nchars == nbytes) | 4385 | inev.code = dest[i]; |
| 4403 | { | 4386 | len = 1; |
| 4404 | inev.code = dest[i]; | ||
| 4405 | len = 1; | ||
| 4406 | } | ||
| 4407 | else | ||
| 4408 | inev.code = STRING_CHAR_AND_LENGTH (dest + i, | ||
| 4409 | nbytes - 1, | ||
| 4410 | len); | ||
| 4411 | inev.kind = (SINGLE_BYTE_CHAR_P (inev.code) | ||
| 4412 | ? ASCII_KEYSTROKE_EVENT | ||
| 4413 | : MULTIBYTE_CHAR_KEYSTROKE_EVENT); | ||
| 4414 | kbd_buffer_store_event_hold (&inev, hold_quit); | ||
| 4415 | count++; | ||
| 4416 | } | 4387 | } |
| 4417 | inev.kind = NO_EVENT; /* Already handled */ | 4388 | else |
| 4418 | break; | 4389 | inev.code = STRING_CHAR_AND_LENGTH (dest + i, |
| 4390 | nbytes - 1, | ||
| 4391 | len); | ||
| 4392 | inev.kind = (SINGLE_BYTE_CHAR_P (inev.code) | ||
| 4393 | ? ASCII_KEYSTROKE_EVENT | ||
| 4394 | : MULTIBYTE_CHAR_KEYSTROKE_EVENT); | ||
| 4395 | kbd_buffer_store_event_hold (&inev, hold_quit); | ||
| 4396 | count++; | ||
| 4419 | } | 4397 | } |
| 4420 | 4398 | inev.kind = NO_EVENT; /* Already handled */ | |
| 4421 | /* Unicode characters from above. */ | ||
| 4422 | c1 = (code / 96) + 32; | ||
| 4423 | c2 = (code % 96) + 32; | ||
| 4424 | inev.code = MAKE_CHAR (charset_id, c1, c2); | ||
| 4425 | } | 4399 | } |
| 4426 | } | 4400 | } |
| 4427 | else | 4401 | else |
| @@ -4430,7 +4404,6 @@ w32_read_socket (sd, expected, hold_quit) | |||
| 4430 | in non-Unicode message handlers. */ | 4404 | in non-Unicode message handlers. */ |
| 4431 | DebPrint (("Non-byte WM_CHAR: %d\n", msg.msg.wParam)); | 4405 | DebPrint (("Non-byte WM_CHAR: %d\n", msg.msg.wParam)); |
| 4432 | inev.kind = NO_EVENT; | 4406 | inev.kind = NO_EVENT; |
| 4433 | break; | ||
| 4434 | } | 4407 | } |
| 4435 | } | 4408 | } |
| 4436 | break; | 4409 | break; |