diff options
| author | Kenichi Handa | 2003-05-01 04:34:57 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2003-05-01 04:34:57 +0000 |
| commit | b666620cdd330b6759d95339b52819b54ec217f3 (patch) | |
| tree | 8d065e95090d43ec609c0941adc7e6d853ca35b1 /src/coding.c | |
| parent | 6145460516d89ffb7d0d0e8d14916157be3edd26 (diff) | |
| download | emacs-b666620cdd330b6759d95339b52819b54ec217f3.tar.gz emacs-b666620cdd330b6759d95339b52819b54ec217f3.zip | |
(coding_system_accept_latin_extra_p): Delete this
function.
(find_safe_codings): Pay attention to
the property tranlsation-table-for-encode of each codings.
(syms_of_coding): Give Qtranslation_table the extra slot number 2.
Diffstat (limited to 'src/coding.c')
| -rw-r--r-- | src/coding.c | 99 |
1 files changed, 68 insertions, 31 deletions
diff --git a/src/coding.c b/src/coding.c index 9d1298ffff2..81464d2ce14 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -6397,30 +6397,10 @@ highest priority. */) | |||
| 6397 | STRING_MULTIBYTE (string)); | 6397 | STRING_MULTIBYTE (string)); |
| 6398 | } | 6398 | } |
| 6399 | 6399 | ||
| 6400 | static int coding_system_accept_latin_extra_p P_ ((Lisp_Object)); | ||
| 6401 | |||
| 6402 | static int | ||
| 6403 | coding_system_accept_latin_extra_p (coding_system) | ||
| 6404 | Lisp_Object coding_system; | ||
| 6405 | { | ||
| 6406 | Lisp_Object coding_spec, coding_type, flags; | ||
| 6407 | |||
| 6408 | coding_spec = Fget (coding_system, Qcoding_system); | ||
| 6409 | if (! VECTORP (coding_spec) | ||
| 6410 | || ASIZE (coding_spec) != 5) | ||
| 6411 | return 0; | ||
| 6412 | coding_type = AREF (coding_spec, 0); | ||
| 6413 | if (! EQ (coding_type, make_number (2))) | ||
| 6414 | return 0; | ||
| 6415 | flags = AREF (coding_spec, 4); | ||
| 6416 | return (VECTORP (flags) | ||
| 6417 | && ! NILP (AREF (flags, CODING_FLAG_ISO_LATIN_EXTRA))); | ||
| 6418 | } | ||
| 6419 | |||
| 6420 | /* Subroutine for Fsafe_coding_systems_region_internal. | 6400 | /* Subroutine for Fsafe_coding_systems_region_internal. |
| 6421 | 6401 | ||
| 6422 | Return a list of coding systems that safely encode the multibyte | 6402 | Return a list of coding systems that safely encode the multibyte |
| 6423 | text between P and PEND. SAFE_CODINGS, if non-nil, is a list of | 6403 | text between P and PEND. SAFE_CODINGS, if non-nil, is an alist of |
| 6424 | possible coding systems. If it is nil, it means that we have not | 6404 | possible coding systems. If it is nil, it means that we have not |
| 6425 | yet found any coding systems. | 6405 | yet found any coding systems. |
| 6426 | 6406 | ||
| @@ -6450,7 +6430,9 @@ find_safe_codings (p, pend, safe_codings, work_table, single_byte_char_found) | |||
| 6450 | if (SINGLE_BYTE_CHAR_P (c)) | 6430 | if (SINGLE_BYTE_CHAR_P (c)) |
| 6451 | *single_byte_char_found = 1; | 6431 | *single_byte_char_found = 1; |
| 6452 | if (NILP (safe_codings)) | 6432 | if (NILP (safe_codings)) |
| 6453 | /* Already all coding systems are excluded. */ | 6433 | /* Already all coding systems are excluded. But, we can't |
| 6434 | terminate the loop here because non-ASCII single-byte char | ||
| 6435 | must be found. */ | ||
| 6454 | continue; | 6436 | continue; |
| 6455 | /* Check the safe coding systems for C. */ | 6437 | /* Check the safe coding systems for C. */ |
| 6456 | ch = make_number (c); | 6438 | ch = make_number (c); |
| @@ -6463,12 +6445,69 @@ find_safe_codings (p, pend, safe_codings, work_table, single_byte_char_found) | |||
| 6463 | 6445 | ||
| 6464 | for (prev = tail = safe_codings; CONSP (tail); tail = XCDR (tail)) | 6446 | for (prev = tail = safe_codings; CONSP (tail); tail = XCDR (tail)) |
| 6465 | { | 6447 | { |
| 6466 | val = XCAR (tail); | 6448 | Lisp_Object elt, translation_table, hash_table, accept_latin_extra; |
| 6467 | if (NILP (Faref (XCDR (val), ch)) | 6449 | int encodable; |
| 6468 | && !(SINGLE_BYTE_CHAR_P (c) | 6450 | |
| 6469 | && VECTORP (Vlatin_extra_code_table) | 6451 | elt = XCAR (tail); |
| 6470 | && ! NILP (AREF (Vlatin_extra_code_table, c)) | 6452 | if (CONSP (XCDR (elt))) |
| 6471 | && coding_system_accept_latin_extra_p (XCAR (val)))) | 6453 | { |
| 6454 | /* This entry has this format now: | ||
| 6455 | ( CODING SAFE-CHARS TRANSLATION-TABLE HASH-TABLE | ||
| 6456 | ACCEPT-LATIN-EXTRA ) */ | ||
| 6457 | val = XCDR (elt); | ||
| 6458 | encodable = ! NILP (Faref (XCAR (val), ch)); | ||
| 6459 | if (! encodable) | ||
| 6460 | { | ||
| 6461 | val = XCDR (val); | ||
| 6462 | translation_table = XCAR (val); | ||
| 6463 | hash_table = XCAR (XCDR (val)); | ||
| 6464 | accept_latin_extra = XCAR (XCDR (XCDR (val))); | ||
| 6465 | } | ||
| 6466 | } | ||
| 6467 | else | ||
| 6468 | { | ||
| 6469 | /* This entry has this format now: ( CODING . SAFE-CHARS) */ | ||
| 6470 | encodable = ! NILP (Faref (XCDR (elt), ch)); | ||
| 6471 | if (! encodable) | ||
| 6472 | { | ||
| 6473 | /* Transform the format to: | ||
| 6474 | ( CODING SAFE-CHARS TRANSLATION-TABLE HASH-TABLE | ||
| 6475 | ACCEPT-LATIN-EXTRA ) */ | ||
| 6476 | val = Fget (XCAR (elt), Qcoding_system); | ||
| 6477 | translation_table | ||
| 6478 | = Fplist_get (AREF (val, 3), | ||
| 6479 | Qtranslation_table_for_encode); | ||
| 6480 | if (SYMBOLP (translation_table)) | ||
| 6481 | translation_table = Fget (translation_table, | ||
| 6482 | Qtranslation_table); | ||
| 6483 | hash_table | ||
| 6484 | = (CHAR_TABLE_P (translation_table) | ||
| 6485 | ? XCHAR_TABLE (translation_table)->extras[1] | ||
| 6486 | : Qnil); | ||
| 6487 | accept_latin_extra | ||
| 6488 | = ((EQ (AREF (val, 0), make_number (2)) | ||
| 6489 | && VECTORP (AREF (val, 4))) | ||
| 6490 | ? AREF (AREF (val, 4), CODING_FLAG_ISO_LATIN_EXTRA) | ||
| 6491 | : Qnil); | ||
| 6492 | XSETCAR (tail, list5 (XCAR (elt), XCDR (elt), | ||
| 6493 | translation_table, hash_table, | ||
| 6494 | accept_latin_extra)); | ||
| 6495 | } | ||
| 6496 | } | ||
| 6497 | |||
| 6498 | if (! encodable | ||
| 6499 | && ((CHAR_TABLE_P (translation_table) | ||
| 6500 | && ! NILP (Faref (translation_table, ch))) | ||
| 6501 | || (HASH_TABLE_P (hash_table) | ||
| 6502 | && ! NILP (Fgethash (ch, hash_table, Qnil))) | ||
| 6503 | || (SINGLE_BYTE_CHAR_P (c) | ||
| 6504 | && ! NILP (accept_latin_extra) | ||
| 6505 | && VECTORP (Vlatin_extra_code_table) | ||
| 6506 | && ! NILP (AREF (Vlatin_extra_code_table, c))))) | ||
| 6507 | encodable = 1; | ||
| 6508 | if (encodable) | ||
| 6509 | prev = tail; | ||
| 6510 | else | ||
| 6472 | { | 6511 | { |
| 6473 | /* Exclued this coding system from SAFE_CODINGS. */ | 6512 | /* Exclued this coding system from SAFE_CODINGS. */ |
| 6474 | if (EQ (tail, safe_codings)) | 6513 | if (EQ (tail, safe_codings)) |
| @@ -6476,8 +6515,6 @@ find_safe_codings (p, pend, safe_codings, work_table, single_byte_char_found) | |||
| 6476 | else | 6515 | else |
| 6477 | XSETCDR (prev, XCDR (tail)); | 6516 | XSETCDR (prev, XCDR (tail)); |
| 6478 | } | 6517 | } |
| 6479 | else | ||
| 6480 | prev = tail; | ||
| 6481 | } | 6518 | } |
| 6482 | } | 6519 | } |
| 6483 | return safe_codings; | 6520 | return safe_codings; |
| @@ -7398,7 +7435,7 @@ syms_of_coding () | |||
| 7398 | 7435 | ||
| 7399 | Qtranslation_table = intern ("translation-table"); | 7436 | Qtranslation_table = intern ("translation-table"); |
| 7400 | staticpro (&Qtranslation_table); | 7437 | staticpro (&Qtranslation_table); |
| 7401 | Fput (Qtranslation_table, Qchar_table_extra_slots, make_number (1)); | 7438 | Fput (Qtranslation_table, Qchar_table_extra_slots, make_number (2)); |
| 7402 | 7439 | ||
| 7403 | Qtranslation_table_id = intern ("translation-table-id"); | 7440 | Qtranslation_table_id = intern ("translation-table-id"); |
| 7404 | staticpro (&Qtranslation_table_id); | 7441 | staticpro (&Qtranslation_table_id); |