aboutsummaryrefslogtreecommitdiffstats
path: root/src/ccl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ccl.c')
-rw-r--r--src/ccl.c122
1 files changed, 63 insertions, 59 deletions
diff --git a/src/ccl.c b/src/ccl.c
index bc6322c35b9..5da90ad4f04 100644
--- a/src/ccl.c
+++ b/src/ccl.c
@@ -762,9 +762,6 @@ while (0)
762#define GET_CCL_CODE(code, ccl_prog, ic) \ 762#define GET_CCL_CODE(code, ccl_prog, ic) \
763 GET_CCL_RANGE (code, ccl_prog, ic, CCL_CODE_MIN, CCL_CODE_MAX) 763 GET_CCL_RANGE (code, ccl_prog, ic, CCL_CODE_MIN, CCL_CODE_MAX)
764 764
765#define GET_CCL_INT(var, ccl_prog, ic) \
766 GET_CCL_RANGE (var, ccl_prog, ic, INT_MIN, INT_MAX)
767
768#define IN_INT_RANGE(val) ASCENDING_ORDER (INT_MIN, val, INT_MAX) 765#define IN_INT_RANGE(val) ASCENDING_ORDER (INT_MIN, val, INT_MAX)
769 766
770/* Encode one character CH to multibyte form and write to the current 767/* Encode one character CH to multibyte form and write to the current
@@ -945,14 +942,14 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
945 break; 942 break;
946 943
947 case CCL_SetConst: /* 00000000000000000000rrrXXXXX */ 944 case CCL_SetConst: /* 00000000000000000000rrrXXXXX */
948 GET_CCL_INT (reg[rrr], ccl_prog, ic++); 945 reg[rrr] = XINT (ccl_prog[ic++]);
949 break; 946 break;
950 947
951 case CCL_SetArray: /* CCCCCCCCCCCCCCCCCCCCRRRrrrXXXXX */ 948 case CCL_SetArray: /* CCCCCCCCCCCCCCCCCCCCRRRrrrXXXXX */
952 i = reg[RRR]; 949 i = reg[RRR];
953 j = field1 >> 3; 950 j = field1 >> 3;
954 if (0 <= i && i < j) 951 if (0 <= i && i < j)
955 GET_CCL_INT (reg[rrr], ccl_prog, ic + i); 952 reg[rrr] = XINT (ccl_prog[ic + i]);
956 ic += j; 953 ic += j;
957 break; 954 break;
958 955
@@ -980,13 +977,13 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
980 break; 977 break;
981 978
982 case CCL_WriteConstJump: /* A--D--D--R--E--S--S-000XXXXX */ 979 case CCL_WriteConstJump: /* A--D--D--R--E--S--S-000XXXXX */
983 GET_CCL_INT (i, ccl_prog, ic); 980 i = XINT (ccl_prog[ic]);
984 CCL_WRITE_CHAR (i); 981 CCL_WRITE_CHAR (i);
985 ic += ADDR; 982 ic += ADDR;
986 break; 983 break;
987 984
988 case CCL_WriteConstReadJump: /* A--D--D--R--E--S--S-rrrXXXXX */ 985 case CCL_WriteConstReadJump: /* A--D--D--R--E--S--S-rrrXXXXX */
989 GET_CCL_INT (i, ccl_prog, ic); 986 i = XINT (ccl_prog[ic]);
990 CCL_WRITE_CHAR (i); 987 CCL_WRITE_CHAR (i);
991 ic++; 988 ic++;
992 CCL_READ_CHAR (reg[rrr]); 989 CCL_READ_CHAR (reg[rrr]);
@@ -994,17 +991,17 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
994 break; 991 break;
995 992
996 case CCL_WriteStringJump: /* A--D--D--R--E--S--S-000XXXXX */ 993 case CCL_WriteStringJump: /* A--D--D--R--E--S--S-000XXXXX */
997 GET_CCL_INT (j, ccl_prog, ic++); 994 j = XINT (ccl_prog[ic++]);
998 CCL_WRITE_STRING (j); 995 CCL_WRITE_STRING (j);
999 ic += ADDR - 1; 996 ic += ADDR - 1;
1000 break; 997 break;
1001 998
1002 case CCL_WriteArrayReadJump: /* A--D--D--R--E--S--S-rrrXXXXX */ 999 case CCL_WriteArrayReadJump: /* A--D--D--R--E--S--S-rrrXXXXX */
1003 i = reg[rrr]; 1000 i = reg[rrr];
1004 GET_CCL_INT (j, ccl_prog, ic); 1001 j = XINT (ccl_prog[ic]);
1005 if (0 <= i && i < j) 1002 if (0 <= i && i < j)
1006 { 1003 {
1007 GET_CCL_INT (i, ccl_prog, ic + 1 + i); 1004 i = XINT (ccl_prog[ic + 1 + i]);
1008 CCL_WRITE_CHAR (i); 1005 CCL_WRITE_CHAR (i);
1009 } 1006 }
1010 ic += j + 2; 1007 ic += j + 2;
@@ -1022,11 +1019,8 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
1022 /* fall through ... */ 1019 /* fall through ... */
1023 case CCL_Branch: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */ 1020 case CCL_Branch: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */
1024 { 1021 {
1025 int incr; 1022 int ioff = 0 <= reg[rrr] && reg[rrr] < field1 ? reg[rrr] : field1;
1026 GET_CCL_INT (incr, ccl_prog, 1023 int incr = XINT (ccl_prog[ic + ioff]);
1027 ic + (0 <= reg[rrr] && reg[rrr] < field1
1028 ? reg[rrr]
1029 : field1));
1030 ic += incr; 1024 ic += incr;
1031 } 1025 }
1032 break; 1026 break;
@@ -1045,7 +1039,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
1045 case CCL_WriteExprConst: /* 1:00000OPERATION000RRR000XXXXX */ 1039 case CCL_WriteExprConst: /* 1:00000OPERATION000RRR000XXXXX */
1046 rrr = 7; 1040 rrr = 7;
1047 i = reg[RRR]; 1041 i = reg[RRR];
1048 GET_CCL_INT (j, ccl_prog, ic); 1042 j = XINT (ccl_prog[ic]);
1049 op = field1 >> 6; 1043 op = field1 >> 6;
1050 jump_address = ic + 1; 1044 jump_address = ic + 1;
1051 goto ccl_set_expr; 1045 goto ccl_set_expr;
@@ -1078,7 +1072,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
1078 /* If FFF is nonzero, the CCL program ID is in the 1072 /* If FFF is nonzero, the CCL program ID is in the
1079 following code. */ 1073 following code. */
1080 if (rrr) 1074 if (rrr)
1081 GET_CCL_INT (prog_id, ccl_prog, ic++); 1075 prog_id = XINT (ccl_prog[ic++]);
1082 else 1076 else
1083 prog_id = field1; 1077 prog_id = field1;
1084 1078
@@ -1121,7 +1115,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
1121 i = reg[rrr]; 1115 i = reg[rrr];
1122 if (0 <= i && i < field1) 1116 if (0 <= i && i < field1)
1123 { 1117 {
1124 GET_CCL_INT (j, ccl_prog, ic + i); 1118 j = XINT (ccl_prog[ic + i]);
1125 CCL_WRITE_CHAR (j); 1119 CCL_WRITE_CHAR (j);
1126 } 1120 }
1127 ic += field1; 1121 ic += field1;
@@ -1146,7 +1140,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
1146 CCL_SUCCESS; 1140 CCL_SUCCESS;
1147 1141
1148 case CCL_ExprSelfConst: /* 00000OPERATION000000rrrXXXXX */ 1142 case CCL_ExprSelfConst: /* 00000OPERATION000000rrrXXXXX */
1149 GET_CCL_INT (i, ccl_prog, ic++); 1143 i = XINT (ccl_prog[ic++]);
1150 op = field1 >> 6; 1144 op = field1 >> 6;
1151 goto ccl_expr_self; 1145 goto ccl_expr_self;
1152 1146
@@ -1182,7 +1176,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
1182 1176
1183 case CCL_SetExprConst: /* 00000OPERATION000RRRrrrXXXXX */ 1177 case CCL_SetExprConst: /* 00000OPERATION000RRRrrrXXXXX */
1184 i = reg[RRR]; 1178 i = reg[RRR];
1185 GET_CCL_INT (j, ccl_prog, ic++); 1179 j = XINT (ccl_prog[ic++]);
1186 op = field1 >> 6; 1180 op = field1 >> 6;
1187 jump_address = ic; 1181 jump_address = ic;
1188 goto ccl_set_expr; 1182 goto ccl_set_expr;
@@ -1199,8 +1193,8 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
1199 case CCL_JumpCondExprConst: /* A--D--D--R--E--S--S-rrrXXXXX */ 1193 case CCL_JumpCondExprConst: /* A--D--D--R--E--S--S-rrrXXXXX */
1200 i = reg[rrr]; 1194 i = reg[rrr];
1201 jump_address = ic + ADDR; 1195 jump_address = ic + ADDR;
1202 GET_CCL_INT (op, ccl_prog, ic++); 1196 op = XINT (ccl_prog[ic++]);
1203 GET_CCL_INT (j, ccl_prog, ic++); 1197 j = XINT (ccl_prog[ic++]);
1204 rrr = 7; 1198 rrr = 7;
1205 goto ccl_set_expr; 1199 goto ccl_set_expr;
1206 1200
@@ -1209,7 +1203,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
1209 case CCL_JumpCondExprReg: 1203 case CCL_JumpCondExprReg:
1210 i = reg[rrr]; 1204 i = reg[rrr];
1211 jump_address = ic + ADDR; 1205 jump_address = ic + ADDR;
1212 GET_CCL_INT (op, ccl_prog, ic++); 1206 op = XINT (ccl_prog[ic++]);
1213 GET_CCL_RANGE (j, ccl_prog, ic++, 0, 7); 1207 GET_CCL_RANGE (j, ccl_prog, ic++, 0, 7);
1214 j = reg[j]; 1208 j = reg[j];
1215 rrr = 7; 1209 rrr = 7;
@@ -1290,7 +1284,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
1290 1284
1291 case CCL_TranslateCharacterConstTbl: 1285 case CCL_TranslateCharacterConstTbl:
1292 { 1286 {
1293 EMACS_INT eop; 1287 ptrdiff_t eop;
1294 GET_CCL_RANGE (eop, ccl_prog, ic++, 0, 1288 GET_CCL_RANGE (eop, ccl_prog, ic++, 0,
1295 (VECTORP (Vtranslation_table_vector) 1289 (VECTORP (Vtranslation_table_vector)
1296 ? ASIZE (Vtranslation_table_vector) 1290 ? ASIZE (Vtranslation_table_vector)
@@ -1356,10 +1350,11 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
1356 case CCL_IterateMultipleMap: 1350 case CCL_IterateMultipleMap:
1357 { 1351 {
1358 Lisp_Object map, content, attrib, value; 1352 Lisp_Object map, content, attrib, value;
1359 EMACS_INT point, size; 1353 EMACS_INT point;
1354 ptrdiff_t size;
1360 int fin_ic; 1355 int fin_ic;
1361 1356
1362 GET_CCL_INT (j, ccl_prog, ic++); /* number of maps. */ 1357 j = XINT (ccl_prog[ic++]); /* number of maps. */
1363 fin_ic = ic + j; 1358 fin_ic = ic + j;
1364 op = reg[rrr]; 1359 op = reg[rrr];
1365 if ((j > reg[RRR]) && (j >= 0)) 1360 if ((j > reg[RRR]) && (j >= 0))
@@ -1376,7 +1371,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
1376 1371
1377 for (;i < j;i++) 1372 for (;i < j;i++)
1378 { 1373 {
1379 1374 if (!VECTORP (Vcode_conversion_map_vector)) continue;
1380 size = ASIZE (Vcode_conversion_map_vector); 1375 size = ASIZE (Vcode_conversion_map_vector);
1381 point = XINT (ccl_prog[ic++]); 1376 point = XINT (ccl_prog[ic++]);
1382 if (! (0 <= point && point < size)) continue; 1377 if (! (0 <= point && point < size)) continue;
@@ -1452,7 +1447,8 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
1452 case CCL_MapMultiple: 1447 case CCL_MapMultiple:
1453 { 1448 {
1454 Lisp_Object map, content, attrib, value; 1449 Lisp_Object map, content, attrib, value;
1455 int point, size, map_vector_size; 1450 EMACS_INT point;
1451 ptrdiff_t size, map_vector_size;
1456 int map_set_rest_length, fin_ic; 1452 int map_set_rest_length, fin_ic;
1457 int current_ic = this_ic; 1453 int current_ic = this_ic;
1458 1454
@@ -1471,7 +1467,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
1471 stack_idx_of_map_multiple = 0; 1467 stack_idx_of_map_multiple = 0;
1472 1468
1473 /* Get number of maps and separators. */ 1469 /* Get number of maps and separators. */
1474 GET_CCL_INT (map_set_rest_length, ccl_prog, ic++); 1470 map_set_rest_length = XINT (ccl_prog[ic++]);
1475 1471
1476 fin_ic = ic + map_set_rest_length; 1472 fin_ic = ic + map_set_rest_length;
1477 op = reg[rrr]; 1473 op = reg[rrr];
@@ -1535,12 +1531,14 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
1535 break; 1531 break;
1536 } 1532 }
1537 } 1533 }
1534 if (!VECTORP (Vcode_conversion_map_vector))
1535 CCL_INVALID_CMD;
1538 map_vector_size = ASIZE (Vcode_conversion_map_vector); 1536 map_vector_size = ASIZE (Vcode_conversion_map_vector);
1539 1537
1540 do { 1538 do {
1541 for (;map_set_rest_length > 0;i++, ic++, map_set_rest_length--) 1539 for (;map_set_rest_length > 0;i++, ic++, map_set_rest_length--)
1542 { 1540 {
1543 GET_CCL_INT (point, ccl_prog, ic); 1541 point = XINT (ccl_prog[ic]);
1544 if (point < 0) 1542 if (point < 0)
1545 { 1543 {
1546 /* +1 is for including separator. */ 1544 /* +1 is for including separator. */
@@ -1657,7 +1655,8 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
1657 int point; 1655 int point;
1658 j = XINT (ccl_prog[ic++]); /* map_id */ 1656 j = XINT (ccl_prog[ic++]); /* map_id */
1659 op = reg[rrr]; 1657 op = reg[rrr];
1660 if (j >= ASIZE (Vcode_conversion_map_vector)) 1658 if (! (VECTORP (Vcode_conversion_map_vector)
1659 && j < ASIZE (Vcode_conversion_map_vector)))
1661 { 1660 {
1662 reg[RRR] = -1; 1661 reg[RRR] = -1;
1663 break; 1662 break;
@@ -1670,6 +1669,7 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
1670 } 1669 }
1671 map = XCDR (map); 1670 map = XCDR (map);
1672 if (! (VECTORP (map) 1671 if (! (VECTORP (map)
1672 && 0 < ASIZE (map)
1673 && INTEGERP (AREF (map, 0)) 1673 && INTEGERP (AREF (map, 0))
1674 && XINT (AREF (map, 0)) <= op 1674 && XINT (AREF (map, 0)) <= op
1675 && op - XINT (AREF (map, 0)) + 1 < ASIZE (map))) 1675 && op - XINT (AREF (map, 0)) + 1 < ASIZE (map)))
@@ -1677,20 +1677,20 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
1677 reg[RRR] = -1; 1677 reg[RRR] = -1;
1678 break; 1678 break;
1679 } 1679 }
1680 point = XINT (AREF (map, 0)); 1680 point = op - XINT (AREF (map, 0)) + 1;
1681 point = op - point + 1;
1682 reg[RRR] = 0; 1681 reg[RRR] = 0;
1683 content = AREF (map, point); 1682 content = AREF (map, point);
1684 if (NILP (content)) 1683 if (NILP (content))
1685 reg[RRR] = -1; 1684 reg[RRR] = -1;
1686 else if (INTEGERP (content)) 1685 else if (TYPE_RANGED_INTEGERP (int, content))
1687 reg[rrr] = XINT (content); 1686 reg[rrr] = XINT (content);
1688 else if (EQ (content, Qt)); 1687 else if (EQ (content, Qt));
1689 else if (CONSP (content)) 1688 else if (CONSP (content))
1690 { 1689 {
1691 attrib = XCAR (content); 1690 attrib = XCAR (content);
1692 value = XCDR (content); 1691 value = XCDR (content);
1693 if (!INTEGERP (attrib) || !INTEGERP (value)) 1692 if (!INTEGERP (attrib)
1693 || !TYPE_RANGED_INTEGERP (int, value))
1694 continue; 1694 continue;
1695 reg[rrr] = XINT (value); 1695 reg[rrr] = XINT (value);
1696 break; 1696 break;
@@ -1810,8 +1810,8 @@ ccl_driver (struct ccl_program *ccl, int *source, int *destination, int src_size
1810 function converts symbols of code conversion maps and character 1810 function converts symbols of code conversion maps and character
1811 translation tables embedded in the CCL code into their ID numbers. 1811 translation tables embedded in the CCL code into their ID numbers.
1812 1812
1813 The return value is a vector (CCL itself or a new vector in which 1813 The return value is a new vector in which all symbols are resolved,
1814 all symbols are resolved), Qt if resolving of some symbol failed, 1814 Qt if resolving of some symbol failed,
1815 or nil if CCL contains invalid data. */ 1815 or nil if CCL contains invalid data. */
1816 1816
1817static Lisp_Object 1817static Lisp_Object
@@ -1820,13 +1820,15 @@ resolve_symbol_ccl_program (Lisp_Object ccl)
1820 int i, veclen, unresolved = 0; 1820 int i, veclen, unresolved = 0;
1821 Lisp_Object result, contents, val; 1821 Lisp_Object result, contents, val;
1822 1822
1823 result = ccl; 1823 if (! (CCL_HEADER_MAIN < ASIZE (ccl) && ASIZE (ccl) <= INT_MAX))
1824 return Qnil;
1825 result = Fcopy_sequence (ccl);
1824 veclen = ASIZE (result); 1826 veclen = ASIZE (result);
1825 1827
1826 for (i = 0; i < veclen; i++) 1828 for (i = 0; i < veclen; i++)
1827 { 1829 {
1828 contents = AREF (result, i); 1830 contents = AREF (result, i);
1829 if (INTEGERP (contents)) 1831 if (TYPE_RANGED_INTEGERP (int, contents))
1830 continue; 1832 continue;
1831 else if (CONSP (contents) 1833 else if (CONSP (contents)
1832 && SYMBOLP (XCAR (contents)) 1834 && SYMBOLP (XCAR (contents))
@@ -1835,12 +1837,8 @@ resolve_symbol_ccl_program (Lisp_Object ccl)
1835 /* This is the new style for embedding symbols. The form is 1837 /* This is the new style for embedding symbols. The form is
1836 (SYMBOL . PROPERTY). (get SYMBOL PROPERTY) should give 1838 (SYMBOL . PROPERTY). (get SYMBOL PROPERTY) should give
1837 an index number. */ 1839 an index number. */
1838
1839 if (EQ (result, ccl))
1840 result = Fcopy_sequence (ccl);
1841
1842 val = Fget (XCAR (contents), XCDR (contents)); 1840 val = Fget (XCAR (contents), XCDR (contents));
1843 if (NATNUMP (val)) 1841 if (RANGED_INTEGERP (0, val, INT_MAX))
1844 ASET (result, i, val); 1842 ASET (result, i, val);
1845 else 1843 else
1846 unresolved = 1; 1844 unresolved = 1;
@@ -1851,21 +1849,18 @@ resolve_symbol_ccl_program (Lisp_Object ccl)
1851 /* This is the old style for embedding symbols. This style 1849 /* This is the old style for embedding symbols. This style
1852 may lead to a bug if, for instance, a translation table 1850 may lead to a bug if, for instance, a translation table
1853 and a code conversion map have the same name. */ 1851 and a code conversion map have the same name. */
1854 if (EQ (result, ccl))
1855 result = Fcopy_sequence (ccl);
1856
1857 val = Fget (contents, Qtranslation_table_id); 1852 val = Fget (contents, Qtranslation_table_id);
1858 if (NATNUMP (val)) 1853 if (RANGED_INTEGERP (0, val, INT_MAX))
1859 ASET (result, i, val); 1854 ASET (result, i, val);
1860 else 1855 else
1861 { 1856 {
1862 val = Fget (contents, Qcode_conversion_map_id); 1857 val = Fget (contents, Qcode_conversion_map_id);
1863 if (NATNUMP (val)) 1858 if (RANGED_INTEGERP (0, val, INT_MAX))
1864 ASET (result, i, val); 1859 ASET (result, i, val);
1865 else 1860 else
1866 { 1861 {
1867 val = Fget (contents, Qccl_program_idx); 1862 val = Fget (contents, Qccl_program_idx);
1868 if (NATNUMP (val)) 1863 if (RANGED_INTEGERP (0, val, INT_MAX))
1869 ASET (result, i, val); 1864 ASET (result, i, val);
1870 else 1865 else
1871 unresolved = 1; 1866 unresolved = 1;
@@ -1876,6 +1871,11 @@ resolve_symbol_ccl_program (Lisp_Object ccl)
1876 return Qnil; 1871 return Qnil;
1877 } 1872 }
1878 1873
1874 if (! (0 <= XINT (AREF (result, CCL_HEADER_BUF_MAG))
1875 && ASCENDING_ORDER (0, XINT (AREF (result, CCL_HEADER_EOF)),
1876 ASIZE (ccl))))
1877 return Qnil;
1878
1879 return (unresolved ? Qt : result); 1879 return (unresolved ? Qt : result);
1880} 1880}
1881 1881
@@ -1886,7 +1886,7 @@ resolve_symbol_ccl_program (Lisp_Object ccl)
1886 symbols, return Qnil. */ 1886 symbols, return Qnil. */
1887 1887
1888static Lisp_Object 1888static Lisp_Object
1889ccl_get_compiled_code (Lisp_Object ccl_prog, int *idx) 1889ccl_get_compiled_code (Lisp_Object ccl_prog, ptrdiff_t *idx)
1890{ 1890{
1891 Lisp_Object val, slot; 1891 Lisp_Object val, slot;
1892 1892
@@ -2015,7 +2015,7 @@ programs. */)
2015 error ("Length of vector REGISTERS is not 8"); 2015 error ("Length of vector REGISTERS is not 8");
2016 2016
2017 for (i = 0; i < 8; i++) 2017 for (i = 0; i < 8; i++)
2018 ccl.reg[i] = (INTEGERP (AREF (reg, i)) 2018 ccl.reg[i] = (TYPE_RANGED_INTEGERP (int, AREF (reg, i))
2019 ? XINT (AREF (reg, i)) 2019 ? XINT (AREF (reg, i))
2020 : 0); 2020 : 0);
2021 2021
@@ -2084,7 +2084,7 @@ usage: (ccl-execute-on-string CCL-PROGRAM STATUS STRING &optional CONTINUE UNIBY
2084 { 2084 {
2085 if (NILP (AREF (status, i))) 2085 if (NILP (AREF (status, i)))
2086 ASET (status, i, make_number (0)); 2086 ASET (status, i, make_number (0));
2087 if (INTEGERP (AREF (status, i))) 2087 if (TYPE_RANGED_INTEGERP (int, AREF (status, i)))
2088 ccl.reg[i] = XINT (AREF (status, i)); 2088 ccl.reg[i] = XINT (AREF (status, i));
2089 } 2089 }
2090 if (INTEGERP (AREF (status, i))) 2090 if (INTEGERP (AREF (status, i)))
@@ -2187,8 +2187,8 @@ If it is nil, just reserve NAME as a CCL program name.
2187Return index number of the registered CCL program. */) 2187Return index number of the registered CCL program. */)
2188 (Lisp_Object name, Lisp_Object ccl_prog) 2188 (Lisp_Object name, Lisp_Object ccl_prog)
2189{ 2189{
2190 int len = ASIZE (Vccl_program_table); 2190 ptrdiff_t len = ASIZE (Vccl_program_table);
2191 int idx; 2191 ptrdiff_t idx;
2192 Lisp_Object resolved; 2192 Lisp_Object resolved;
2193 2193
2194 CHECK_SYMBOL (name); 2194 CHECK_SYMBOL (name);
@@ -2229,7 +2229,7 @@ Return index number of the registered CCL program. */)
2229 2229
2230 if (idx == len) 2230 if (idx == len)
2231 /* Extend the table. */ 2231 /* Extend the table. */
2232 Vccl_program_table = larger_vector (Vccl_program_table, len * 2, Qnil); 2232 Vccl_program_table = larger_vector (Vccl_program_table, 1, -1);
2233 2233
2234 { 2234 {
2235 Lisp_Object elt; 2235 Lisp_Object elt;
@@ -2262,12 +2262,16 @@ DEFUN ("register-code-conversion-map", Fregister_code_conversion_map,
2262Return index number of the registered map. */) 2262Return index number of the registered map. */)
2263 (Lisp_Object symbol, Lisp_Object map) 2263 (Lisp_Object symbol, Lisp_Object map)
2264{ 2264{
2265 int len = ASIZE (Vcode_conversion_map_vector); 2265 ptrdiff_t len;
2266 int i; 2266 ptrdiff_t i;
2267 Lisp_Object idx; 2267 Lisp_Object idx;
2268 2268
2269 CHECK_SYMBOL (symbol); 2269 CHECK_SYMBOL (symbol);
2270 CHECK_VECTOR (map); 2270 CHECK_VECTOR (map);
2271 if (! VECTORP (Vcode_conversion_map_vector))
2272 error ("Invalid code-conversion-map-vector");
2273
2274 len = ASIZE (Vcode_conversion_map_vector);
2271 2275
2272 for (i = 0; i < len; i++) 2276 for (i = 0; i < len; i++)
2273 { 2277 {
@@ -2288,7 +2292,7 @@ Return index number of the registered map. */)
2288 2292
2289 if (i == len) 2293 if (i == len)
2290 Vcode_conversion_map_vector = larger_vector (Vcode_conversion_map_vector, 2294 Vcode_conversion_map_vector = larger_vector (Vcode_conversion_map_vector,
2291 len * 2, Qnil); 2295 1, -1);
2292 2296
2293 idx = make_number (i); 2297 idx = make_number (i);
2294 Fput (symbol, Qcode_conversion_map, map); 2298 Fput (symbol, Qcode_conversion_map, map);