comparison src/mule-ccl.c @ 771:943eaba38521

[xemacs-hg @ 2002-03-13 08:51:24 by ben] The big ben-mule-21-5 check-in! Various files were added and deleted. See CHANGES-ben-mule. There are still some test suite failures. No crashes, though. Many of the failures have to do with problems in the test suite itself rather than in the actual code. I'll be addressing these in the next day or so -- none of the test suite failures are at all critical. Meanwhile I'll be trying to address the biggest issues -- i.e. build or run failures, which will almost certainly happen on various platforms. All comments should be sent to ben@xemacs.org -- use a Cc: if necessary when sending to mailing lists. There will be pre- and post- tags, something like pre-ben-mule-21-5-merge-in, and post-ben-mule-21-5-merge-in.
author ben
date Wed, 13 Mar 2002 08:54:06 +0000
parents fdefd0186b75
children e38acbeb1cae
comparison
equal deleted inserted replaced
770:336a418893b5 771:943eaba38521
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */ 20 Boston, MA 02111-1307, USA. */
21 21
22 /* Synched up with : FSF Emacs 21.0.90 except TranslateCharacter */ 22 /* Synched up with : FSF Emacs 21.0.90 except TranslateCharacter */
23 23
24 #ifdef emacs
25 #include <config.h> 24 #include <config.h>
26 #endif
27
28 #include <stdio.h>
29
30 #ifdef emacs
31
32 #include "lisp.h" 25 #include "lisp.h"
26
33 #include "buffer.h" 27 #include "buffer.h"
34 #include "mule-charset.h" 28 #include "charset.h"
35 #include "mule-ccl.h" 29 #include "mule-ccl.h"
36 #include "file-coding.h" 30 #include "file-coding.h"
37
38 #else /* not emacs */
39
40 #include "mulelib.h"
41
42 #endif /* not emacs */
43 31
44 Lisp_Object Qccl_error; 32 Lisp_Object Qccl_error;
45 33
46 /* This contains all code conversion map available to CCL. */ 34 /* This contains all code conversion map available to CCL. */
47 Lisp_Object Vcode_conversion_map_vector; 35 Lisp_Object Vcode_conversion_map_vector;
699 if (1) goto ccl_finish; \ 687 if (1) goto ccl_finish; \
700 } while (0) 688 } while (0)
701 689
702 /* Terminate CCL program because of invalid command. Should not occur 690 /* Terminate CCL program because of invalid command. Should not occur
703 in the normal case. */ 691 in the normal case. */
704 #define CCL_INVALID_CMD \ 692 #define CCL_INVALID_CMD \
705 do { \ 693 do { \
706 ccl->status = CCL_STAT_INVALID_CMD; \ 694 ccl->status = CCL_STAT_INVALID_CMD; \
707 /* The "if (1)" inhibits the warning \ 695 /* enable this to debug invalid cmd errors */ \
708 "end-of loop code not reached" */ \ 696 /* debug_break (); */ \
709 if (1) goto ccl_error_handler; \ 697 /* The "if (1)" inhibits the warning \
698 "end-of loop code not reached" */ \
699 if (1) goto ccl_error_handler; \
710 } while (0) 700 } while (0)
711 701
712 /* Encode one character CH to multibyte form and write to the current 702 /* Encode one character CH to multibyte form and write to the current
713 output buffer. At encoding time, if CH is less than 256, CH is 703 output buffer. At encoding time, if CH is less than 256, CH is
714 written as is. At decoding time, if CH cannot be regarded as an 704 written as is. At decoding time, if CH cannot be regarded as an
1258 case CCL_EQ: reg[rrr] = i == j; break; 1248 case CCL_EQ: reg[rrr] = i == j; break;
1259 case CCL_LE: reg[rrr] = i <= j; break; 1249 case CCL_LE: reg[rrr] = i <= j; break;
1260 case CCL_GE: reg[rrr] = i >= j; break; 1250 case CCL_GE: reg[rrr] = i >= j; break;
1261 case CCL_NE: reg[rrr] = i != j; break; 1251 case CCL_NE: reg[rrr] = i != j; break;
1262 case CCL_DECODE_SJIS: 1252 case CCL_DECODE_SJIS:
1263 /* DECODE_SJIS set MSB for internal format 1253 /* DECODE_SHIFT_JIS set MSB for internal format
1264 as opposed to Emacs. */ 1254 as opposed to Emacs. */
1265 DECODE_SJIS (i, j, reg[rrr], reg[7]); 1255 DECODE_SHIFT_JIS (i, j, reg[rrr], reg[7]);
1266 reg[rrr] &= 0x7F; 1256 reg[rrr] &= 0x7F;
1267 reg[7] &= 0x7F; 1257 reg[7] &= 0x7F;
1268 break; 1258 break;
1269 case CCL_ENCODE_SJIS: 1259 case CCL_ENCODE_SJIS:
1270 /* ENCODE_SJIS assumes MSB of SJIS-char is set 1260 /* ENCODE_SHIFT_JIS assumes MSB of SHIFT-JIS-char is set
1271 as opposed to Emacs. */ 1261 as opposed to Emacs. */
1272 ENCODE_SJIS (i | 0x80, j | 0x80, reg[rrr], reg[7]); 1262 ENCODE_SHIFT_JIS (i | 0x80, j | 0x80, reg[rrr], reg[7]);
1273 break; 1263 break;
1274 default: CCL_INVALID_CMD; 1264 default: CCL_INVALID_CMD;
1275 } 1265 }
1276 code &= 0x1F; 1266 code &= 0x1F;
1277 if (code == CCL_WriteExprConst || code == CCL_WriteExprRegister) 1267 if (code == CCL_WriteExprConst || code == CCL_WriteExprRegister)
1387 #endif 1377 #endif
1388 break; 1378 break;
1389 1379
1390 case CCL_TranslateCharacterConstTbl: 1380 case CCL_TranslateCharacterConstTbl:
1391 #if 0 1381 #if 0
1392 /* XEmacs does not have translate_char, and its 1382 /* XEmacs does not have translate_char or an equivalent. We
1393 equivalent nor. We do nothing on this operation. */ 1383 do nothing on this operation. */
1394 op = XINT (ccl_prog[ic]); /* table */ 1384 op = XINT (ccl_prog[ic]); /* table */
1395 ic++; 1385 ic++;
1396 CCL_MAKE_CHAR (reg[RRR], reg[rrr], i); 1386 CCL_MAKE_CHAR (reg[RRR], reg[rrr], i);
1397 op = translate_char (GET_TRANSLATION_TABLE (op), i, -1, 0, 0); 1387 op = translate_char (GET_TRANSLATION_TABLE (op), i, -1, 0, 0);
1398 SPLIT_CHAR (op, reg[RRR], i, j); 1388 SPLIT_CHAR (op, reg[RRR], i, j);
1940 1930
1941 If CCL_PROG is nil, we just reset the structure pointed by CCL. */ 1931 If CCL_PROG is nil, we just reset the structure pointed by CCL. */
1942 int 1932 int
1943 setup_ccl_program (struct ccl_program *ccl, Lisp_Object ccl_prog) 1933 setup_ccl_program (struct ccl_program *ccl, Lisp_Object ccl_prog)
1944 { 1934 {
1945 int i; 1935 xzero (*ccl); /* XEmacs change */
1946
1947 if (! NILP (ccl_prog)) 1936 if (! NILP (ccl_prog))
1948 { 1937 {
1949 ccl_prog = ccl_get_compiled_code (ccl_prog); 1938 ccl_prog = ccl_get_compiled_code (ccl_prog);
1950 if (! VECTORP (ccl_prog)) 1939 if (! VECTORP (ccl_prog))
1951 return -1; 1940 return -1;
1953 ccl->prog = XVECTOR_DATA (ccl_prog); 1942 ccl->prog = XVECTOR_DATA (ccl_prog);
1954 ccl->eof_ic = XINT (XVECTOR_DATA (ccl_prog)[CCL_HEADER_EOF]); 1943 ccl->eof_ic = XINT (XVECTOR_DATA (ccl_prog)[CCL_HEADER_EOF]);
1955 ccl->buf_magnification = XINT (XVECTOR_DATA (ccl_prog)[CCL_HEADER_BUF_MAG]); 1944 ccl->buf_magnification = XINT (XVECTOR_DATA (ccl_prog)[CCL_HEADER_BUF_MAG]);
1956 } 1945 }
1957 ccl->ic = CCL_HEADER_MAIN; 1946 ccl->ic = CCL_HEADER_MAIN;
1958 for (i = 0; i < 8; i++)
1959 ccl->reg[i] = 0;
1960 ccl->last_block = 0;
1961 ccl->private_state = 0;
1962 ccl->status = 0;
1963 ccl->stack_idx = 0;
1964 ccl->eol_type = CCL_CODING_EOL_LF; 1947 ccl->eol_type = CCL_CODING_EOL_LF;
1965 return 0; 1948 return 0;
1966 } 1949 }
1967 1950
1968 #ifdef emacs 1951 #ifdef emacs