comparison src/ccl.c @ 90333:fcd118e730fb

(CCL_WRITE_STRING): Handle a flag bit for multibyte character sequence. (Fccl_execute_on_string): Use ASET, not XSET.
author Kenichi Handa <handa@m17n.org>
date Thu, 02 Mar 2006 01:48:27 +0000
parents c5406394f567
children 4a17062dd458
comparison
equal deleted inserted replaced
90332:3f1e5b454299 90333:fcd118e730fb
204 second code (YYYYY == CCL_ReadJump). */ 204 second code (YYYYY == CCL_ReadJump). */
205 205
206 #define CCL_WriteStringJump 0x0A /* Write string and jump: 206 #define CCL_WriteStringJump 0x0A /* Write string and jump:
207 1:A--D--D--R--E--S--S-000XXXXX 207 1:A--D--D--R--E--S--S-000XXXXX
208 2:LENGTH 208 2:LENGTH
209 3:0000STRIN[0]STRIN[1]STRIN[2] 209 3:000MSTRIN[0]STRIN[1]STRIN[2]
210 ... 210 ...
211 ------------------------------ 211 ------------------------------
212 write_string (STRING, LENGTH); 212 if (M)
213 write_multibyte_string (STRING, LENGTH);
214 else
215 write_string (STRING, LENGTH);
213 IC += ADDRESS; 216 IC += ADDRESS;
214 */ 217 */
215 218
216 #define CCL_WriteArrayReadJump 0x0B /* Write an array element, read, and jump: 219 #define CCL_WriteArrayReadJump 0x0B /* Write an array element, read, and jump:
217 1:A--D--D--R--E--S--S-rrrXXXXX 220 1:A--D--D--R--E--S--S-rrrXXXXX
314 call (CC..C) 317 call (CC..C)
315 */ 318 */
316 319
317 #define CCL_WriteConstString 0x14 /* Write a constant or a string: 320 #define CCL_WriteConstString 0x14 /* Write a constant or a string:
318 1:CCCCCCCCCCCCCCCCCCCCrrrXXXXX 321 1:CCCCCCCCCCCCCCCCCCCCrrrXXXXX
319 [2:0000STRIN[0]STRIN[1]STRIN[2]] 322 [2:000MSTRIN[0]STRIN[1]STRIN[2]]
320 [...] 323 [...]
321 ----------------------------- 324 -----------------------------
322 if (!rrr) 325 if (!rrr)
323 write (CC..C) 326 write (CC..C)
324 else 327 else
325 write_string (STRING, CC..C); 328 if (M)
329 write_multibyte_string (STRING, CC..C);
330 else
331 write_string (STRING, CC..C);
326 IC += (CC..C + 2) / 3; 332 IC += (CC..C + 2) / 3;
327 */ 333 */
328 334
329 #define CCL_WriteArray 0x15 /* Write an element of array: 335 #define CCL_WriteArray 0x15 /* Write an element of array:
330 1:CCCCCCCCCCCCCCCCCCCCrrrXXXXX 336 1:CCCCCCCCCCCCCCCCCCCCrrrXXXXX
760 CCL_SUSPEND (CCL_STAT_SUSPEND_BY_DST); \ 766 CCL_SUSPEND (CCL_STAT_SUSPEND_BY_DST); \
761 } while (0) 767 } while (0)
762 768
763 /* Write a string at ccl_prog[IC] of length LEN to the current output 769 /* Write a string at ccl_prog[IC] of length LEN to the current output
764 buffer. */ 770 buffer. */
765 #define CCL_WRITE_STRING(len) \ 771 #define CCL_WRITE_STRING(len) \
766 do { \ 772 do { \
767 int i; \ 773 int i; \
768 if (!dst) \ 774 if (!dst) \
769 CCL_INVALID_CMD; \ 775 CCL_INVALID_CMD; \
770 else if (dst + len <= dst_end) \ 776 else if (dst + len <= dst_end) \
771 for (i = 0; i < len; i++) \ 777 { \
772 *dst++ = ((XFASTINT (ccl_prog[ic + (i / 3)])) \ 778 if (XFASTINT (ccl_prog[ic]) & 0x1000000) \
773 >> ((2 - (i % 3)) * 8)) & 0xFF; \ 779 for (i = 0; i < len; i++) \
774 else \ 780 *dst++ = XFASTINT (ccl_prog[ic + i]) & 0xFFFFFF; \
775 CCL_SUSPEND (CCL_STAT_SUSPEND_BY_DST); \ 781 else \
782 for (i = 0; i < len; i++) \
783 *dst++ = ((XFASTINT (ccl_prog[ic + (i / 3)])) \
784 >> ((2 - (i % 3)) * 8)) & 0xFF; \
785 } \
786 else \
787 CCL_SUSPEND (CCL_STAT_SUSPEND_BY_DST); \
776 } while (0) 788 } while (0)
777 789
778 /* Read one byte from the current input buffer into Rth register. */ 790 /* Read one byte from the current input buffer into Rth register. */
779 #define CCL_READ_CHAR(r) \ 791 #define CCL_READ_CHAR(r) \
780 do { \ 792 do { \
2162 if (ccl.status != CCL_STAT_SUCCESS 2174 if (ccl.status != CCL_STAT_SUCCESS
2163 && ccl.status != CCL_STAT_SUSPEND_BY_SRC) 2175 && ccl.status != CCL_STAT_SUSPEND_BY_SRC)
2164 error ("Error in CCL program at %dth code", ccl.ic); 2176 error ("Error in CCL program at %dth code", ccl.ic);
2165 2177
2166 for (i = 0; i < 8; i++) 2178 for (i = 0; i < 8; i++)
2167 XSET (XVECTOR (status)->contents[i], Lisp_Int, ccl.reg[i]); 2179 ASET (status, i, make_number (ccl.reg[i]));
2168 XSETINT (XVECTOR (status)->contents[8], ccl.ic); 2180 ASET (status, 8, make_number (ccl.ic));
2169 2181
2170 if (NILP (unibyte_p)) 2182 if (NILP (unibyte_p))
2171 val = make_multibyte_string ((char *) outbuf, produced_chars, 2183 val = make_multibyte_string ((char *) outbuf, produced_chars,
2172 outp - outbuf); 2184 outp - outbuf);
2173 else 2185 else