diff options
| author | Kenichi Handa | 2000-02-09 12:20:01 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2000-02-09 12:20:01 +0000 |
| commit | 4ffd487076136233213cb1c28df30bb23f4b4926 (patch) | |
| tree | 92568a8886b12f7f8c9676452abe73e64f107d04 | |
| parent | 5e1cddda2b88b41743aa89b134bce7c453c23679 (diff) | |
| download | emacs-4ffd487076136233213cb1c28df30bb23f4b4926.tar.gz emacs-4ffd487076136233213cb1c28df30bb23f4b4926.zip | |
(CCL_MAKE_CHAR): New macro.
(ccl_driver) <CCL_TranslateCharacter>: Check the validity of
registers by CCL_MAKE_CHAR before calling translate_char.
<CCL_TranslateCharacterConstTbl> Likewise.
| -rw-r--r-- | src/ccl.c | 47 |
1 files changed, 27 insertions, 20 deletions
| @@ -714,6 +714,31 @@ static tr_stack *mapping_stack_pointer; | |||
| 714 | } while (0) | 714 | } while (0) |
| 715 | 715 | ||
| 716 | 716 | ||
| 717 | /* Set C to the character code made from CHARSET and CODE. This is | ||
| 718 | like MAKE_CHAR but check the validity of CHARSET and CODE. If they | ||
| 719 | are not valid, set C to (CODE & 0xFF) because that is usually the | ||
| 720 | case that CCL_ReadMultibyteChar2 read an invalid code and it set | ||
| 721 | CODE to that invalid byte. */ | ||
| 722 | |||
| 723 | #define CCL_MAKE_CHAR(charset, code, c) \ | ||
| 724 | do { \ | ||
| 725 | if (charset == CHARSET_ASCII) \ | ||
| 726 | c = code & 0xFF; \ | ||
| 727 | else if (CHARSET_DEFINED_P (charset) \ | ||
| 728 | && (code & 0x7F) >= 32 \ | ||
| 729 | && (code < 256 || ((code >> 7) & 0x7F) >= 32)) \ | ||
| 730 | { \ | ||
| 731 | int c1 = code & 0x7F, c2 = 0; \ | ||
| 732 | \ | ||
| 733 | if (code >= 256) \ | ||
| 734 | c2 = c1, c1 = (code >> 7) & 0x7F; \ | ||
| 735 | c = MAKE_NON_ASCII_CHAR (charset, c1, c2); \ | ||
| 736 | } \ | ||
| 737 | else \ | ||
| 738 | c = code & 0xFF; \ | ||
| 739 | } while (0) | ||
| 740 | |||
| 741 | |||
| 717 | /* Execute CCL code on SRC_BYTES length text at SOURCE. The resulting | 742 | /* Execute CCL code on SRC_BYTES length text at SOURCE. The resulting |
| 718 | text goes to a place pointed by DESTINATION, the length of which | 743 | text goes to a place pointed by DESTINATION, the length of which |
| 719 | should not exceed DST_BYTES. The bytes actually processed is | 744 | should not exceed DST_BYTES. The bytes actually processed is |
| @@ -1205,16 +1230,7 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed) | |||
| 1205 | break; | 1230 | break; |
| 1206 | 1231 | ||
| 1207 | case CCL_TranslateCharacter: | 1232 | case CCL_TranslateCharacter: |
| 1208 | i = reg[RRR]; /* charset */ | 1233 | CCL_MAKE_CHAR (reg[RRR], reg[rrr], i); |
| 1209 | if (i == CHARSET_ASCII) | ||
| 1210 | i = reg[rrr]; | ||
| 1211 | else if (CHARSET_DIMENSION (i) == 1) | ||
| 1212 | i = ((i - 0x70) << 7) | (reg[rrr] & 0x7F); | ||
| 1213 | else if (i < MIN_CHARSET_PRIVATE_DIMENSION2) | ||
| 1214 | i = ((i - 0x8F) << 14) | (reg[rrr] & 0x3FFF); | ||
| 1215 | else | ||
| 1216 | i = ((i - 0xE0) << 14) | (reg[rrr] & 0x3FFF); | ||
| 1217 | |||
| 1218 | op = translate_char (GET_TRANSLATION_TABLE (reg[Rrr]), | 1234 | op = translate_char (GET_TRANSLATION_TABLE (reg[Rrr]), |
| 1219 | i, -1, 0, 0); | 1235 | i, -1, 0, 0); |
| 1220 | SPLIT_CHAR (op, reg[RRR], i, j); | 1236 | SPLIT_CHAR (op, reg[RRR], i, j); |
| @@ -1227,16 +1243,7 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed) | |||
| 1227 | case CCL_TranslateCharacterConstTbl: | 1243 | case CCL_TranslateCharacterConstTbl: |
| 1228 | op = XINT (ccl_prog[ic]); /* table */ | 1244 | op = XINT (ccl_prog[ic]); /* table */ |
| 1229 | ic++; | 1245 | ic++; |
| 1230 | i = reg[RRR]; /* charset */ | 1246 | CCL_MAKE_CHAR (reg[RRR], reg[rrr], i); |
| 1231 | if (i == CHARSET_ASCII) | ||
| 1232 | i = reg[rrr]; | ||
| 1233 | else if (CHARSET_DIMENSION (i) == 1) | ||
| 1234 | i = ((i - 0x70) << 7) | (reg[rrr] & 0x7F); | ||
| 1235 | else if (i < MIN_CHARSET_PRIVATE_DIMENSION2) | ||
| 1236 | i = ((i - 0x8F) << 14) | (reg[rrr] & 0x3FFF); | ||
| 1237 | else | ||
| 1238 | i = ((i - 0xE0) << 14) | (reg[rrr] & 0x3FFF); | ||
| 1239 | |||
| 1240 | op = translate_char (GET_TRANSLATION_TABLE (op), i, -1, 0, 0); | 1247 | op = translate_char (GET_TRANSLATION_TABLE (op), i, -1, 0, 0); |
| 1241 | SPLIT_CHAR (op, reg[RRR], i, j); | 1248 | SPLIT_CHAR (op, reg[RRR], i, j); |
| 1242 | if (j != -1) | 1249 | if (j != -1) |