comparison src/mule-ccl.c @ 4193:6438d53aabcf

[xemacs-hg @ 2007-09-30 11:37:59 by aidan] Merge a CCL bugfix from GNU.
author aidan
date Sun, 30 Sep 2007 11:38:00 +0000
parents 76737c305982
children eded49463f9a
comparison
equal deleted inserted replaced
4192:203027d0f2cd 4193:6438d53aabcf
632 { \ 632 { \
633 if (stack_idx > 0) \ 633 if (stack_idx > 0) \
634 { \ 634 { \
635 ccl_prog = ccl_prog_stack_struct[0].ccl_prog; \ 635 ccl_prog = ccl_prog_stack_struct[0].ccl_prog; \
636 ic = ccl_prog_stack_struct[0].ic; \ 636 ic = ccl_prog_stack_struct[0].ic; \
637 eof_ic = ccl_prog_stack_struct[0].eof_ic; \
637 } \ 638 } \
638 CCL_INVALID_CMD; \ 639 CCL_INVALID_CMD; \
639 } \ 640 } \
640 ccl_prog_stack_struct[stack_idx].ccl_prog = ccl_prog; \ 641 ccl_prog_stack_struct[stack_idx].ccl_prog = ccl_prog; \
641 ccl_prog_stack_struct[stack_idx].ic = (ret_ic); \ 642 ccl_prog_stack_struct[stack_idx].ic = (ret_ic); \
643 ccl_prog_stack_struct[stack_idx].eof_ic = eof_ic; \
642 stack_idx++; \ 644 stack_idx++; \
643 ccl_prog = called_ccl.prog; \ 645 ccl_prog = called_ccl.prog; \
644 ic = CCL_HEADER_MAIN; \ 646 ic = CCL_HEADER_MAIN; \
647 eof_ic = XINT (ccl_prog[CCL_HEADER_EOF]); \
645 /* The "if (1)" prevents warning \ 648 /* The "if (1)" prevents warning \
646 "end-of loop code not reached" */ \ 649 "end-of loop code not reached" */ \
647 if (1) goto ccl_repeat; \ 650 if (1) goto ccl_repeat; \
648 } while (0) 651 } while (0)
649 652
924 927
925 struct ccl_prog_stack 928 struct ccl_prog_stack
926 { 929 {
927 Lisp_Object *ccl_prog; /* Pointer to an array of CCL code. */ 930 Lisp_Object *ccl_prog; /* Pointer to an array of CCL code. */
928 int ic; /* Instruction Counter. */ 931 int ic; /* Instruction Counter. */
932 int eof_ic; /* Instruction Counter to jump on EOF. */
929 }; 933 };
930 934
931 /* For the moment, we only support depth 256 of stack. */ 935 /* For the moment, we only support depth 256 of stack. */
932 static struct ccl_prog_stack ccl_prog_stack_struct[256]; 936 static struct ccl_prog_stack ccl_prog_stack_struct[256];
933 937
948 int jump_address; 952 int jump_address;
949 int i, j, op; 953 int i, j, op;
950 int stack_idx = ccl->stack_idx; 954 int stack_idx = ccl->stack_idx;
951 /* Instruction counter of the current CCL code. */ 955 /* Instruction counter of the current CCL code. */
952 int this_ic = 0; 956 int this_ic = 0;
953 957 int eof_ic = ccl->eof_ic;
954 if (ic >= ccl->eof_ic) 958 int eof_hit = 0;
959 static int ccl_driver_calls;
960
961 if (ic >= eof_ic)
955 ic = CCL_HEADER_MAIN; 962 ic = CCL_HEADER_MAIN;
956 963
957 if (ccl->buf_magnification ==0) /* We can't produce any bytes. */ 964 if (ccl->buf_magnification ==0) /* We can't produce any bytes. */
958 destination = NULL; 965 destination = NULL;
959 966
961 mapping_stack_pointer = mapping_stack; 968 mapping_stack_pointer = mapping_stack;
962 969
963 #ifdef CCL_DEBUG 970 #ifdef CCL_DEBUG
964 ccl_backtrace_idx = 0; 971 ccl_backtrace_idx = 0;
965 #endif 972 #endif
973
974 ++ccl_driver_calls;
966 975
967 for (;;) 976 for (;;)
968 { 977 {
969 ccl_repeat: 978 ccl_repeat:
970 #ifdef CCL_DEBUG 979 #ifdef CCL_DEBUG
1159 { 1168 {
1160 if (stack_idx > 0) 1169 if (stack_idx > 0)
1161 { 1170 {
1162 ccl_prog = ccl_prog_stack_struct[0].ccl_prog; 1171 ccl_prog = ccl_prog_stack_struct[0].ccl_prog;
1163 ic = ccl_prog_stack_struct[0].ic; 1172 ic = ccl_prog_stack_struct[0].ic;
1173 eof_ic = ccl_prog_stack_struct[0].eof_ic;
1164 } 1174 }
1165 CCL_INVALID_CMD; 1175 CCL_INVALID_CMD;
1166 } 1176 }
1167 1177
1168 ccl_prog_stack_struct[stack_idx].ccl_prog = ccl_prog; 1178 ccl_prog_stack_struct[stack_idx].ccl_prog = ccl_prog;
1169 ccl_prog_stack_struct[stack_idx].ic = ic; 1179 ccl_prog_stack_struct[stack_idx].ic = ic;
1180 ccl_prog_stack_struct[stack_idx].eof_ic = eof_ic;
1170 stack_idx++; 1181 stack_idx++;
1171 ccl_prog = XVECTOR (XVECTOR (slot)->contents[1])->contents; 1182 ccl_prog = XVECTOR (XVECTOR (slot)->contents[1])->contents;
1172 ic = CCL_HEADER_MAIN; 1183 ic = CCL_HEADER_MAIN;
1184 eof_ic = XINT (ccl_prog[CCL_HEADER_EOF]);
1173 } 1185 }
1174 break; 1186 break;
1175 1187
1176 case CCL_WriteConstString: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */ 1188 case CCL_WriteConstString: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */
1177 if (!rrr) 1189 if (!rrr)
1198 if (stack_idx > 0) 1210 if (stack_idx > 0)
1199 { 1211 {
1200 stack_idx--; 1212 stack_idx--;
1201 ccl_prog = ccl_prog_stack_struct[stack_idx].ccl_prog; 1213 ccl_prog = ccl_prog_stack_struct[stack_idx].ccl_prog;
1202 ic = ccl_prog_stack_struct[stack_idx].ic; 1214 ic = ccl_prog_stack_struct[stack_idx].ic;
1215 eof_ic = ccl_prog_stack_struct[stack_idx].eof_ic;
1216 if (eof_hit)
1217 ic = eof_ic;
1203 break; 1218 break;
1204 } 1219 }
1205 if (src) 1220 if (src)
1206 src = src_end; 1221 src = src_end;
1207 /* ccl->ic should points to this command code again to 1222 /* ccl->ic should points to this command code again to
1396 reg[rrr] = i; 1411 reg[rrr] = i;
1397 } 1412 }
1398 break; 1413 break;
1399 1414
1400 ccl_read_multibyte_character_suspend: 1415 ccl_read_multibyte_character_suspend:
1416 if (src <= src_end && ccl->last_block)
1417 {
1418 /* #### Unclear when this happens. GNU use
1419 CHARSET_8_BIT_CONTROL here, which we can't. */
1420 if (i < 0x80)
1421 {
1422 reg[RRR] = LEADING_BYTE_ASCII;
1423 reg[rrr] = i;
1424 }
1425 else if (i < 0xA0)
1426 {
1427 reg[RRR] = LEADING_BYTE_CONTROL_1;
1428 reg[rrr] = i - 0xA0;
1429 }
1430 else
1431 {
1432 reg[RRR] = LEADING_BYTE_LATIN_ISO8859_1;
1433 reg[rrr] = i & 0x7F;
1434 }
1435 break;
1436 }
1401 src--; 1437 src--;
1402 if (ccl->last_block) 1438 if (ccl->last_block)
1403 { 1439 {
1404 ic = ccl->eof_ic; 1440 ic = eof_ic;
1441 eof_hit = 1;
1405 goto ccl_repeat; 1442 goto ccl_repeat;
1406 } 1443 }
1407 else 1444 else
1408 CCL_SUSPEND (CCL_STAT_SUSPEND_BY_SRC); 1445 CCL_SUSPEND (CCL_STAT_SUSPEND_BY_SRC);
1409 1446