comparison src/ccl.c @ 27650:b875236c7043

(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.
author Kenichi Handa <handa@m17n.org>
date Wed, 09 Feb 2000 12:20:01 +0000
parents d96c50f3e37e
children fe0206a9f10c
comparison
equal deleted inserted replaced
27649:248e0de1bae2 27650:b875236c7043
709 ic = ccl->eof_ic; \ 709 ic = ccl->eof_ic; \
710 goto ccl_repeat; \ 710 goto ccl_repeat; \
711 } \ 711 } \
712 else \ 712 else \
713 CCL_SUSPEND (CCL_STAT_SUSPEND_BY_SRC); \ 713 CCL_SUSPEND (CCL_STAT_SUSPEND_BY_SRC); \
714 } while (0)
715
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; \
714 } while (0) 739 } while (0)
715 740
716 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
1203 CCL_WRITE_CHAR (i); 1228 CCL_WRITE_CHAR (i);
1204 1229
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);
1221 if (j != -1) 1237 if (j != -1)
1222 i = (i << 7) | j; 1238 i = (i << 7) | j;
1225 break; 1241 break;
1226 1242
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)
1243 i = (i << 7) | j; 1250 i = (i << 7) | j;
1244 1251