Mercurial > emacs
annotate src/ccl.c @ 44997:31b7eba1962b
Whitespace changes.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Mon, 29 Apr 2002 23:23:03 +0000 |
parents | 2c3898d7bbef |
children | 48b34872db42 1ce6f7577173 |
rev | line source |
---|---|
17052 | 1 /* CCL (Code Conversion Language) interpreter. |
18341
33e78cc7f058
Change copyright notices.
Richard M. Stallman <rms@gnu.org>
parents:
17828
diff
changeset
|
2 Copyright (C) 1995, 1997 Electrotechnical Laboratory, JAPAN. |
37765
0a94387bba65
Add copyright notice for FSF.
Gerd Moellmann <gerd@gnu.org>
parents:
37734
diff
changeset
|
3 Copyright (C) 2001 Free Software Foundation, Inc. |
18341
33e78cc7f058
Change copyright notices.
Richard M. Stallman <rms@gnu.org>
parents:
17828
diff
changeset
|
4 Licensed to the Free Software Foundation. |
17052 | 5 |
17071 | 6 This file is part of GNU Emacs. |
7 | |
8 GNU Emacs is free software; you can redistribute it and/or modify | |
9 it under the terms of the GNU General Public License as published by | |
10 the Free Software Foundation; either version 2, or (at your option) | |
11 any later version. | |
17052 | 12 |
17071 | 13 GNU Emacs is distributed in the hope that it will be useful, |
14 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 GNU General Public License for more details. | |
17052 | 17 |
17071 | 18 You should have received a copy of the GNU General Public License |
19 along with GNU Emacs; see the file COPYING. If not, write to | |
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
21 Boston, MA 02111-1307, USA. */ | |
17052 | 22 |
26088
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25662
diff
changeset
|
23 #ifdef emacs |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25662
diff
changeset
|
24 #include <config.h> |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25662
diff
changeset
|
25 #endif |
b7aa6ac26872
Add support for large files, 64-bit Solaris, system locale codings.
Paul Eggert <eggert@twinsun.com>
parents:
25662
diff
changeset
|
26 |
17052 | 27 #include <stdio.h> |
28 | |
29 #ifdef emacs | |
30 | |
31 #include "lisp.h" | |
32 #include "charset.h" | |
33 #include "ccl.h" | |
34 #include "coding.h" | |
35 | |
36 #else /* not emacs */ | |
37 | |
38 #include "mulelib.h" | |
39 | |
40 #endif /* not emacs */ | |
41 | |
22718 | 42 /* This contains all code conversion map available to CCL. */ |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
43 Lisp_Object Vcode_conversion_map_vector; |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
44 |
17052 | 45 /* Alist of fontname patterns vs corresponding CCL program. */ |
46 Lisp_Object Vfont_ccl_encoder_alist; | |
47 | |
21551 | 48 /* This symbol is a property which assocates with ccl program vector. |
49 Ex: (get 'ccl-big5-encoder 'ccl-program) returns ccl program vector. */ | |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
50 Lisp_Object Qccl_program; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
51 |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
52 /* These symbols are properties which associate with code conversion |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
53 map and their ID respectively. */ |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
54 Lisp_Object Qcode_conversion_map; |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
55 Lisp_Object Qcode_conversion_map_id; |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
56 |
21551 | 57 /* Symbols of ccl program have this property, a value of the property |
58 is an index for Vccl_protram_table. */ | |
59 Lisp_Object Qccl_program_idx; | |
60 | |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
61 /* Table of registered CCL programs. Each element is a vector of |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
62 NAME, CCL_PROG, and RESOLVEDP where NAME (symbol) is the name of |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
63 the program, CCL_PROG (vector) is the compiled code of the program, |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
64 RESOLVEDP (t or nil) is the flag to tell if symbols in CCL_PROG is |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
65 already resolved to index numbers or not. */ |
17052 | 66 Lisp_Object Vccl_program_table; |
67 | |
68 /* CCL (Code Conversion Language) is a simple language which has | |
69 operations on one input buffer, one output buffer, and 7 registers. | |
70 The syntax of CCL is described in `ccl.el'. Emacs Lisp function | |
71 `ccl-compile' compiles a CCL program and produces a CCL code which | |
72 is a vector of integers. The structure of this vector is as | |
73 follows: The 1st element: buffer-magnification, a factor for the | |
74 size of output buffer compared with the size of input buffer. The | |
75 2nd element: address of CCL code to be executed when encountered | |
76 with end of input stream. The 3rd and the remaining elements: CCL | |
77 codes. */ | |
78 | |
79 /* Header of CCL compiled code */ | |
80 #define CCL_HEADER_BUF_MAG 0 | |
81 #define CCL_HEADER_EOF 1 | |
82 #define CCL_HEADER_MAIN 2 | |
83 | |
84 /* CCL code is a sequence of 28-bit non-negative integers (i.e. the | |
85 MSB is always 0), each contains CCL command and/or arguments in the | |
86 following format: | |
87 | |
88 |----------------- integer (28-bit) ------------------| | |
89 |------- 17-bit ------|- 3-bit --|- 3-bit --|- 5-bit -| | |
90 |--constant argument--|-register-|-register-|-command-| | |
91 ccccccccccccccccc RRR rrr XXXXX | |
92 or | |
93 |------- relative address -------|-register-|-command-| | |
94 cccccccccccccccccccc rrr XXXXX | |
95 or | |
96 |------------- constant or other args ----------------| | |
97 cccccccccccccccccccccccccccc | |
98 | |
99 where, `cc...c' is a non-negative integer indicating constant value | |
100 (the left most `c' is always 0) or an absolute jump address, `RRR' | |
101 and `rrr' are CCL register number, `XXXXX' is one of the following | |
102 CCL commands. */ | |
103 | |
104 /* CCL commands | |
105 | |
106 Each comment fields shows one or more lines for command syntax and | |
107 the following lines for semantics of the command. In semantics, IC | |
108 stands for Instruction Counter. */ | |
109 | |
110 #define CCL_SetRegister 0x00 /* Set register a register value: | |
111 1:00000000000000000RRRrrrXXXXX | |
112 ------------------------------ | |
113 reg[rrr] = reg[RRR]; | |
114 */ | |
115 | |
116 #define CCL_SetShortConst 0x01 /* Set register a short constant value: | |
117 1:CCCCCCCCCCCCCCCCCCCCrrrXXXXX | |
118 ------------------------------ | |
119 reg[rrr] = CCCCCCCCCCCCCCCCCCC; | |
120 */ | |
121 | |
122 #define CCL_SetConst 0x02 /* Set register a constant value: | |
123 1:00000000000000000000rrrXXXXX | |
124 2:CONSTANT | |
125 ------------------------------ | |
126 reg[rrr] = CONSTANT; | |
127 IC++; | |
128 */ | |
129 | |
130 #define CCL_SetArray 0x03 /* Set register an element of array: | |
131 1:CCCCCCCCCCCCCCCCCRRRrrrXXXXX | |
132 2:ELEMENT[0] | |
133 3:ELEMENT[1] | |
134 ... | |
135 ------------------------------ | |
136 if (0 <= reg[RRR] < CC..C) | |
137 reg[rrr] = ELEMENT[reg[RRR]]; | |
138 IC += CC..C; | |
139 */ | |
140 | |
141 #define CCL_Jump 0x04 /* Jump: | |
142 1:A--D--D--R--E--S--S-000XXXXX | |
143 ------------------------------ | |
144 IC += ADDRESS; | |
145 */ | |
146 | |
147 /* Note: If CC..C is greater than 0, the second code is omitted. */ | |
148 | |
149 #define CCL_JumpCond 0x05 /* Jump conditional: | |
150 1:A--D--D--R--E--S--S-rrrXXXXX | |
151 ------------------------------ | |
152 if (!reg[rrr]) | |
153 IC += ADDRESS; | |
154 */ | |
155 | |
156 | |
157 #define CCL_WriteRegisterJump 0x06 /* Write register and jump: | |
158 1:A--D--D--R--E--S--S-rrrXXXXX | |
159 ------------------------------ | |
160 write (reg[rrr]); | |
161 IC += ADDRESS; | |
162 */ | |
163 | |
164 #define CCL_WriteRegisterReadJump 0x07 /* Write register, read, and jump: | |
165 1:A--D--D--R--E--S--S-rrrXXXXX | |
166 2:A--D--D--R--E--S--S-rrrYYYYY | |
167 ----------------------------- | |
168 write (reg[rrr]); | |
169 IC++; | |
170 read (reg[rrr]); | |
171 IC += ADDRESS; | |
172 */ | |
173 /* Note: If read is suspended, the resumed execution starts from the | |
174 second code (YYYYY == CCL_ReadJump). */ | |
175 | |
176 #define CCL_WriteConstJump 0x08 /* Write constant and jump: | |
177 1:A--D--D--R--E--S--S-000XXXXX | |
178 2:CONST | |
179 ------------------------------ | |
180 write (CONST); | |
181 IC += ADDRESS; | |
182 */ | |
183 | |
184 #define CCL_WriteConstReadJump 0x09 /* Write constant, read, and jump: | |
185 1:A--D--D--R--E--S--S-rrrXXXXX | |
186 2:CONST | |
187 3:A--D--D--R--E--S--S-rrrYYYYY | |
188 ----------------------------- | |
189 write (CONST); | |
190 IC += 2; | |
191 read (reg[rrr]); | |
192 IC += ADDRESS; | |
193 */ | |
194 /* Note: If read is suspended, the resumed execution starts from the | |
195 second code (YYYYY == CCL_ReadJump). */ | |
196 | |
197 #define CCL_WriteStringJump 0x0A /* Write string and jump: | |
198 1:A--D--D--R--E--S--S-000XXXXX | |
199 2:LENGTH | |
200 3:0000STRIN[0]STRIN[1]STRIN[2] | |
201 ... | |
202 ------------------------------ | |
203 write_string (STRING, LENGTH); | |
204 IC += ADDRESS; | |
205 */ | |
206 | |
207 #define CCL_WriteArrayReadJump 0x0B /* Write an array element, read, and jump: | |
208 1:A--D--D--R--E--S--S-rrrXXXXX | |
209 2:LENGTH | |
210 3:ELEMENET[0] | |
211 4:ELEMENET[1] | |
212 ... | |
213 N:A--D--D--R--E--S--S-rrrYYYYY | |
214 ------------------------------ | |
215 if (0 <= reg[rrr] < LENGTH) | |
216 write (ELEMENT[reg[rrr]]); | |
217 IC += LENGTH + 2; (... pointing at N+1) | |
218 read (reg[rrr]); | |
219 IC += ADDRESS; | |
220 */ | |
221 /* Note: If read is suspended, the resumed execution starts from the | |
17323
15fa68d983e7
(ccl_driver): Fix bug of the case CCL_WriteArrayReadJump.
Kenichi Handa <handa@m17n.org>
parents:
17122
diff
changeset
|
222 Nth code (YYYYY == CCL_ReadJump). */ |
17052 | 223 |
224 #define CCL_ReadJump 0x0C /* Read and jump: | |
225 1:A--D--D--R--E--S--S-rrrYYYYY | |
226 ----------------------------- | |
227 read (reg[rrr]); | |
228 IC += ADDRESS; | |
229 */ | |
230 | |
231 #define CCL_Branch 0x0D /* Jump by branch table: | |
232 1:CCCCCCCCCCCCCCCCCCCCrrrXXXXX | |
233 2:A--D--D--R--E-S-S[0]000XXXXX | |
234 3:A--D--D--R--E-S-S[1]000XXXXX | |
235 ... | |
236 ------------------------------ | |
237 if (0 <= reg[rrr] < CC..C) | |
238 IC += ADDRESS[reg[rrr]]; | |
239 else | |
240 IC += ADDRESS[CC..C]; | |
241 */ | |
242 | |
243 #define CCL_ReadRegister 0x0E /* Read bytes into registers: | |
244 1:CCCCCCCCCCCCCCCCCCCCrrrXXXXX | |
245 2:CCCCCCCCCCCCCCCCCCCCrrrXXXXX | |
246 ... | |
247 ------------------------------ | |
248 while (CCC--) | |
249 read (reg[rrr]); | |
250 */ | |
251 | |
252 #define CCL_WriteExprConst 0x0F /* write result of expression: | |
253 1:00000OPERATION000RRR000XXXXX | |
254 2:CONSTANT | |
255 ------------------------------ | |
256 write (reg[RRR] OPERATION CONSTANT); | |
257 IC++; | |
258 */ | |
259 | |
260 /* Note: If the Nth read is suspended, the resumed execution starts | |
261 from the Nth code. */ | |
262 | |
263 #define CCL_ReadBranch 0x10 /* Read one byte into a register, | |
264 and jump by branch table: | |
265 1:CCCCCCCCCCCCCCCCCCCCrrrXXXXX | |
266 2:A--D--D--R--E-S-S[0]000XXXXX | |
267 3:A--D--D--R--E-S-S[1]000XXXXX | |
268 ... | |
269 ------------------------------ | |
270 read (read[rrr]); | |
271 if (0 <= reg[rrr] < CC..C) | |
272 IC += ADDRESS[reg[rrr]]; | |
273 else | |
274 IC += ADDRESS[CC..C]; | |
275 */ | |
276 | |
277 #define CCL_WriteRegister 0x11 /* Write registers: | |
278 1:CCCCCCCCCCCCCCCCCCCrrrXXXXX | |
279 2:CCCCCCCCCCCCCCCCCCCrrrXXXXX | |
280 ... | |
281 ------------------------------ | |
282 while (CCC--) | |
283 write (reg[rrr]); | |
284 ... | |
285 */ | |
286 | |
287 /* Note: If the Nth write is suspended, the resumed execution | |
288 starts from the Nth code. */ | |
289 | |
290 #define CCL_WriteExprRegister 0x12 /* Write result of expression | |
291 1:00000OPERATIONRrrRRR000XXXXX | |
292 ------------------------------ | |
293 write (reg[RRR] OPERATION reg[Rrr]); | |
294 */ | |
295 | |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
296 #define CCL_Call 0x13 /* Call the CCL program whose ID is |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
297 CC..C or cc..c. |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
298 1:CCCCCCCCCCCCCCCCCCCCFFFXXXXX |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
299 [2:00000000cccccccccccccccccccc] |
17052 | 300 ------------------------------ |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
301 if (FFF) |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
302 call (cc..c) |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
303 IC++; |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
304 else |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
305 call (CC..C) |
17052 | 306 */ |
307 | |
308 #define CCL_WriteConstString 0x14 /* Write a constant or a string: | |
309 1:CCCCCCCCCCCCCCCCCCCCrrrXXXXX | |
310 [2:0000STRIN[0]STRIN[1]STRIN[2]] | |
311 [...] | |
312 ----------------------------- | |
313 if (!rrr) | |
314 write (CC..C) | |
315 else | |
316 write_string (STRING, CC..C); | |
317 IC += (CC..C + 2) / 3; | |
318 */ | |
319 | |
320 #define CCL_WriteArray 0x15 /* Write an element of array: | |
321 1:CCCCCCCCCCCCCCCCCCCCrrrXXXXX | |
322 2:ELEMENT[0] | |
323 3:ELEMENT[1] | |
324 ... | |
325 ------------------------------ | |
326 if (0 <= reg[rrr] < CC..C) | |
327 write (ELEMENT[reg[rrr]]); | |
328 IC += CC..C; | |
329 */ | |
330 | |
331 #define CCL_End 0x16 /* Terminate: | |
332 1:00000000000000000000000XXXXX | |
333 ------------------------------ | |
334 terminate (); | |
335 */ | |
336 | |
337 /* The following two codes execute an assignment arithmetic/logical | |
338 operation. The form of the operation is like REG OP= OPERAND. */ | |
339 | |
340 #define CCL_ExprSelfConst 0x17 /* REG OP= constant: | |
341 1:00000OPERATION000000rrrXXXXX | |
342 2:CONSTANT | |
343 ------------------------------ | |
344 reg[rrr] OPERATION= CONSTANT; | |
345 */ | |
346 | |
347 #define CCL_ExprSelfReg 0x18 /* REG1 OP= REG2: | |
348 1:00000OPERATION000RRRrrrXXXXX | |
349 ------------------------------ | |
350 reg[rrr] OPERATION= reg[RRR]; | |
351 */ | |
352 | |
353 /* The following codes execute an arithmetic/logical operation. The | |
354 form of the operation is like REG_X = REG_Y OP OPERAND2. */ | |
355 | |
356 #define CCL_SetExprConst 0x19 /* REG_X = REG_Y OP constant: | |
357 1:00000OPERATION000RRRrrrXXXXX | |
358 2:CONSTANT | |
359 ------------------------------ | |
360 reg[rrr] = reg[RRR] OPERATION CONSTANT; | |
361 IC++; | |
362 */ | |
363 | |
364 #define CCL_SetExprReg 0x1A /* REG1 = REG2 OP REG3: | |
365 1:00000OPERATIONRrrRRRrrrXXXXX | |
366 ------------------------------ | |
367 reg[rrr] = reg[RRR] OPERATION reg[Rrr]; | |
368 */ | |
369 | |
370 #define CCL_JumpCondExprConst 0x1B /* Jump conditional according to | |
371 an operation on constant: | |
372 1:A--D--D--R--E--S--S-rrrXXXXX | |
373 2:OPERATION | |
374 3:CONSTANT | |
375 ----------------------------- | |
376 reg[7] = reg[rrr] OPERATION CONSTANT; | |
377 if (!(reg[7])) | |
378 IC += ADDRESS; | |
379 else | |
380 IC += 2 | |
381 */ | |
382 | |
383 #define CCL_JumpCondExprReg 0x1C /* Jump conditional according to | |
384 an operation on register: | |
385 1:A--D--D--R--E--S--S-rrrXXXXX | |
386 2:OPERATION | |
387 3:RRR | |
388 ----------------------------- | |
389 reg[7] = reg[rrr] OPERATION reg[RRR]; | |
390 if (!reg[7]) | |
391 IC += ADDRESS; | |
392 else | |
393 IC += 2; | |
394 */ | |
395 | |
396 #define CCL_ReadJumpCondExprConst 0x1D /* Read and jump conditional according | |
397 to an operation on constant: | |
398 1:A--D--D--R--E--S--S-rrrXXXXX | |
399 2:OPERATION | |
400 3:CONSTANT | |
401 ----------------------------- | |
402 read (reg[rrr]); | |
403 reg[7] = reg[rrr] OPERATION CONSTANT; | |
404 if (!reg[7]) | |
405 IC += ADDRESS; | |
406 else | |
407 IC += 2; | |
408 */ | |
409 | |
410 #define CCL_ReadJumpCondExprReg 0x1E /* Read and jump conditional according | |
411 to an operation on register: | |
412 1:A--D--D--R--E--S--S-rrrXXXXX | |
413 2:OPERATION | |
414 3:RRR | |
415 ----------------------------- | |
416 read (reg[rrr]); | |
417 reg[7] = reg[rrr] OPERATION reg[RRR]; | |
418 if (!reg[7]) | |
419 IC += ADDRESS; | |
420 else | |
421 IC += 2; | |
422 */ | |
423 | |
35328
f4c8b11d4d36
(CCL_Extension): Fix typo (originally CCL_Extention). Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
35322
diff
changeset
|
424 #define CCL_Extension 0x1F /* Extended CCL code |
17052 | 425 1:ExtendedCOMMNDRrrRRRrrrXXXXX |
426 2:ARGUEMENT | |
427 3:... | |
428 ------------------------------ | |
429 extended_command (rrr,RRR,Rrr,ARGS) | |
430 */ | |
431 | |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
432 /* |
21551 | 433 Here after, Extended CCL Instructions. |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
434 Bit length of extended command is 14. |
21551 | 435 Therefore, the instruction code range is 0..16384(0x3fff). |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
436 */ |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
437 |
21551 | 438 /* Read a multibyte characeter. |
439 A code point is stored into reg[rrr]. A charset ID is stored into | |
440 reg[RRR]. */ | |
441 | |
442 #define CCL_ReadMultibyteChar2 0x00 /* Read Multibyte Character | |
443 1:ExtendedCOMMNDRrrRRRrrrXXXXX */ | |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
444 |
21551 | 445 /* Write a multibyte character. |
446 Write a character whose code point is reg[rrr] and the charset ID | |
447 is reg[RRR]. */ | |
448 | |
449 #define CCL_WriteMultibyteChar2 0x01 /* Write Multibyte Character | |
450 1:ExtendedCOMMNDRrrRRRrrrXXXXX */ | |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
451 |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
452 /* Translate a character whose code point is reg[rrr] and the charset |
22186
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22122
diff
changeset
|
453 ID is reg[RRR] by a translation table whose ID is reg[Rrr]. |
21551 | 454 |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
455 A translated character is set in reg[rrr] (code point) and reg[RRR] |
21551 | 456 (charset ID). */ |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
457 |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
458 #define CCL_TranslateCharacter 0x02 /* Translate a multibyte character |
21551 | 459 1:ExtendedCOMMNDRrrRRRrrrXXXXX */ |
460 | |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
461 /* Translate a character whose code point is reg[rrr] and the charset |
22186
fc4aaf1b1772
Change term "character translation table" to "translation table".
Kenichi Handa <handa@m17n.org>
parents:
22122
diff
changeset
|
462 ID is reg[RRR] by a translation table whose ID is ARGUMENT. |
21551 | 463 |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
464 A translated character is set in reg[rrr] (code point) and reg[RRR] |
21551 | 465 (charset ID). */ |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
466 |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
467 #define CCL_TranslateCharacterConstTbl 0x03 /* Translate a multibyte character |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
468 1:ExtendedCOMMNDRrrRRRrrrXXXXX |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
469 2:ARGUMENT(Translation Table ID) |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
470 */ |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
471 |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
472 /* Iterate looking up MAPs for reg[rrr] starting from the Nth (N = |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
473 reg[RRR]) MAP until some value is found. |
21551 | 474 |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
475 Each MAP is a Lisp vector whose element is number, nil, t, or |
21551 | 476 lambda. |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
477 If the element is nil, ignore the map and proceed to the next map. |
21551 | 478 If the element is t or lambda, finish without changing reg[rrr]. |
479 If the element is a number, set reg[rrr] to the number and finish. | |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
480 |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
481 Detail of the map structure is descibed in the comment for |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
482 CCL_MapMultiple below. */ |
21551 | 483 |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
484 #define CCL_IterateMultipleMap 0x10 /* Iterate multiple maps |
21551 | 485 1:ExtendedCOMMNDXXXRRRrrrXXXXX |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
486 2:NUMBER of MAPs |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
487 3:MAP-ID1 |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
488 4:MAP-ID2 |
21551 | 489 ... |
490 */ | |
491 | |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
492 /* Map the code in reg[rrr] by MAPs starting from the Nth (N = |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
493 reg[RRR]) map. |
21551 | 494 |
22525
3dade37fd85d
Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
495 MAPs are supplied in the succeeding CCL codes as follows: |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
496 |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
497 When CCL program gives this nested structure of map to this command: |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
498 ((MAP-ID11 |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
499 MAP-ID12 |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
500 (MAP-ID121 MAP-ID122 MAP-ID123) |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
501 MAP-ID13) |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
502 (MAP-ID21 |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
503 (MAP-ID211 (MAP-ID2111) MAP-ID212) |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
504 MAP-ID22)), |
21551 | 505 the compiled CCL codes has this sequence: |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
506 CCL_MapMultiple (CCL code of this command) |
22525
3dade37fd85d
Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
507 16 (total number of MAPs and SEPARATORs) |
3dade37fd85d
Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
508 -7 (1st SEPARATOR) |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
509 MAP-ID11 |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
510 MAP-ID12 |
22525
3dade37fd85d
Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
511 -3 (2nd SEPARATOR) |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
512 MAP-ID121 |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
513 MAP-ID122 |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
514 MAP-ID123 |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
515 MAP-ID13 |
22525
3dade37fd85d
Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
516 -7 (3rd SEPARATOR) |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
517 MAP-ID21 |
22525
3dade37fd85d
Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
518 -4 (4th SEPARATOR) |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
519 MAP-ID211 |
22525
3dade37fd85d
Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
520 -1 (5th SEPARATOR) |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
521 MAP_ID2111 |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
522 MAP-ID212 |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
523 MAP-ID22 |
21551 | 524 |
22525
3dade37fd85d
Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
525 A value of each SEPARATOR follows this rule: |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
526 MAP-SET := SEPARATOR [(MAP-ID | MAP-SET)]+ |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
527 SEPARATOR := -(number of MAP-IDs and SEPARATORs in the MAP-SET) |
21551 | 528 |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
529 (*)....Nest level of MAP-SET must not be over than MAX_MAP_SET_LEVEL. |
21551 | 530 |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
531 When some map fails to map (i.e. it doesn't have a value for |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
532 reg[rrr]), the mapping is treated as identity. |
21551 | 533 |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
534 The mapping is iterated for all maps in each map set (set of maps |
22525
3dade37fd85d
Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
535 separated by SEPARATOR) except in the case that lambda is |
3dade37fd85d
Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
536 encountered. More precisely, the mapping proceeds as below: |
3dade37fd85d
Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
537 |
3dade37fd85d
Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
538 At first, VAL0 is set to reg[rrr], and it is translated by the |
3dade37fd85d
Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
539 first map to VAL1. Then, VAL1 is translated by the next map to |
3dade37fd85d
Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
540 VAL2. This mapping is iterated until the last map is used. The |
31551 | 541 result of the mapping is the last value of VAL?. When the mapping |
542 process reached to the end of the map set, it moves to the next | |
543 map set. If the next does not exit, the mapping process terminates, | |
544 and regard the last value as a result. | |
22525
3dade37fd85d
Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
545 |
3dade37fd85d
Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
546 But, when VALm is mapped to VALn and VALn is not a number, the |
3dade37fd85d
Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
547 mapping proceed as below: |
3dade37fd85d
Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
548 |
3dade37fd85d
Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
549 If VALn is nil, the lastest map is ignored and the mapping of VALm |
3dade37fd85d
Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
550 proceed to the next map. |
3dade37fd85d
Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
551 |
3dade37fd85d
Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
552 In VALn is t, VALm is reverted to reg[rrr] and the mapping of VALm |
3dade37fd85d
Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
553 proceed to the next map. |
3dade37fd85d
Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
554 |
31551 | 555 If VALn is lambda, move to the next map set like reaching to the |
556 end of the current map set. | |
557 | |
558 If VALn is a symbol, call the CCL program refered by it. | |
559 Then, use reg[rrr] as a mapped value except for -1, -2 and -3. | |
560 Such special values are regarded as nil, t, and lambda respectively. | |
21551 | 561 |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
562 Each map is a Lisp vector of the following format (a) or (b): |
21551 | 563 (a)......[STARTPOINT VAL1 VAL2 ...] |
564 (b)......[t VAL STARTPOINT ENDPOINT], | |
565 where | |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
566 STARTPOINT is an offset to be used for indexing a map, |
22525
3dade37fd85d
Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
567 ENDPOINT is a maximum index number of a map, |
21551 | 568 VAL and VALn is a number, nil, t, or lambda. |
569 | |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
570 Valid index range of a map of type (a) is: |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
571 STARTPOINT <= index < STARTPOINT + map_size - 1 |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
572 Valid index range of a map of type (b) is: |
22525
3dade37fd85d
Comment for CCL_MapMultiple modified..
Kenichi Handa <handa@m17n.org>
parents:
22186
diff
changeset
|
573 STARTPOINT <= index < ENDPOINT */ |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
574 |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
575 #define CCL_MapMultiple 0x11 /* Mapping by multiple code conversion maps |
21551 | 576 1:ExtendedCOMMNDXXXRRRrrrXXXXX |
577 2:N-2 | |
578 3:SEPARATOR_1 (< 0) | |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
579 4:MAP-ID_1 |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
580 5:MAP-ID_2 |
21551 | 581 ... |
582 M:SEPARATOR_x (< 0) | |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
583 M+1:MAP-ID_y |
21551 | 584 ... |
585 N:SEPARATOR_z (< 0) | |
586 */ | |
587 | |
31551 | 588 #define MAX_MAP_SET_LEVEL 30 |
21551 | 589 |
590 typedef struct | |
591 { | |
592 int rest_length; | |
593 int orig_val; | |
594 } tr_stack; | |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
595 |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
596 static tr_stack mapping_stack[MAX_MAP_SET_LEVEL]; |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
597 static tr_stack *mapping_stack_pointer; |
21551 | 598 |
31551 | 599 /* If this variable is non-zero, it indicates the stack_idx |
600 of immediately called by CCL_MapMultiple. */ | |
34157
f8e2b3c8da1b
(stack_idx_of_map_multiple): Don't use C initializier.
Kenichi Handa <handa@m17n.org>
parents:
31702
diff
changeset
|
601 static int stack_idx_of_map_multiple; |
31551 | 602 |
603 #define PUSH_MAPPING_STACK(restlen, orig) \ | |
40940
174ef035d156
Change macros to use do-while block instead of if-else.
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
604 do \ |
174ef035d156
Change macros to use do-while block instead of if-else.
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
605 { \ |
31551 | 606 mapping_stack_pointer->rest_length = (restlen); \ |
607 mapping_stack_pointer->orig_val = (orig); \ | |
608 mapping_stack_pointer++; \ | |
40940
174ef035d156
Change macros to use do-while block instead of if-else.
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
609 } \ |
174ef035d156
Change macros to use do-while block instead of if-else.
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
610 while (0) |
31551 | 611 |
612 #define POP_MAPPING_STACK(restlen, orig) \ | |
40940
174ef035d156
Change macros to use do-while block instead of if-else.
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
613 do \ |
174ef035d156
Change macros to use do-while block instead of if-else.
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
614 { \ |
31551 | 615 mapping_stack_pointer--; \ |
616 (restlen) = mapping_stack_pointer->rest_length; \ | |
617 (orig) = mapping_stack_pointer->orig_val; \ | |
40940
174ef035d156
Change macros to use do-while block instead of if-else.
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
618 } \ |
174ef035d156
Change macros to use do-while block instead of if-else.
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
619 while (0) |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
620 |
31551 | 621 #define CCL_CALL_FOR_MAP_INSTRUCTION(symbol, ret_ic) \ |
40940
174ef035d156
Change macros to use do-while block instead of if-else.
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
622 do \ |
35498
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
623 { \ |
31551 | 624 struct ccl_program called_ccl; \ |
625 if (stack_idx >= 256 \ | |
626 || (setup_ccl_program (&called_ccl, (symbol)) != 0)) \ | |
627 { \ | |
628 if (stack_idx > 0) \ | |
629 { \ | |
630 ccl_prog = ccl_prog_stack_struct[0].ccl_prog; \ | |
631 ic = ccl_prog_stack_struct[0].ic; \ | |
632 } \ | |
633 CCL_INVALID_CMD; \ | |
634 } \ | |
635 ccl_prog_stack_struct[stack_idx].ccl_prog = ccl_prog; \ | |
636 ccl_prog_stack_struct[stack_idx].ic = (ret_ic); \ | |
637 stack_idx++; \ | |
638 ccl_prog = called_ccl.prog; \ | |
639 ic = CCL_HEADER_MAIN; \ | |
640 goto ccl_repeat; \ | |
35498
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
641 } \ |
40940
174ef035d156
Change macros to use do-while block instead of if-else.
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
642 while (0) |
21551 | 643 |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
644 #define CCL_MapSingle 0x12 /* Map by single code conversion map |
21551 | 645 1:ExtendedCOMMNDXXXRRRrrrXXXXX |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
646 2:MAP-ID |
21551 | 647 ------------------------------ |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
648 Map reg[rrr] by MAP-ID. |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
649 If some valid mapping is found, |
21551 | 650 set reg[rrr] to the result, |
651 else | |
652 set reg[RRR] to -1. | |
653 */ | |
17052 | 654 |
655 /* CCL arithmetic/logical operators. */ | |
656 #define CCL_PLUS 0x00 /* X = Y + Z */ | |
657 #define CCL_MINUS 0x01 /* X = Y - Z */ | |
658 #define CCL_MUL 0x02 /* X = Y * Z */ | |
659 #define CCL_DIV 0x03 /* X = Y / Z */ | |
660 #define CCL_MOD 0x04 /* X = Y % Z */ | |
661 #define CCL_AND 0x05 /* X = Y & Z */ | |
662 #define CCL_OR 0x06 /* X = Y | Z */ | |
663 #define CCL_XOR 0x07 /* X = Y ^ Z */ | |
664 #define CCL_LSH 0x08 /* X = Y << Z */ | |
665 #define CCL_RSH 0x09 /* X = Y >> Z */ | |
666 #define CCL_LSH8 0x0A /* X = (Y << 8) | Z */ | |
667 #define CCL_RSH8 0x0B /* X = Y >> 8, r[7] = Y & 0xFF */ | |
668 #define CCL_DIVMOD 0x0C /* X = Y / Z, r[7] = Y % Z */ | |
669 #define CCL_LS 0x10 /* X = (X < Y) */ | |
670 #define CCL_GT 0x11 /* X = (X > Y) */ | |
671 #define CCL_EQ 0x12 /* X = (X == Y) */ | |
672 #define CCL_LE 0x13 /* X = (X <= Y) */ | |
673 #define CCL_GE 0x14 /* X = (X >= Y) */ | |
674 #define CCL_NE 0x15 /* X = (X != Y) */ | |
675 | |
23428
49c7e979c16c
(CCL_DECODE_SJIS, CCL_ENCODE_SJIS): Swap the definitions.
Kenichi Handa <handa@m17n.org>
parents:
23303
diff
changeset
|
676 #define CCL_DECODE_SJIS 0x16 /* X = HIGHER_BYTE (DE-SJIS (Y, Z)) |
49c7e979c16c
(CCL_DECODE_SJIS, CCL_ENCODE_SJIS): Swap the definitions.
Kenichi Handa <handa@m17n.org>
parents:
23303
diff
changeset
|
677 r[7] = LOWER_BYTE (DE-SJIS (Y, Z)) */ |
49c7e979c16c
(CCL_DECODE_SJIS, CCL_ENCODE_SJIS): Swap the definitions.
Kenichi Handa <handa@m17n.org>
parents:
23303
diff
changeset
|
678 #define CCL_ENCODE_SJIS 0x17 /* X = HIGHER_BYTE (SJIS (Y, Z)) |
17052 | 679 r[7] = LOWER_BYTE (SJIS (Y, Z) */ |
680 | |
681 /* Terminate CCL program successfully. */ | |
35498
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
682 #define CCL_SUCCESS \ |
40940
174ef035d156
Change macros to use do-while block instead of if-else.
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
683 do \ |
35498
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
684 { \ |
17052 | 685 ccl->status = CCL_STAT_SUCCESS; \ |
35498
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
686 goto ccl_finish; \ |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
687 } \ |
40940
174ef035d156
Change macros to use do-while block instead of if-else.
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
688 while(0) |
17052 | 689 |
690 /* Suspend CCL program because of reading from empty input buffer or | |
691 writing to full output buffer. When this program is resumed, the | |
692 same I/O command is executed. */ | |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
693 #define CCL_SUSPEND(stat) \ |
40940
174ef035d156
Change macros to use do-while block instead of if-else.
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
694 do \ |
35498
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
695 { \ |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
696 ic--; \ |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
697 ccl->status = stat; \ |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
698 goto ccl_finish; \ |
35498
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
699 } \ |
40940
174ef035d156
Change macros to use do-while block instead of if-else.
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
700 while (0) |
17052 | 701 |
702 /* Terminate CCL program because of invalid command. Should not occur | |
703 in the normal case. */ | |
704 #define CCL_INVALID_CMD \ | |
40940
174ef035d156
Change macros to use do-while block instead of if-else.
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
705 do \ |
35498
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
706 { \ |
17052 | 707 ccl->status = CCL_STAT_INVALID_CMD; \ |
708 goto ccl_error_handler; \ | |
35498
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
709 } \ |
40940
174ef035d156
Change macros to use do-while block instead of if-else.
Pavel Janík <Pavel@Janik.cz>
parents:
40656
diff
changeset
|
710 while(0) |
17052 | 711 |
712 /* Encode one character CH to multibyte form and write to the current | |
17323
15fa68d983e7
(ccl_driver): Fix bug of the case CCL_WriteArrayReadJump.
Kenichi Handa <handa@m17n.org>
parents:
17122
diff
changeset
|
713 output buffer. If CH is less than 256, CH is written as is. */ |
34890
f203e7623af7
(CCL_WRITE_CHAR): Check variable `extra_bytes'.
Kenichi Handa <handa@m17n.org>
parents:
34816
diff
changeset
|
714 #define CCL_WRITE_CHAR(ch) \ |
f203e7623af7
(CCL_WRITE_CHAR): Check variable `extra_bytes'.
Kenichi Handa <handa@m17n.org>
parents:
34816
diff
changeset
|
715 do { \ |
f203e7623af7
(CCL_WRITE_CHAR): Check variable `extra_bytes'.
Kenichi Handa <handa@m17n.org>
parents:
34816
diff
changeset
|
716 int bytes = SINGLE_BYTE_CHAR_P (ch) ? 1: CHAR_BYTES (ch); \ |
f203e7623af7
(CCL_WRITE_CHAR): Check variable `extra_bytes'.
Kenichi Handa <handa@m17n.org>
parents:
34816
diff
changeset
|
717 if (!dst) \ |
f203e7623af7
(CCL_WRITE_CHAR): Check variable `extra_bytes'.
Kenichi Handa <handa@m17n.org>
parents:
34816
diff
changeset
|
718 CCL_INVALID_CMD; \ |
f203e7623af7
(CCL_WRITE_CHAR): Check variable `extra_bytes'.
Kenichi Handa <handa@m17n.org>
parents:
34816
diff
changeset
|
719 else if (dst + bytes + extra_bytes < (dst_bytes ? dst_end : src)) \ |
f203e7623af7
(CCL_WRITE_CHAR): Check variable `extra_bytes'.
Kenichi Handa <handa@m17n.org>
parents:
34816
diff
changeset
|
720 { \ |
f203e7623af7
(CCL_WRITE_CHAR): Check variable `extra_bytes'.
Kenichi Handa <handa@m17n.org>
parents:
34816
diff
changeset
|
721 if (bytes == 1) \ |
f203e7623af7
(CCL_WRITE_CHAR): Check variable `extra_bytes'.
Kenichi Handa <handa@m17n.org>
parents:
34816
diff
changeset
|
722 { \ |
f203e7623af7
(CCL_WRITE_CHAR): Check variable `extra_bytes'.
Kenichi Handa <handa@m17n.org>
parents:
34816
diff
changeset
|
723 *dst++ = (ch); \ |
f203e7623af7
(CCL_WRITE_CHAR): Check variable `extra_bytes'.
Kenichi Handa <handa@m17n.org>
parents:
34816
diff
changeset
|
724 if ((ch) >= 0x80 && (ch) < 0xA0) \ |
f203e7623af7
(CCL_WRITE_CHAR): Check variable `extra_bytes'.
Kenichi Handa <handa@m17n.org>
parents:
34816
diff
changeset
|
725 /* We may have to convert this eight-bit char to \ |
f203e7623af7
(CCL_WRITE_CHAR): Check variable `extra_bytes'.
Kenichi Handa <handa@m17n.org>
parents:
34816
diff
changeset
|
726 multibyte form later. */ \ |
f203e7623af7
(CCL_WRITE_CHAR): Check variable `extra_bytes'.
Kenichi Handa <handa@m17n.org>
parents:
34816
diff
changeset
|
727 extra_bytes++; \ |
f203e7623af7
(CCL_WRITE_CHAR): Check variable `extra_bytes'.
Kenichi Handa <handa@m17n.org>
parents:
34816
diff
changeset
|
728 } \ |
35883
aedc87e25ce2
(CCL_WRITE_CHAR): Check if CH is valid or not. If
Kenichi Handa <handa@m17n.org>
parents:
35535
diff
changeset
|
729 else if (CHAR_VALID_P (ch, 0)) \ |
aedc87e25ce2
(CCL_WRITE_CHAR): Check if CH is valid or not. If
Kenichi Handa <handa@m17n.org>
parents:
35535
diff
changeset
|
730 dst += CHAR_STRING (ch, dst); \ |
34890
f203e7623af7
(CCL_WRITE_CHAR): Check variable `extra_bytes'.
Kenichi Handa <handa@m17n.org>
parents:
34816
diff
changeset
|
731 else \ |
35883
aedc87e25ce2
(CCL_WRITE_CHAR): Check if CH is valid or not. If
Kenichi Handa <handa@m17n.org>
parents:
35535
diff
changeset
|
732 CCL_INVALID_CMD; \ |
34890
f203e7623af7
(CCL_WRITE_CHAR): Check variable `extra_bytes'.
Kenichi Handa <handa@m17n.org>
parents:
34816
diff
changeset
|
733 } \ |
f203e7623af7
(CCL_WRITE_CHAR): Check variable `extra_bytes'.
Kenichi Handa <handa@m17n.org>
parents:
34816
diff
changeset
|
734 else \ |
f203e7623af7
(CCL_WRITE_CHAR): Check variable `extra_bytes'.
Kenichi Handa <handa@m17n.org>
parents:
34816
diff
changeset
|
735 CCL_SUSPEND (CCL_STAT_SUSPEND_BY_DST); \ |
17052 | 736 } while (0) |
737 | |
36411
120891909abe
(CCL_WRITE_MULTIBYTE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
36102
diff
changeset
|
738 /* Encode one character CH to multibyte form and write to the current |
120891909abe
(CCL_WRITE_MULTIBYTE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
36102
diff
changeset
|
739 output buffer. The output bytes always forms a valid multibyte |
120891909abe
(CCL_WRITE_MULTIBYTE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
36102
diff
changeset
|
740 sequence. */ |
120891909abe
(CCL_WRITE_MULTIBYTE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
36102
diff
changeset
|
741 #define CCL_WRITE_MULTIBYTE_CHAR(ch) \ |
120891909abe
(CCL_WRITE_MULTIBYTE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
36102
diff
changeset
|
742 do { \ |
120891909abe
(CCL_WRITE_MULTIBYTE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
36102
diff
changeset
|
743 int bytes = CHAR_BYTES (ch); \ |
120891909abe
(CCL_WRITE_MULTIBYTE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
36102
diff
changeset
|
744 if (!dst) \ |
120891909abe
(CCL_WRITE_MULTIBYTE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
36102
diff
changeset
|
745 CCL_INVALID_CMD; \ |
120891909abe
(CCL_WRITE_MULTIBYTE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
36102
diff
changeset
|
746 else if (dst + bytes + extra_bytes < (dst_bytes ? dst_end : src)) \ |
120891909abe
(CCL_WRITE_MULTIBYTE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
36102
diff
changeset
|
747 { \ |
120891909abe
(CCL_WRITE_MULTIBYTE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
36102
diff
changeset
|
748 if (CHAR_VALID_P ((ch), 0)) \ |
120891909abe
(CCL_WRITE_MULTIBYTE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
36102
diff
changeset
|
749 dst += CHAR_STRING ((ch), dst); \ |
120891909abe
(CCL_WRITE_MULTIBYTE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
36102
diff
changeset
|
750 else \ |
120891909abe
(CCL_WRITE_MULTIBYTE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
36102
diff
changeset
|
751 CCL_INVALID_CMD; \ |
120891909abe
(CCL_WRITE_MULTIBYTE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
36102
diff
changeset
|
752 } \ |
120891909abe
(CCL_WRITE_MULTIBYTE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
36102
diff
changeset
|
753 else \ |
120891909abe
(CCL_WRITE_MULTIBYTE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
36102
diff
changeset
|
754 CCL_SUSPEND (CCL_STAT_SUSPEND_BY_DST); \ |
120891909abe
(CCL_WRITE_MULTIBYTE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
36102
diff
changeset
|
755 } while (0) |
120891909abe
(CCL_WRITE_MULTIBYTE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
36102
diff
changeset
|
756 |
17052 | 757 /* Write a string at ccl_prog[IC] of length LEN to the current output |
758 buffer. */ | |
759 #define CCL_WRITE_STRING(len) \ | |
760 do { \ | |
761 if (!dst) \ | |
762 CCL_INVALID_CMD; \ | |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
763 else if (dst + len <= (dst_bytes ? dst_end : src)) \ |
17052 | 764 for (i = 0; i < len; i++) \ |
765 *dst++ = ((XFASTINT (ccl_prog[ic + (i / 3)])) \ | |
766 >> ((2 - (i % 3)) * 8)) & 0xFF; \ | |
767 else \ | |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
768 CCL_SUSPEND (CCL_STAT_SUSPEND_BY_DST); \ |
17052 | 769 } while (0) |
770 | |
35495
74e192d083e9
(CCL_READ_CHAR): Change the argument name from r to REG
Kenichi Handa <handa@m17n.org>
parents:
35328
diff
changeset
|
771 /* Read one byte from the current input buffer into REGth register. */ |
74e192d083e9
(CCL_READ_CHAR): Change the argument name from r to REG
Kenichi Handa <handa@m17n.org>
parents:
35328
diff
changeset
|
772 #define CCL_READ_CHAR(REG) \ |
34816
f998b856d92b
(CCL_WRITE_CHAR): Don't handle EOL conversion here.
Kenichi Handa <handa@m17n.org>
parents:
34157
diff
changeset
|
773 do { \ |
f998b856d92b
(CCL_WRITE_CHAR): Don't handle EOL conversion here.
Kenichi Handa <handa@m17n.org>
parents:
34157
diff
changeset
|
774 if (!src) \ |
f998b856d92b
(CCL_WRITE_CHAR): Don't handle EOL conversion here.
Kenichi Handa <handa@m17n.org>
parents:
34157
diff
changeset
|
775 CCL_INVALID_CMD; \ |
f998b856d92b
(CCL_WRITE_CHAR): Don't handle EOL conversion here.
Kenichi Handa <handa@m17n.org>
parents:
34157
diff
changeset
|
776 else if (src < src_end) \ |
f998b856d92b
(CCL_WRITE_CHAR): Don't handle EOL conversion here.
Kenichi Handa <handa@m17n.org>
parents:
34157
diff
changeset
|
777 { \ |
35495
74e192d083e9
(CCL_READ_CHAR): Change the argument name from r to REG
Kenichi Handa <handa@m17n.org>
parents:
35328
diff
changeset
|
778 REG = *src++; \ |
74e192d083e9
(CCL_READ_CHAR): Change the argument name from r to REG
Kenichi Handa <handa@m17n.org>
parents:
35328
diff
changeset
|
779 if (REG == '\n' \ |
34816
f998b856d92b
(CCL_WRITE_CHAR): Don't handle EOL conversion here.
Kenichi Handa <handa@m17n.org>
parents:
34157
diff
changeset
|
780 && ccl->eol_type != CODING_EOL_LF) \ |
f998b856d92b
(CCL_WRITE_CHAR): Don't handle EOL conversion here.
Kenichi Handa <handa@m17n.org>
parents:
34157
diff
changeset
|
781 { \ |
f998b856d92b
(CCL_WRITE_CHAR): Don't handle EOL conversion here.
Kenichi Handa <handa@m17n.org>
parents:
34157
diff
changeset
|
782 /* We are encoding. */ \ |
f998b856d92b
(CCL_WRITE_CHAR): Don't handle EOL conversion here.
Kenichi Handa <handa@m17n.org>
parents:
34157
diff
changeset
|
783 if (ccl->eol_type == CODING_EOL_CRLF) \ |
f998b856d92b
(CCL_WRITE_CHAR): Don't handle EOL conversion here.
Kenichi Handa <handa@m17n.org>
parents:
34157
diff
changeset
|
784 { \ |
f998b856d92b
(CCL_WRITE_CHAR): Don't handle EOL conversion here.
Kenichi Handa <handa@m17n.org>
parents:
34157
diff
changeset
|
785 if (ccl->cr_consumed) \ |
f998b856d92b
(CCL_WRITE_CHAR): Don't handle EOL conversion here.
Kenichi Handa <handa@m17n.org>
parents:
34157
diff
changeset
|
786 ccl->cr_consumed = 0; \ |
f998b856d92b
(CCL_WRITE_CHAR): Don't handle EOL conversion here.
Kenichi Handa <handa@m17n.org>
parents:
34157
diff
changeset
|
787 else \ |
f998b856d92b
(CCL_WRITE_CHAR): Don't handle EOL conversion here.
Kenichi Handa <handa@m17n.org>
parents:
34157
diff
changeset
|
788 { \ |
f998b856d92b
(CCL_WRITE_CHAR): Don't handle EOL conversion here.
Kenichi Handa <handa@m17n.org>
parents:
34157
diff
changeset
|
789 ccl->cr_consumed = 1; \ |
35495
74e192d083e9
(CCL_READ_CHAR): Change the argument name from r to REG
Kenichi Handa <handa@m17n.org>
parents:
35328
diff
changeset
|
790 REG = '\r'; \ |
34816
f998b856d92b
(CCL_WRITE_CHAR): Don't handle EOL conversion here.
Kenichi Handa <handa@m17n.org>
parents:
34157
diff
changeset
|
791 src--; \ |
f998b856d92b
(CCL_WRITE_CHAR): Don't handle EOL conversion here.
Kenichi Handa <handa@m17n.org>
parents:
34157
diff
changeset
|
792 } \ |
f998b856d92b
(CCL_WRITE_CHAR): Don't handle EOL conversion here.
Kenichi Handa <handa@m17n.org>
parents:
34157
diff
changeset
|
793 } \ |
f998b856d92b
(CCL_WRITE_CHAR): Don't handle EOL conversion here.
Kenichi Handa <handa@m17n.org>
parents:
34157
diff
changeset
|
794 else \ |
35495
74e192d083e9
(CCL_READ_CHAR): Change the argument name from r to REG
Kenichi Handa <handa@m17n.org>
parents:
35328
diff
changeset
|
795 REG = '\r'; \ |
34816
f998b856d92b
(CCL_WRITE_CHAR): Don't handle EOL conversion here.
Kenichi Handa <handa@m17n.org>
parents:
34157
diff
changeset
|
796 } \ |
35495
74e192d083e9
(CCL_READ_CHAR): Change the argument name from r to REG
Kenichi Handa <handa@m17n.org>
parents:
35328
diff
changeset
|
797 if (REG == LEADING_CODE_8_BIT_CONTROL \ |
34816
f998b856d92b
(CCL_WRITE_CHAR): Don't handle EOL conversion here.
Kenichi Handa <handa@m17n.org>
parents:
34157
diff
changeset
|
798 && ccl->multibyte) \ |
35495
74e192d083e9
(CCL_READ_CHAR): Change the argument name from r to REG
Kenichi Handa <handa@m17n.org>
parents:
35328
diff
changeset
|
799 REG = *src++ - 0x20; \ |
34816
f998b856d92b
(CCL_WRITE_CHAR): Don't handle EOL conversion here.
Kenichi Handa <handa@m17n.org>
parents:
34157
diff
changeset
|
800 } \ |
f998b856d92b
(CCL_WRITE_CHAR): Don't handle EOL conversion here.
Kenichi Handa <handa@m17n.org>
parents:
34157
diff
changeset
|
801 else if (ccl->last_block) \ |
f998b856d92b
(CCL_WRITE_CHAR): Don't handle EOL conversion here.
Kenichi Handa <handa@m17n.org>
parents:
34157
diff
changeset
|
802 { \ |
f998b856d92b
(CCL_WRITE_CHAR): Don't handle EOL conversion here.
Kenichi Handa <handa@m17n.org>
parents:
34157
diff
changeset
|
803 ic = ccl->eof_ic; \ |
f998b856d92b
(CCL_WRITE_CHAR): Don't handle EOL conversion here.
Kenichi Handa <handa@m17n.org>
parents:
34157
diff
changeset
|
804 goto ccl_repeat; \ |
f998b856d92b
(CCL_WRITE_CHAR): Don't handle EOL conversion here.
Kenichi Handa <handa@m17n.org>
parents:
34157
diff
changeset
|
805 } \ |
f998b856d92b
(CCL_WRITE_CHAR): Don't handle EOL conversion here.
Kenichi Handa <handa@m17n.org>
parents:
34157
diff
changeset
|
806 else \ |
f998b856d92b
(CCL_WRITE_CHAR): Don't handle EOL conversion here.
Kenichi Handa <handa@m17n.org>
parents:
34157
diff
changeset
|
807 CCL_SUSPEND (CCL_STAT_SUSPEND_BY_SRC); \ |
17052 | 808 } while (0) |
809 | |
810 | |
27650
b875236c7043
(CCL_MAKE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
27566
diff
changeset
|
811 /* Set C to the character code made from CHARSET and CODE. This is |
b875236c7043
(CCL_MAKE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
27566
diff
changeset
|
812 like MAKE_CHAR but check the validity of CHARSET and CODE. If they |
b875236c7043
(CCL_MAKE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
27566
diff
changeset
|
813 are not valid, set C to (CODE & 0xFF) because that is usually the |
b875236c7043
(CCL_MAKE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
27566
diff
changeset
|
814 case that CCL_ReadMultibyteChar2 read an invalid code and it set |
b875236c7043
(CCL_MAKE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
27566
diff
changeset
|
815 CODE to that invalid byte. */ |
b875236c7043
(CCL_MAKE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
27566
diff
changeset
|
816 |
b875236c7043
(CCL_MAKE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
27566
diff
changeset
|
817 #define CCL_MAKE_CHAR(charset, code, c) \ |
b875236c7043
(CCL_MAKE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
27566
diff
changeset
|
818 do { \ |
b875236c7043
(CCL_MAKE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
27566
diff
changeset
|
819 if (charset == CHARSET_ASCII) \ |
b875236c7043
(CCL_MAKE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
27566
diff
changeset
|
820 c = code & 0xFF; \ |
b875236c7043
(CCL_MAKE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
27566
diff
changeset
|
821 else if (CHARSET_DEFINED_P (charset) \ |
b875236c7043
(CCL_MAKE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
27566
diff
changeset
|
822 && (code & 0x7F) >= 32 \ |
b875236c7043
(CCL_MAKE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
27566
diff
changeset
|
823 && (code < 256 || ((code >> 7) & 0x7F) >= 32)) \ |
b875236c7043
(CCL_MAKE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
27566
diff
changeset
|
824 { \ |
b875236c7043
(CCL_MAKE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
27566
diff
changeset
|
825 int c1 = code & 0x7F, c2 = 0; \ |
b875236c7043
(CCL_MAKE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
27566
diff
changeset
|
826 \ |
b875236c7043
(CCL_MAKE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
27566
diff
changeset
|
827 if (code >= 256) \ |
b875236c7043
(CCL_MAKE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
27566
diff
changeset
|
828 c2 = c1, c1 = (code >> 7) & 0x7F; \ |
29002
8dfd5b675823
(CCL_WRITE_CHAR): Be sure to write single byte characters
Kenichi Handa <handa@m17n.org>
parents:
27877
diff
changeset
|
829 c = MAKE_CHAR (charset, c1, c2); \ |
27650
b875236c7043
(CCL_MAKE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
27566
diff
changeset
|
830 } \ |
b875236c7043
(CCL_MAKE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
27566
diff
changeset
|
831 else \ |
29002
8dfd5b675823
(CCL_WRITE_CHAR): Be sure to write single byte characters
Kenichi Handa <handa@m17n.org>
parents:
27877
diff
changeset
|
832 c = code & 0xFF; \ |
27650
b875236c7043
(CCL_MAKE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
27566
diff
changeset
|
833 } while (0) |
b875236c7043
(CCL_MAKE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
27566
diff
changeset
|
834 |
b875236c7043
(CCL_MAKE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
27566
diff
changeset
|
835 |
17052 | 836 /* Execute CCL code on SRC_BYTES length text at SOURCE. The resulting |
837 text goes to a place pointed by DESTINATION, the length of which | |
838 should not exceed DST_BYTES. The bytes actually processed is | |
839 returned as *CONSUMED. The return value is the length of the | |
840 resulting text. As a side effect, the contents of CCL registers | |
841 are updated. If SOURCE or DESTINATION is NULL, only operations on | |
842 registers are permitted. */ | |
843 | |
844 #ifdef CCL_DEBUG | |
845 #define CCL_DEBUG_BACKTRACE_LEN 256 | |
846 int ccl_backtrace_table[CCL_BACKTRACE_TABLE]; | |
847 int ccl_backtrace_idx; | |
848 #endif | |
849 | |
850 struct ccl_prog_stack | |
851 { | |
17828
db443ea8cb36
(struct ccl_prog_stack): Declear the member ccl_prog as
Kenichi Handa <handa@m17n.org>
parents:
17728
diff
changeset
|
852 Lisp_Object *ccl_prog; /* Pointer to an array of CCL code. */ |
17052 | 853 int ic; /* Instruction Counter. */ |
854 }; | |
855 | |
24688
7b170d2184a4
(ccl_prog_stack_struct): Declare it as static.
Kenichi Handa <handa@m17n.org>
parents:
24567
diff
changeset
|
856 /* For the moment, we only support depth 256 of stack. */ |
7b170d2184a4
(ccl_prog_stack_struct): Declare it as static.
Kenichi Handa <handa@m17n.org>
parents:
24567
diff
changeset
|
857 static struct ccl_prog_stack ccl_prog_stack_struct[256]; |
7b170d2184a4
(ccl_prog_stack_struct): Declare it as static.
Kenichi Handa <handa@m17n.org>
parents:
24567
diff
changeset
|
858 |
21514 | 859 int |
17052 | 860 ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed) |
861 struct ccl_program *ccl; | |
862 unsigned char *source, *destination; | |
863 int src_bytes, dst_bytes; | |
864 int *consumed; | |
865 { | |
866 register int *reg = ccl->reg; | |
867 register int ic = ccl->ic; | |
37734
3d05b438e278
(ccl_driver): Don't copy remaining bytes in case
Gerd Moellmann <gerd@gnu.org>
parents:
36565
diff
changeset
|
868 register int code = 0, field1, field2; |
17370
6db43d8c9dfc
(ccl_driver): Fix Lisp_Object/integer confusion.
Karl Heuer <kwzh@gnu.org>
parents:
17323
diff
changeset
|
869 register Lisp_Object *ccl_prog = ccl->prog; |
17052 | 870 unsigned char *src = source, *src_end = src + src_bytes; |
871 unsigned char *dst = destination, *dst_end = dst + dst_bytes; | |
872 int jump_address; | |
37734
3d05b438e278
(ccl_driver): Don't copy remaining bytes in case
Gerd Moellmann <gerd@gnu.org>
parents:
36565
diff
changeset
|
873 int i = 0, j, op; |
24688
7b170d2184a4
(ccl_prog_stack_struct): Declare it as static.
Kenichi Handa <handa@m17n.org>
parents:
24567
diff
changeset
|
874 int stack_idx = ccl->stack_idx; |
23303
fb38954a02d3
(ccl_driver): Report correct CCL program counter on error.
Kenichi Handa <handa@m17n.org>
parents:
23280
diff
changeset
|
875 /* Instruction counter of the current CCL code. */ |
37734
3d05b438e278
(ccl_driver): Don't copy remaining bytes in case
Gerd Moellmann <gerd@gnu.org>
parents:
36565
diff
changeset
|
876 int this_ic = 0; |
34890
f203e7623af7
(CCL_WRITE_CHAR): Check variable `extra_bytes'.
Kenichi Handa <handa@m17n.org>
parents:
34816
diff
changeset
|
877 /* CCL_WRITE_CHAR will produce 8-bit code of range 0x80..0x9F. But, |
f203e7623af7
(CCL_WRITE_CHAR): Check variable `extra_bytes'.
Kenichi Handa <handa@m17n.org>
parents:
34816
diff
changeset
|
878 each of them will be converted to multibyte form of 2-byte |
f203e7623af7
(CCL_WRITE_CHAR): Check variable `extra_bytes'.
Kenichi Handa <handa@m17n.org>
parents:
34816
diff
changeset
|
879 sequence. For that conversion, we remember how many more bytes |
f203e7623af7
(CCL_WRITE_CHAR): Check variable `extra_bytes'.
Kenichi Handa <handa@m17n.org>
parents:
34816
diff
changeset
|
880 we must keep in DESTINATION in this variable. */ |
f203e7623af7
(CCL_WRITE_CHAR): Check variable `extra_bytes'.
Kenichi Handa <handa@m17n.org>
parents:
34816
diff
changeset
|
881 int extra_bytes = 0; |
17052 | 882 |
883 if (ic >= ccl->eof_ic) | |
884 ic = CCL_HEADER_MAIN; | |
885 | |
37734
3d05b438e278
(ccl_driver): Don't copy remaining bytes in case
Gerd Moellmann <gerd@gnu.org>
parents:
36565
diff
changeset
|
886 if (ccl->buf_magnification == 0) /* We can't produce any bytes. */ |
23280
b4656367043f
(CCL_WRITE_CHAR): Don't use bcopy.
Kenichi Handa <handa@m17n.org>
parents:
23072
diff
changeset
|
887 dst = NULL; |
b4656367043f
(CCL_WRITE_CHAR): Don't use bcopy.
Kenichi Handa <handa@m17n.org>
parents:
23072
diff
changeset
|
888 |
31551 | 889 /* Set mapping stack pointer. */ |
890 mapping_stack_pointer = mapping_stack; | |
891 | |
17052 | 892 #ifdef CCL_DEBUG |
893 ccl_backtrace_idx = 0; | |
894 #endif | |
895 | |
896 for (;;) | |
897 { | |
23068
ae33b925b20f
If eof is encounterd while processing the
Kenichi Handa <handa@m17n.org>
parents:
22718
diff
changeset
|
898 ccl_repeat: |
17052 | 899 #ifdef CCL_DEBUG |
900 ccl_backtrace_table[ccl_backtrace_idx++] = ic; | |
901 if (ccl_backtrace_idx >= CCL_DEBUG_BACKTRACE_LEN) | |
902 ccl_backtrace_idx = 0; | |
903 ccl_backtrace_table[ccl_backtrace_idx] = 0; | |
904 #endif | |
905 | |
906 if (!NILP (Vquit_flag) && NILP (Vinhibit_quit)) | |
907 { | |
908 /* We can't just signal Qquit, instead break the loop as if | |
909 the whole data is processed. Don't reset Vquit_flag, it | |
910 must be handled later at a safer place. */ | |
911 if (consumed) | |
912 src = source + src_bytes; | |
913 ccl->status = CCL_STAT_QUIT; | |
914 break; | |
915 } | |
916 | |
23303
fb38954a02d3
(ccl_driver): Report correct CCL program counter on error.
Kenichi Handa <handa@m17n.org>
parents:
23280
diff
changeset
|
917 this_ic = ic; |
17052 | 918 code = XINT (ccl_prog[ic]); ic++; |
919 field1 = code >> 8; | |
920 field2 = (code & 0xFF) >> 5; | |
921 | |
922 #define rrr field2 | |
923 #define RRR (field1 & 7) | |
924 #define Rrr ((field1 >> 3) & 7) | |
925 #define ADDR field1 | |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
926 #define EXCMD (field1 >> 6) |
17052 | 927 |
928 switch (code & 0x1F) | |
929 { | |
930 case CCL_SetRegister: /* 00000000000000000RRRrrrXXXXX */ | |
931 reg[rrr] = reg[RRR]; | |
932 break; | |
933 | |
934 case CCL_SetShortConst: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */ | |
935 reg[rrr] = field1; | |
936 break; | |
937 | |
938 case CCL_SetConst: /* 00000000000000000000rrrXXXXX */ | |
939 reg[rrr] = XINT (ccl_prog[ic]); | |
940 ic++; | |
941 break; | |
942 | |
943 case CCL_SetArray: /* CCCCCCCCCCCCCCCCCCCCRRRrrrXXXXX */ | |
944 i = reg[RRR]; | |
945 j = field1 >> 3; | |
946 if ((unsigned int) i < j) | |
947 reg[rrr] = XINT (ccl_prog[ic + i]); | |
948 ic += j; | |
949 break; | |
950 | |
951 case CCL_Jump: /* A--D--D--R--E--S--S-000XXXXX */ | |
952 ic += ADDR; | |
953 break; | |
954 | |
955 case CCL_JumpCond: /* A--D--D--R--E--S--S-rrrXXXXX */ | |
956 if (!reg[rrr]) | |
957 ic += ADDR; | |
958 break; | |
959 | |
960 case CCL_WriteRegisterJump: /* A--D--D--R--E--S--S-rrrXXXXX */ | |
961 i = reg[rrr]; | |
962 CCL_WRITE_CHAR (i); | |
963 ic += ADDR; | |
964 break; | |
965 | |
966 case CCL_WriteRegisterReadJump: /* A--D--D--R--E--S--S-rrrXXXXX */ | |
967 i = reg[rrr]; | |
968 CCL_WRITE_CHAR (i); | |
969 ic++; | |
970 CCL_READ_CHAR (reg[rrr]); | |
971 ic += ADDR - 1; | |
972 break; | |
973 | |
974 case CCL_WriteConstJump: /* A--D--D--R--E--S--S-000XXXXX */ | |
975 i = XINT (ccl_prog[ic]); | |
976 CCL_WRITE_CHAR (i); | |
977 ic += ADDR; | |
978 break; | |
979 | |
980 case CCL_WriteConstReadJump: /* A--D--D--R--E--S--S-rrrXXXXX */ | |
981 i = XINT (ccl_prog[ic]); | |
982 CCL_WRITE_CHAR (i); | |
983 ic++; | |
984 CCL_READ_CHAR (reg[rrr]); | |
985 ic += ADDR - 1; | |
986 break; | |
987 | |
988 case CCL_WriteStringJump: /* A--D--D--R--E--S--S-000XXXXX */ | |
989 j = XINT (ccl_prog[ic]); | |
990 ic++; | |
991 CCL_WRITE_STRING (j); | |
992 ic += ADDR - 1; | |
993 break; | |
994 | |
995 case CCL_WriteArrayReadJump: /* A--D--D--R--E--S--S-rrrXXXXX */ | |
996 i = reg[rrr]; | |
18613
614b916ff5bf
Fix bugs with inappropriate mixing of Lisp_Object with int.
Richard M. Stallman <rms@gnu.org>
parents:
18341
diff
changeset
|
997 j = XINT (ccl_prog[ic]); |
17052 | 998 if ((unsigned int) i < j) |
999 { | |
17323
15fa68d983e7
(ccl_driver): Fix bug of the case CCL_WriteArrayReadJump.
Kenichi Handa <handa@m17n.org>
parents:
17122
diff
changeset
|
1000 i = XINT (ccl_prog[ic + 1 + i]); |
17052 | 1001 CCL_WRITE_CHAR (i); |
1002 } | |
17323
15fa68d983e7
(ccl_driver): Fix bug of the case CCL_WriteArrayReadJump.
Kenichi Handa <handa@m17n.org>
parents:
17122
diff
changeset
|
1003 ic += j + 2; |
17052 | 1004 CCL_READ_CHAR (reg[rrr]); |
1005 ic += ADDR - (j + 2); | |
1006 break; | |
1007 | |
1008 case CCL_ReadJump: /* A--D--D--R--E--S--S-rrrYYYYY */ | |
1009 CCL_READ_CHAR (reg[rrr]); | |
1010 ic += ADDR; | |
1011 break; | |
1012 | |
1013 case CCL_ReadBranch: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */ | |
1014 CCL_READ_CHAR (reg[rrr]); | |
1015 /* fall through ... */ | |
1016 case CCL_Branch: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */ | |
1017 if ((unsigned int) reg[rrr] < field1) | |
1018 ic += XINT (ccl_prog[ic + reg[rrr]]); | |
1019 else | |
1020 ic += XINT (ccl_prog[ic + field1]); | |
1021 break; | |
1022 | |
1023 case CCL_ReadRegister: /* CCCCCCCCCCCCCCCCCCCCrrXXXXX */ | |
1024 while (1) | |
1025 { | |
1026 CCL_READ_CHAR (reg[rrr]); | |
1027 if (!field1) break; | |
1028 code = XINT (ccl_prog[ic]); ic++; | |
1029 field1 = code >> 8; | |
1030 field2 = (code & 0xFF) >> 5; | |
1031 } | |
1032 break; | |
1033 | |
1034 case CCL_WriteExprConst: /* 1:00000OPERATION000RRR000XXXXX */ | |
1035 rrr = 7; | |
1036 i = reg[RRR]; | |
1037 j = XINT (ccl_prog[ic]); | |
1038 op = field1 >> 6; | |
27566
d96c50f3e37e
(ccl_driver) <CCL_WriteExprRegister>: Set jump_address
Kenichi Handa <handa@m17n.org>
parents:
26842
diff
changeset
|
1039 jump_address = ic + 1; |
17052 | 1040 goto ccl_set_expr; |
1041 | |
1042 case CCL_WriteRegister: /* CCCCCCCCCCCCCCCCCCCrrrXXXXX */ | |
1043 while (1) | |
1044 { | |
1045 i = reg[rrr]; | |
1046 CCL_WRITE_CHAR (i); | |
1047 if (!field1) break; | |
1048 code = XINT (ccl_prog[ic]); ic++; | |
1049 field1 = code >> 8; | |
1050 field2 = (code & 0xFF) >> 5; | |
1051 } | |
1052 break; | |
1053 | |
1054 case CCL_WriteExprRegister: /* 1:00000OPERATIONRrrRRR000XXXXX */ | |
1055 rrr = 7; | |
1056 i = reg[RRR]; | |
1057 j = reg[Rrr]; | |
1058 op = field1 >> 6; | |
27566
d96c50f3e37e
(ccl_driver) <CCL_WriteExprRegister>: Set jump_address
Kenichi Handa <handa@m17n.org>
parents:
26842
diff
changeset
|
1059 jump_address = ic; |
17052 | 1060 goto ccl_set_expr; |
1061 | |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1062 case CCL_Call: /* 1:CCCCCCCCCCCCCCCCCCCCFFFXXXXX */ |
17052 | 1063 { |
1064 Lisp_Object slot; | |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1065 int prog_id; |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1066 |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1067 /* If FFF is nonzero, the CCL program ID is in the |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1068 following code. */ |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1069 if (rrr) |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1070 { |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1071 prog_id = XINT (ccl_prog[ic]); |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1072 ic++; |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1073 } |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1074 else |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1075 prog_id = field1; |
17052 | 1076 |
1077 if (stack_idx >= 256 | |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1078 || prog_id < 0 |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1079 || prog_id >= ASIZE (Vccl_program_table) |
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1080 || (slot = AREF (Vccl_program_table, prog_id), !VECTORP (slot)) |
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1081 || !VECTORP (AREF (slot, 1))) |
17052 | 1082 { |
1083 if (stack_idx > 0) | |
1084 { | |
1085 ccl_prog = ccl_prog_stack_struct[0].ccl_prog; | |
1086 ic = ccl_prog_stack_struct[0].ic; | |
1087 } | |
1088 CCL_INVALID_CMD; | |
1089 } | |
1090 | |
1091 ccl_prog_stack_struct[stack_idx].ccl_prog = ccl_prog; | |
1092 ccl_prog_stack_struct[stack_idx].ic = ic; | |
1093 stack_idx++; | |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1094 ccl_prog = XVECTOR (AREF (slot, 1))->contents; |
17052 | 1095 ic = CCL_HEADER_MAIN; |
1096 } | |
1097 break; | |
1098 | |
1099 case CCL_WriteConstString: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */ | |
1100 if (!rrr) | |
1101 CCL_WRITE_CHAR (field1); | |
1102 else | |
1103 { | |
1104 CCL_WRITE_STRING (field1); | |
1105 ic += (field1 + 2) / 3; | |
1106 } | |
1107 break; | |
1108 | |
1109 case CCL_WriteArray: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */ | |
1110 i = reg[rrr]; | |
1111 if ((unsigned int) i < field1) | |
1112 { | |
1113 j = XINT (ccl_prog[ic + i]); | |
1114 CCL_WRITE_CHAR (j); | |
1115 } | |
1116 ic += field1; | |
1117 break; | |
1118 | |
1119 case CCL_End: /* 0000000000000000000000XXXXX */ | |
29847
c6b0046bb943
(ccl_driver) <CCL_End>: Decrement stack_idx only when it is greater
Kenichi Handa <handa@m17n.org>
parents:
29724
diff
changeset
|
1120 if (stack_idx > 0) |
17052 | 1121 { |
29847
c6b0046bb943
(ccl_driver) <CCL_End>: Decrement stack_idx only when it is greater
Kenichi Handa <handa@m17n.org>
parents:
29724
diff
changeset
|
1122 stack_idx--; |
17052 | 1123 ccl_prog = ccl_prog_stack_struct[stack_idx].ccl_prog; |
1124 ic = ccl_prog_stack_struct[stack_idx].ic; | |
1125 break; | |
1126 } | |
23884
179bcb86f12f
(CCL_SUCCESS): Don't set ccl->ic.
Kenichi Handa <handa@m17n.org>
parents:
23768
diff
changeset
|
1127 if (src) |
179bcb86f12f
(CCL_SUCCESS): Don't set ccl->ic.
Kenichi Handa <handa@m17n.org>
parents:
23768
diff
changeset
|
1128 src = src_end; |
179bcb86f12f
(CCL_SUCCESS): Don't set ccl->ic.
Kenichi Handa <handa@m17n.org>
parents:
23768
diff
changeset
|
1129 /* ccl->ic should points to this command code again to |
179bcb86f12f
(CCL_SUCCESS): Don't set ccl->ic.
Kenichi Handa <handa@m17n.org>
parents:
23768
diff
changeset
|
1130 suppress further processing. */ |
179bcb86f12f
(CCL_SUCCESS): Don't set ccl->ic.
Kenichi Handa <handa@m17n.org>
parents:
23768
diff
changeset
|
1131 ic--; |
17052 | 1132 CCL_SUCCESS; |
1133 | |
1134 case CCL_ExprSelfConst: /* 00000OPERATION000000rrrXXXXX */ | |
1135 i = XINT (ccl_prog[ic]); | |
1136 ic++; | |
1137 op = field1 >> 6; | |
1138 goto ccl_expr_self; | |
1139 | |
1140 case CCL_ExprSelfReg: /* 00000OPERATION000RRRrrrXXXXX */ | |
1141 i = reg[RRR]; | |
1142 op = field1 >> 6; | |
1143 | |
1144 ccl_expr_self: | |
1145 switch (op) | |
1146 { | |
1147 case CCL_PLUS: reg[rrr] += i; break; | |
1148 case CCL_MINUS: reg[rrr] -= i; break; | |
1149 case CCL_MUL: reg[rrr] *= i; break; | |
1150 case CCL_DIV: reg[rrr] /= i; break; | |
1151 case CCL_MOD: reg[rrr] %= i; break; | |
1152 case CCL_AND: reg[rrr] &= i; break; | |
1153 case CCL_OR: reg[rrr] |= i; break; | |
1154 case CCL_XOR: reg[rrr] ^= i; break; | |
1155 case CCL_LSH: reg[rrr] <<= i; break; | |
1156 case CCL_RSH: reg[rrr] >>= i; break; | |
1157 case CCL_LSH8: reg[rrr] <<= 8; reg[rrr] |= i; break; | |
1158 case CCL_RSH8: reg[7] = reg[rrr] & 0xFF; reg[rrr] >>= 8; break; | |
1159 case CCL_DIVMOD: reg[7] = reg[rrr] % i; reg[rrr] /= i; break; | |
1160 case CCL_LS: reg[rrr] = reg[rrr] < i; break; | |
1161 case CCL_GT: reg[rrr] = reg[rrr] > i; break; | |
1162 case CCL_EQ: reg[rrr] = reg[rrr] == i; break; | |
1163 case CCL_LE: reg[rrr] = reg[rrr] <= i; break; | |
1164 case CCL_GE: reg[rrr] = reg[rrr] >= i; break; | |
1165 case CCL_NE: reg[rrr] = reg[rrr] != i; break; | |
1166 default: CCL_INVALID_CMD; | |
1167 } | |
1168 break; | |
1169 | |
1170 case CCL_SetExprConst: /* 00000OPERATION000RRRrrrXXXXX */ | |
1171 i = reg[RRR]; | |
1172 j = XINT (ccl_prog[ic]); | |
1173 op = field1 >> 6; | |
1174 jump_address = ++ic; | |
1175 goto ccl_set_expr; | |
1176 | |
1177 case CCL_SetExprReg: /* 00000OPERATIONRrrRRRrrrXXXXX */ | |
1178 i = reg[RRR]; | |
1179 j = reg[Rrr]; | |
1180 op = field1 >> 6; | |
1181 jump_address = ic; | |
1182 goto ccl_set_expr; | |
1183 | |
1184 case CCL_ReadJumpCondExprConst: /* A--D--D--R--E--S--S-rrrXXXXX */ | |
1185 CCL_READ_CHAR (reg[rrr]); | |
1186 case CCL_JumpCondExprConst: /* A--D--D--R--E--S--S-rrrXXXXX */ | |
1187 i = reg[rrr]; | |
1188 op = XINT (ccl_prog[ic]); | |
1189 jump_address = ic++ + ADDR; | |
1190 j = XINT (ccl_prog[ic]); | |
1191 ic++; | |
1192 rrr = 7; | |
1193 goto ccl_set_expr; | |
1194 | |
1195 case CCL_ReadJumpCondExprReg: /* A--D--D--R--E--S--S-rrrXXXXX */ | |
1196 CCL_READ_CHAR (reg[rrr]); | |
1197 case CCL_JumpCondExprReg: | |
1198 i = reg[rrr]; | |
1199 op = XINT (ccl_prog[ic]); | |
1200 jump_address = ic++ + ADDR; | |
1201 j = reg[XINT (ccl_prog[ic])]; | |
1202 ic++; | |
1203 rrr = 7; | |
1204 | |
1205 ccl_set_expr: | |
1206 switch (op) | |
1207 { | |
1208 case CCL_PLUS: reg[rrr] = i + j; break; | |
1209 case CCL_MINUS: reg[rrr] = i - j; break; | |
1210 case CCL_MUL: reg[rrr] = i * j; break; | |
1211 case CCL_DIV: reg[rrr] = i / j; break; | |
1212 case CCL_MOD: reg[rrr] = i % j; break; | |
1213 case CCL_AND: reg[rrr] = i & j; break; | |
1214 case CCL_OR: reg[rrr] = i | j; break; | |
1215 case CCL_XOR: reg[rrr] = i ^ j;; break; | |
1216 case CCL_LSH: reg[rrr] = i << j; break; | |
1217 case CCL_RSH: reg[rrr] = i >> j; break; | |
1218 case CCL_LSH8: reg[rrr] = (i << 8) | j; break; | |
1219 case CCL_RSH8: reg[rrr] = i >> 8; reg[7] = i & 0xFF; break; | |
1220 case CCL_DIVMOD: reg[rrr] = i / j; reg[7] = i % j; break; | |
1221 case CCL_LS: reg[rrr] = i < j; break; | |
1222 case CCL_GT: reg[rrr] = i > j; break; | |
1223 case CCL_EQ: reg[rrr] = i == j; break; | |
1224 case CCL_LE: reg[rrr] = i <= j; break; | |
1225 case CCL_GE: reg[rrr] = i >= j; break; | |
1226 case CCL_NE: reg[rrr] = i != j; break; | |
23428
49c7e979c16c
(CCL_DECODE_SJIS, CCL_ENCODE_SJIS): Swap the definitions.
Kenichi Handa <handa@m17n.org>
parents:
23303
diff
changeset
|
1227 case CCL_DECODE_SJIS: DECODE_SJIS (i, j, reg[rrr], reg[7]); break; |
17052 | 1228 case CCL_ENCODE_SJIS: ENCODE_SJIS (i, j, reg[rrr], reg[7]); break; |
1229 default: CCL_INVALID_CMD; | |
1230 } | |
1231 code &= 0x1F; | |
1232 if (code == CCL_WriteExprConst || code == CCL_WriteExprRegister) | |
1233 { | |
1234 i = reg[rrr]; | |
1235 CCL_WRITE_CHAR (i); | |
27566
d96c50f3e37e
(ccl_driver) <CCL_WriteExprRegister>: Set jump_address
Kenichi Handa <handa@m17n.org>
parents:
26842
diff
changeset
|
1236 ic = jump_address; |
17052 | 1237 } |
1238 else if (!reg[rrr]) | |
1239 ic = jump_address; | |
1240 break; | |
1241 | |
35328
f4c8b11d4d36
(CCL_Extension): Fix typo (originally CCL_Extention). Caller changed.
Kenichi Handa <handa@m17n.org>
parents:
35322
diff
changeset
|
1242 case CCL_Extension: |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1243 switch (EXCMD) |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1244 { |
21551 | 1245 case CCL_ReadMultibyteChar2: |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1246 if (!src) |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1247 CCL_INVALID_CMD; |
24567
36e004c54eaf
(ccl_driver) <CCL_ReadMultibyteChar2>: Fix bug of handling
Kenichi Handa <handa@m17n.org>
parents:
23884
diff
changeset
|
1248 |
35498
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1249 if (src >= src_end) |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1250 { |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1251 src++; |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1252 goto ccl_read_multibyte_character_suspend; |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1253 } |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1254 |
36565
022c0e9f5e9b
(ccl_driver) <CCL_ReadMultibyteChar2>: Fix for the case
Kenichi Handa <handa@m17n.org>
parents:
36467
diff
changeset
|
1255 if (!ccl->multibyte) |
022c0e9f5e9b
(ccl_driver) <CCL_ReadMultibyteChar2>: Fix for the case
Kenichi Handa <handa@m17n.org>
parents:
36467
diff
changeset
|
1256 { |
022c0e9f5e9b
(ccl_driver) <CCL_ReadMultibyteChar2>: Fix for the case
Kenichi Handa <handa@m17n.org>
parents:
36467
diff
changeset
|
1257 int bytes; |
022c0e9f5e9b
(ccl_driver) <CCL_ReadMultibyteChar2>: Fix for the case
Kenichi Handa <handa@m17n.org>
parents:
36467
diff
changeset
|
1258 if (!UNIBYTE_STR_AS_MULTIBYTE_P (src, src_end - src, bytes)) |
022c0e9f5e9b
(ccl_driver) <CCL_ReadMultibyteChar2>: Fix for the case
Kenichi Handa <handa@m17n.org>
parents:
36467
diff
changeset
|
1259 { |
022c0e9f5e9b
(ccl_driver) <CCL_ReadMultibyteChar2>: Fix for the case
Kenichi Handa <handa@m17n.org>
parents:
36467
diff
changeset
|
1260 reg[RRR] = CHARSET_8_BIT_CONTROL; |
022c0e9f5e9b
(ccl_driver) <CCL_ReadMultibyteChar2>: Fix for the case
Kenichi Handa <handa@m17n.org>
parents:
36467
diff
changeset
|
1261 reg[rrr] = *src++; |
022c0e9f5e9b
(ccl_driver) <CCL_ReadMultibyteChar2>: Fix for the case
Kenichi Handa <handa@m17n.org>
parents:
36467
diff
changeset
|
1262 break; |
022c0e9f5e9b
(ccl_driver) <CCL_ReadMultibyteChar2>: Fix for the case
Kenichi Handa <handa@m17n.org>
parents:
36467
diff
changeset
|
1263 } |
022c0e9f5e9b
(ccl_driver) <CCL_ReadMultibyteChar2>: Fix for the case
Kenichi Handa <handa@m17n.org>
parents:
36467
diff
changeset
|
1264 } |
35498
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1265 i = *src++; |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1266 if (i == '\n' && ccl->eol_type != CODING_EOL_LF) |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1267 { |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1268 /* We are encoding. */ |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1269 if (ccl->eol_type == CODING_EOL_CRLF) |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1270 { |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1271 if (ccl->cr_consumed) |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1272 ccl->cr_consumed = 0; |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1273 else |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1274 { |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1275 ccl->cr_consumed = 1; |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1276 i = '\r'; |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1277 src--; |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1278 } |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1279 } |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1280 else |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1281 i = '\r'; |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1282 reg[rrr] = i; |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1283 reg[RRR] = CHARSET_ASCII; |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1284 } |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1285 else if (i < 0x80) |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1286 { |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1287 /* ASCII */ |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1288 reg[rrr] = i; |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1289 reg[RRR] = CHARSET_ASCII; |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1290 } |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1291 else if (i <= MAX_CHARSET_OFFICIAL_DIMENSION2) |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1292 { |
36102
cd1abcc15e9c
(ccl_driver) [CCL_ReadMultibyteChar2]: If SRC points an
Kenichi Handa <handa@m17n.org>
parents:
35883
diff
changeset
|
1293 int dimension = BYTES_BY_CHAR_HEAD (i) - 1; |
cd1abcc15e9c
(ccl_driver) [CCL_ReadMultibyteChar2]: If SRC points an
Kenichi Handa <handa@m17n.org>
parents:
35883
diff
changeset
|
1294 |
cd1abcc15e9c
(ccl_driver) [CCL_ReadMultibyteChar2]: If SRC points an
Kenichi Handa <handa@m17n.org>
parents:
35883
diff
changeset
|
1295 if (dimension == 0) |
cd1abcc15e9c
(ccl_driver) [CCL_ReadMultibyteChar2]: If SRC points an
Kenichi Handa <handa@m17n.org>
parents:
35883
diff
changeset
|
1296 { |
cd1abcc15e9c
(ccl_driver) [CCL_ReadMultibyteChar2]: If SRC points an
Kenichi Handa <handa@m17n.org>
parents:
35883
diff
changeset
|
1297 /* `i' is a leading code for an undefined charset. */ |
cd1abcc15e9c
(ccl_driver) [CCL_ReadMultibyteChar2]: If SRC points an
Kenichi Handa <handa@m17n.org>
parents:
35883
diff
changeset
|
1298 reg[RRR] = CHARSET_8_BIT_GRAPHIC; |
cd1abcc15e9c
(ccl_driver) [CCL_ReadMultibyteChar2]: If SRC points an
Kenichi Handa <handa@m17n.org>
parents:
35883
diff
changeset
|
1299 reg[rrr] = i; |
cd1abcc15e9c
(ccl_driver) [CCL_ReadMultibyteChar2]: If SRC points an
Kenichi Handa <handa@m17n.org>
parents:
35883
diff
changeset
|
1300 } |
cd1abcc15e9c
(ccl_driver) [CCL_ReadMultibyteChar2]: If SRC points an
Kenichi Handa <handa@m17n.org>
parents:
35883
diff
changeset
|
1301 else if (src + dimension > src_end) |
35498
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1302 goto ccl_read_multibyte_character_suspend; |
36102
cd1abcc15e9c
(ccl_driver) [CCL_ReadMultibyteChar2]: If SRC points an
Kenichi Handa <handa@m17n.org>
parents:
35883
diff
changeset
|
1303 else |
cd1abcc15e9c
(ccl_driver) [CCL_ReadMultibyteChar2]: If SRC points an
Kenichi Handa <handa@m17n.org>
parents:
35883
diff
changeset
|
1304 { |
cd1abcc15e9c
(ccl_driver) [CCL_ReadMultibyteChar2]: If SRC points an
Kenichi Handa <handa@m17n.org>
parents:
35883
diff
changeset
|
1305 reg[RRR] = i; |
cd1abcc15e9c
(ccl_driver) [CCL_ReadMultibyteChar2]: If SRC points an
Kenichi Handa <handa@m17n.org>
parents:
35883
diff
changeset
|
1306 i = (*src++ & 0x7F); |
cd1abcc15e9c
(ccl_driver) [CCL_ReadMultibyteChar2]: If SRC points an
Kenichi Handa <handa@m17n.org>
parents:
35883
diff
changeset
|
1307 if (dimension == 1) |
cd1abcc15e9c
(ccl_driver) [CCL_ReadMultibyteChar2]: If SRC points an
Kenichi Handa <handa@m17n.org>
parents:
35883
diff
changeset
|
1308 reg[rrr] = i; |
cd1abcc15e9c
(ccl_driver) [CCL_ReadMultibyteChar2]: If SRC points an
Kenichi Handa <handa@m17n.org>
parents:
35883
diff
changeset
|
1309 else |
cd1abcc15e9c
(ccl_driver) [CCL_ReadMultibyteChar2]: If SRC points an
Kenichi Handa <handa@m17n.org>
parents:
35883
diff
changeset
|
1310 reg[rrr] = ((i << 7) | (*src++ & 0x7F)); |
cd1abcc15e9c
(ccl_driver) [CCL_ReadMultibyteChar2]: If SRC points an
Kenichi Handa <handa@m17n.org>
parents:
35883
diff
changeset
|
1311 } |
35498
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1312 } |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1313 else if ((i == LEADING_CODE_PRIVATE_11) |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1314 || (i == LEADING_CODE_PRIVATE_12)) |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1315 { |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1316 if ((src + 1) >= src_end) |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1317 goto ccl_read_multibyte_character_suspend; |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1318 reg[RRR] = *src++; |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1319 reg[rrr] = (*src++ & 0x7F); |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1320 } |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1321 else if ((i == LEADING_CODE_PRIVATE_21) |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1322 || (i == LEADING_CODE_PRIVATE_22)) |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1323 { |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1324 if ((src + 2) >= src_end) |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1325 goto ccl_read_multibyte_character_suspend; |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1326 reg[RRR] = *src++; |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1327 i = (*src++ & 0x7F); |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1328 reg[rrr] = ((i << 7) | (*src & 0x7F)); |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1329 src++; |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1330 } |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1331 else if (i == LEADING_CODE_8_BIT_CONTROL) |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1332 { |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1333 if (src >= src_end) |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1334 goto ccl_read_multibyte_character_suspend; |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1335 reg[RRR] = CHARSET_8_BIT_CONTROL; |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1336 reg[rrr] = (*src++ - 0x20); |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1337 } |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1338 else if (i >= 0xA0) |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1339 { |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1340 reg[RRR] = CHARSET_8_BIT_GRAPHIC; |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1341 reg[rrr] = i; |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1342 } |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1343 else |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1344 { |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1345 /* INVALID CODE. Return a single byte character. */ |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1346 reg[RRR] = CHARSET_ASCII; |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1347 reg[rrr] = i; |
add3de5a4293
(CCL_CALL_FOR_MAP_INSTRUCTION): Use "if (1)..." not "do {...".
Kenichi Handa <handa@m17n.org>
parents:
35495
diff
changeset
|
1348 } |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1349 break; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1350 |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1351 ccl_read_multibyte_character_suspend: |
36565
022c0e9f5e9b
(ccl_driver) <CCL_ReadMultibyteChar2>: Fix for the case
Kenichi Handa <handa@m17n.org>
parents:
36467
diff
changeset
|
1352 if (src <= src_end && !ccl->multibyte && ccl->last_block) |
022c0e9f5e9b
(ccl_driver) <CCL_ReadMultibyteChar2>: Fix for the case
Kenichi Handa <handa@m17n.org>
parents:
36467
diff
changeset
|
1353 { |
022c0e9f5e9b
(ccl_driver) <CCL_ReadMultibyteChar2>: Fix for the case
Kenichi Handa <handa@m17n.org>
parents:
36467
diff
changeset
|
1354 reg[RRR] = CHARSET_8_BIT_CONTROL; |
022c0e9f5e9b
(ccl_driver) <CCL_ReadMultibyteChar2>: Fix for the case
Kenichi Handa <handa@m17n.org>
parents:
36467
diff
changeset
|
1355 reg[rrr] = i; |
022c0e9f5e9b
(ccl_driver) <CCL_ReadMultibyteChar2>: Fix for the case
Kenichi Handa <handa@m17n.org>
parents:
36467
diff
changeset
|
1356 break; |
022c0e9f5e9b
(ccl_driver) <CCL_ReadMultibyteChar2>: Fix for the case
Kenichi Handa <handa@m17n.org>
parents:
36467
diff
changeset
|
1357 } |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1358 src--; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1359 if (ccl->last_block) |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1360 { |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1361 ic = ccl->eof_ic; |
23072 | 1362 goto ccl_repeat; |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1363 } |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1364 else |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1365 CCL_SUSPEND (CCL_STAT_SUSPEND_BY_SRC); |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1366 |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1367 break; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1368 |
21551 | 1369 case CCL_WriteMultibyteChar2: |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1370 i = reg[RRR]; /* charset */ |
29170
401490c30961
(ccl_driver) <CCL_ReadMultibyteChar2>
Kenichi Handa <handa@m17n.org>
parents:
29002
diff
changeset
|
1371 if (i == CHARSET_ASCII |
401490c30961
(ccl_driver) <CCL_ReadMultibyteChar2>
Kenichi Handa <handa@m17n.org>
parents:
29002
diff
changeset
|
1372 || i == CHARSET_8_BIT_CONTROL |
401490c30961
(ccl_driver) <CCL_ReadMultibyteChar2>
Kenichi Handa <handa@m17n.org>
parents:
29002
diff
changeset
|
1373 || i == CHARSET_8_BIT_GRAPHIC) |
24688
7b170d2184a4
(ccl_prog_stack_struct): Declare it as static.
Kenichi Handa <handa@m17n.org>
parents:
24567
diff
changeset
|
1374 i = reg[rrr] & 0xFF; |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1375 else if (CHARSET_DIMENSION (i) == 1) |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1376 i = ((i - 0x70) << 7) | (reg[rrr] & 0x7F); |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1377 else if (i < MIN_CHARSET_PRIVATE_DIMENSION2) |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1378 i = ((i - 0x8F) << 14) | reg[rrr]; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1379 else |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1380 i = ((i - 0xE0) << 14) | reg[rrr]; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1381 |
36411
120891909abe
(CCL_WRITE_MULTIBYTE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
36102
diff
changeset
|
1382 CCL_WRITE_MULTIBYTE_CHAR (i); |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1383 |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1384 break; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1385 |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
1386 case CCL_TranslateCharacter: |
27650
b875236c7043
(CCL_MAKE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
27566
diff
changeset
|
1387 CCL_MAKE_CHAR (reg[RRR], reg[rrr], i); |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
1388 op = translate_char (GET_TRANSLATION_TABLE (reg[Rrr]), |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
1389 i, -1, 0, 0); |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1390 SPLIT_CHAR (op, reg[RRR], i, j); |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1391 if (j != -1) |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1392 i = (i << 7) | j; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1393 |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1394 reg[rrr] = i; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1395 break; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1396 |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
1397 case CCL_TranslateCharacterConstTbl: |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1398 op = XINT (ccl_prog[ic]); /* table */ |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1399 ic++; |
27650
b875236c7043
(CCL_MAKE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
27566
diff
changeset
|
1400 CCL_MAKE_CHAR (reg[RRR], reg[rrr], i); |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
1401 op = translate_char (GET_TRANSLATION_TABLE (op), i, -1, 0, 0); |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1402 SPLIT_CHAR (op, reg[RRR], i, j); |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1403 if (j != -1) |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1404 i = (i << 7) | j; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1405 |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1406 reg[rrr] = i; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1407 break; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1408 |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1409 case CCL_IterateMultipleMap: |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1410 { |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
1411 Lisp_Object map, content, attrib, value; |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1412 int point, size, fin_ic; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1413 |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
1414 j = XINT (ccl_prog[ic++]); /* number of maps. */ |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1415 fin_ic = ic + j; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1416 op = reg[rrr]; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1417 if ((j > reg[RRR]) && (j >= 0)) |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1418 { |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1419 ic += reg[RRR]; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1420 i = reg[RRR]; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1421 } |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1422 else |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1423 { |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1424 reg[RRR] = -1; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1425 ic = fin_ic; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1426 break; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1427 } |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1428 |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1429 for (;i < j;i++) |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1430 { |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1431 |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1432 size = ASIZE (Vcode_conversion_map_vector); |
21518
1b0d88d6fb42
(ccl_driver, syms_of_ccl): Fix mixing of Lisp_Object and
Andreas Schwab <schwab@suse.de>
parents:
21514
diff
changeset
|
1433 point = XINT (ccl_prog[ic++]); |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1434 if (point >= size) continue; |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1435 map = AREF (Vcode_conversion_map_vector, point); |
21551 | 1436 |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
1437 /* Check map varidity. */ |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
1438 if (!CONSP (map)) continue; |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25066
diff
changeset
|
1439 map = XCDR (map); |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
1440 if (!VECTORP (map)) continue; |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1441 size = ASIZE (map); |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1442 if (size <= 1) continue; |
21551 | 1443 |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1444 content = AREF (map, 0); |
21551 | 1445 |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
1446 /* check map type, |
21551 | 1447 [STARTPOINT VAL1 VAL2 ...] or |
1448 [t ELELMENT STARTPOINT ENDPOINT] */ | |
1449 if (NUMBERP (content)) | |
1450 { | |
1451 point = XUINT (content); | |
1452 point = op - point + 1; | |
1453 if (!((point >= 1) && (point < size))) continue; | |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1454 content = AREF (map, point); |
21551 | 1455 } |
1456 else if (EQ (content, Qt)) | |
1457 { | |
1458 if (size != 4) continue; | |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1459 if ((op >= XUINT (AREF (map, 2))) |
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1460 && (op < XUINT (AREF (map, 3)))) |
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1461 content = AREF (map, 1); |
21551 | 1462 else |
1463 continue; | |
1464 } | |
1465 else | |
1466 continue; | |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1467 |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1468 if (NILP (content)) |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1469 continue; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1470 else if (NUMBERP (content)) |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1471 { |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1472 reg[RRR] = i; |
21551 | 1473 reg[rrr] = XINT(content); |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1474 break; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1475 } |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1476 else if (EQ (content, Qt) || EQ (content, Qlambda)) |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1477 { |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1478 reg[RRR] = i; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1479 break; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1480 } |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1481 else if (CONSP (content)) |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1482 { |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25066
diff
changeset
|
1483 attrib = XCAR (content); |
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25066
diff
changeset
|
1484 value = XCDR (content); |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1485 if (!NUMBERP (attrib) || !NUMBERP (value)) |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1486 continue; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1487 reg[RRR] = i; |
21551 | 1488 reg[rrr] = XUINT (value); |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1489 break; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1490 } |
31551 | 1491 else if (SYMBOLP (content)) |
1492 CCL_CALL_FOR_MAP_INSTRUCTION (content, fin_ic); | |
1493 else | |
1494 CCL_INVALID_CMD; | |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1495 } |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1496 if (i == j) |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1497 reg[RRR] = -1; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1498 ic = fin_ic; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1499 } |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1500 break; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1501 |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
1502 case CCL_MapMultiple: |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1503 { |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
1504 Lisp_Object map, content, attrib, value; |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
1505 int point, size, map_vector_size; |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
1506 int map_set_rest_length, fin_ic; |
31551 | 1507 int current_ic = this_ic; |
1508 | |
1509 /* inhibit recursive call on MapMultiple. */ | |
1510 if (stack_idx_of_map_multiple > 0) | |
1511 { | |
1512 if (stack_idx_of_map_multiple <= stack_idx) | |
1513 { | |
1514 stack_idx_of_map_multiple = 0; | |
1515 mapping_stack_pointer = mapping_stack; | |
1516 CCL_INVALID_CMD; | |
1517 } | |
1518 } | |
1519 else | |
1520 mapping_stack_pointer = mapping_stack; | |
1521 stack_idx_of_map_multiple = 0; | |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1522 |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
1523 map_set_rest_length = |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
1524 XINT (ccl_prog[ic++]); /* number of maps and separators. */ |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
1525 fin_ic = ic + map_set_rest_length; |
31551 | 1526 op = reg[rrr]; |
1527 | |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
1528 if ((map_set_rest_length > reg[RRR]) && (reg[RRR] >= 0)) |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1529 { |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1530 ic += reg[RRR]; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1531 i = reg[RRR]; |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
1532 map_set_rest_length -= i; |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1533 } |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1534 else |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1535 { |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1536 ic = fin_ic; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1537 reg[RRR] = -1; |
31551 | 1538 mapping_stack_pointer = mapping_stack; |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1539 break; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1540 } |
31551 | 1541 |
1542 if (mapping_stack_pointer <= (mapping_stack + 1)) | |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1543 { |
31551 | 1544 /* Set up initial state. */ |
1545 mapping_stack_pointer = mapping_stack; | |
1546 PUSH_MAPPING_STACK (0, op); | |
1547 reg[RRR] = -1; | |
1548 } | |
1549 else | |
1550 { | |
1551 /* Recover after calling other ccl program. */ | |
1552 int orig_op; | |
21551 | 1553 |
31551 | 1554 POP_MAPPING_STACK (map_set_rest_length, orig_op); |
1555 POP_MAPPING_STACK (map_set_rest_length, reg[rrr]); | |
1556 switch (op) | |
21551 | 1557 { |
31551 | 1558 case -1: |
1559 /* Regard it as Qnil. */ | |
1560 op = orig_op; | |
1561 i++; | |
1562 ic++; | |
1563 map_set_rest_length--; | |
1564 break; | |
1565 case -2: | |
1566 /* Regard it as Qt. */ | |
1567 op = reg[rrr]; | |
1568 i++; | |
1569 ic++; | |
1570 map_set_rest_length--; | |
1571 break; | |
1572 case -3: | |
1573 /* Regard it as Qlambda. */ | |
1574 op = orig_op; | |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
1575 i += map_set_rest_length; |
31551 | 1576 ic += map_set_rest_length; |
1577 map_set_rest_length = 0; | |
1578 break; | |
1579 default: | |
1580 /* Regard it as normal mapping. */ | |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
1581 i += map_set_rest_length; |
31551 | 1582 ic += map_set_rest_length; |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
1583 POP_MAPPING_STACK (map_set_rest_length, reg[rrr]); |
21551 | 1584 break; |
1585 } | |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1586 } |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1587 map_vector_size = ASIZE (Vcode_conversion_map_vector); |
31551 | 1588 |
1589 do { | |
1590 for (;map_set_rest_length > 0;i++, ic++, map_set_rest_length--) | |
1591 { | |
1592 point = XINT(ccl_prog[ic]); | |
1593 if (point < 0) | |
1594 { | |
1595 /* +1 is for including separator. */ | |
1596 point = -point + 1; | |
1597 if (mapping_stack_pointer | |
1598 >= &mapping_stack[MAX_MAP_SET_LEVEL]) | |
1599 CCL_INVALID_CMD; | |
1600 PUSH_MAPPING_STACK (map_set_rest_length - point, | |
1601 reg[rrr]); | |
1602 map_set_rest_length = point; | |
1603 reg[rrr] = op; | |
1604 continue; | |
1605 } | |
1606 | |
1607 if (point >= map_vector_size) continue; | |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1608 map = AREF (Vcode_conversion_map_vector, point); |
31551 | 1609 |
1610 /* Check map varidity. */ | |
1611 if (!CONSP (map)) continue; | |
1612 map = XCDR (map); | |
1613 if (!VECTORP (map)) continue; | |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1614 size = ASIZE (map); |
31551 | 1615 if (size <= 1) continue; |
1616 | |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1617 content = AREF (map, 0); |
31551 | 1618 |
1619 /* check map type, | |
1620 [STARTPOINT VAL1 VAL2 ...] or | |
1621 [t ELEMENT STARTPOINT ENDPOINT] */ | |
1622 if (NUMBERP (content)) | |
1623 { | |
1624 point = XUINT (content); | |
1625 point = op - point + 1; | |
1626 if (!((point >= 1) && (point < size))) continue; | |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1627 content = AREF (map, point); |
31551 | 1628 } |
1629 else if (EQ (content, Qt)) | |
1630 { | |
1631 if (size != 4) continue; | |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1632 if ((op >= XUINT (AREF (map, 2))) && |
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1633 (op < XUINT (AREF (map, 3)))) |
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1634 content = AREF (map, 1); |
31551 | 1635 else |
1636 continue; | |
1637 } | |
1638 else | |
1639 continue; | |
1640 | |
1641 if (NILP (content)) | |
1642 continue; | |
1643 | |
1644 reg[RRR] = i; | |
1645 if (NUMBERP (content)) | |
1646 { | |
1647 op = XINT (content); | |
1648 i += map_set_rest_length - 1; | |
1649 ic += map_set_rest_length - 1; | |
1650 POP_MAPPING_STACK (map_set_rest_length, reg[rrr]); | |
1651 map_set_rest_length++; | |
1652 } | |
1653 else if (CONSP (content)) | |
1654 { | |
1655 attrib = XCAR (content); | |
1656 value = XCDR (content); | |
1657 if (!NUMBERP (attrib) || !NUMBERP (value)) | |
1658 continue; | |
1659 op = XUINT (value); | |
1660 i += map_set_rest_length - 1; | |
1661 ic += map_set_rest_length - 1; | |
1662 POP_MAPPING_STACK (map_set_rest_length, reg[rrr]); | |
1663 map_set_rest_length++; | |
1664 } | |
1665 else if (EQ (content, Qt)) | |
1666 { | |
1667 op = reg[rrr]; | |
1668 } | |
1669 else if (EQ (content, Qlambda)) | |
1670 { | |
1671 i += map_set_rest_length; | |
1672 ic += map_set_rest_length; | |
1673 break; | |
1674 } | |
1675 else if (SYMBOLP (content)) | |
1676 { | |
1677 if (mapping_stack_pointer | |
1678 >= &mapping_stack[MAX_MAP_SET_LEVEL]) | |
1679 CCL_INVALID_CMD; | |
1680 PUSH_MAPPING_STACK (map_set_rest_length, reg[rrr]); | |
1681 PUSH_MAPPING_STACK (map_set_rest_length, op); | |
1682 stack_idx_of_map_multiple = stack_idx + 1; | |
1683 CCL_CALL_FOR_MAP_INSTRUCTION (content, current_ic); | |
1684 } | |
1685 else | |
1686 CCL_INVALID_CMD; | |
1687 } | |
1688 if (mapping_stack_pointer <= (mapping_stack + 1)) | |
1689 break; | |
1690 POP_MAPPING_STACK (map_set_rest_length, reg[rrr]); | |
1691 i += map_set_rest_length; | |
1692 ic += map_set_rest_length; | |
1693 POP_MAPPING_STACK (map_set_rest_length, reg[rrr]); | |
1694 } while (1); | |
1695 | |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1696 ic = fin_ic; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1697 } |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1698 reg[rrr] = op; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1699 break; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1700 |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
1701 case CCL_MapSingle: |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1702 { |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
1703 Lisp_Object map, attrib, value, content; |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1704 int size, point; |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
1705 j = XINT (ccl_prog[ic++]); /* map_id */ |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1706 op = reg[rrr]; |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1707 if (j >= ASIZE (Vcode_conversion_map_vector)) |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1708 { |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1709 reg[RRR] = -1; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1710 break; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1711 } |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1712 map = AREF (Vcode_conversion_map_vector, j); |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
1713 if (!CONSP (map)) |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1714 { |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1715 reg[RRR] = -1; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1716 break; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1717 } |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25066
diff
changeset
|
1718 map = XCDR (map); |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
1719 if (!VECTORP (map)) |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1720 { |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1721 reg[RRR] = -1; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1722 break; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1723 } |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1724 size = ASIZE (map); |
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1725 point = XUINT (AREF (map, 0)); |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1726 point = op - point + 1; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1727 reg[RRR] = 0; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1728 if ((size <= 1) || |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1729 (!((point >= 1) && (point < size)))) |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1730 reg[RRR] = -1; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1731 else |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1732 { |
27877
fe0206a9f10c
(ccl_driver) [CCL_MapMultiple]: When the mapped value is
Kenichi Handa <handa@m17n.org>
parents:
27650
diff
changeset
|
1733 reg[RRR] = 0; |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1734 content = AREF (map, point); |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1735 if (NILP (content)) |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1736 reg[RRR] = -1; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1737 else if (NUMBERP (content)) |
21551 | 1738 reg[rrr] = XINT (content); |
27877
fe0206a9f10c
(ccl_driver) [CCL_MapMultiple]: When the mapped value is
Kenichi Handa <handa@m17n.org>
parents:
27650
diff
changeset
|
1739 else if (EQ (content, Qt)); |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1740 else if (CONSP (content)) |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1741 { |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25066
diff
changeset
|
1742 attrib = XCAR (content); |
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25066
diff
changeset
|
1743 value = XCDR (content); |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1744 if (!NUMBERP (attrib) || !NUMBERP (value)) |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1745 continue; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1746 reg[rrr] = XUINT(value); |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1747 break; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1748 } |
31551 | 1749 else if (SYMBOLP (content)) |
1750 CCL_CALL_FOR_MAP_INSTRUCTION (content, ic); | |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1751 else |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1752 reg[RRR] = -1; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1753 } |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1754 } |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1755 break; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1756 |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1757 default: |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1758 CCL_INVALID_CMD; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1759 } |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1760 break; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
1761 |
17052 | 1762 default: |
1763 CCL_INVALID_CMD; | |
1764 } | |
1765 } | |
1766 | |
1767 ccl_error_handler: | |
35535
0542807f1a5f
(ccl_driver): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
35529
diff
changeset
|
1768 /* The suppress_error member is set when e.g. a CCL-based coding |
0542807f1a5f
(ccl_driver): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
35529
diff
changeset
|
1769 system is used for terminal output. */ |
0542807f1a5f
(ccl_driver): Fix last change.
Eli Zaretskii <eliz@gnu.org>
parents:
35529
diff
changeset
|
1770 if (!ccl->suppress_error && destination) |
17052 | 1771 { |
1772 /* We can insert an error message only if DESTINATION is | |
1773 specified and we still have a room to store the message | |
1774 there. */ | |
1775 char msg[256]; | |
1776 int msglen; | |
1777 | |
23280
b4656367043f
(CCL_WRITE_CHAR): Don't use bcopy.
Kenichi Handa <handa@m17n.org>
parents:
23072
diff
changeset
|
1778 if (!dst) |
b4656367043f
(CCL_WRITE_CHAR): Don't use bcopy.
Kenichi Handa <handa@m17n.org>
parents:
23072
diff
changeset
|
1779 dst = destination; |
b4656367043f
(CCL_WRITE_CHAR): Don't use bcopy.
Kenichi Handa <handa@m17n.org>
parents:
23072
diff
changeset
|
1780 |
17052 | 1781 switch (ccl->status) |
1782 { | |
1783 case CCL_STAT_INVALID_CMD: | |
1784 sprintf(msg, "\nCCL: Invalid command %x (ccl_code = %x) at %d.", | |
23303
fb38954a02d3
(ccl_driver): Report correct CCL program counter on error.
Kenichi Handa <handa@m17n.org>
parents:
23280
diff
changeset
|
1785 code & 0x1F, code, this_ic); |
17052 | 1786 #ifdef CCL_DEBUG |
1787 { | |
1788 int i = ccl_backtrace_idx - 1; | |
1789 int j; | |
1790 | |
1791 msglen = strlen (msg); | |
23280
b4656367043f
(CCL_WRITE_CHAR): Don't use bcopy.
Kenichi Handa <handa@m17n.org>
parents:
23072
diff
changeset
|
1792 if (dst + msglen <= (dst_bytes ? dst_end : src)) |
17052 | 1793 { |
1794 bcopy (msg, dst, msglen); | |
1795 dst += msglen; | |
1796 } | |
1797 | |
1798 for (j = 0; j < CCL_DEBUG_BACKTRACE_LEN; j++, i--) | |
1799 { | |
1800 if (i < 0) i = CCL_DEBUG_BACKTRACE_LEN - 1; | |
1801 if (ccl_backtrace_table[i] == 0) | |
1802 break; | |
1803 sprintf(msg, " %d", ccl_backtrace_table[i]); | |
1804 msglen = strlen (msg); | |
23280
b4656367043f
(CCL_WRITE_CHAR): Don't use bcopy.
Kenichi Handa <handa@m17n.org>
parents:
23072
diff
changeset
|
1805 if (dst + msglen > (dst_bytes ? dst_end : src)) |
17052 | 1806 break; |
1807 bcopy (msg, dst, msglen); | |
1808 dst += msglen; | |
1809 } | |
23280
b4656367043f
(CCL_WRITE_CHAR): Don't use bcopy.
Kenichi Handa <handa@m17n.org>
parents:
23072
diff
changeset
|
1810 goto ccl_finish; |
17052 | 1811 } |
17323
15fa68d983e7
(ccl_driver): Fix bug of the case CCL_WriteArrayReadJump.
Kenichi Handa <handa@m17n.org>
parents:
17122
diff
changeset
|
1812 #endif |
23280
b4656367043f
(CCL_WRITE_CHAR): Don't use bcopy.
Kenichi Handa <handa@m17n.org>
parents:
23072
diff
changeset
|
1813 break; |
17052 | 1814 |
1815 case CCL_STAT_QUIT: | |
1816 sprintf(msg, "\nCCL: Quited."); | |
1817 break; | |
1818 | |
1819 default: | |
1820 sprintf(msg, "\nCCL: Unknown error type (%d).", ccl->status); | |
1821 } | |
1822 | |
1823 msglen = strlen (msg); | |
23280
b4656367043f
(CCL_WRITE_CHAR): Don't use bcopy.
Kenichi Handa <handa@m17n.org>
parents:
23072
diff
changeset
|
1824 if (dst + msglen <= (dst_bytes ? dst_end : src)) |
17052 | 1825 { |
1826 bcopy (msg, dst, msglen); | |
1827 dst += msglen; | |
1828 } | |
37734
3d05b438e278
(ccl_driver): Don't copy remaining bytes in case
Gerd Moellmann <gerd@gnu.org>
parents:
36565
diff
changeset
|
1829 |
35883
aedc87e25ce2
(CCL_WRITE_CHAR): Check if CH is valid or not. If
Kenichi Handa <handa@m17n.org>
parents:
35535
diff
changeset
|
1830 if (ccl->status == CCL_STAT_INVALID_CMD) |
aedc87e25ce2
(CCL_WRITE_CHAR): Check if CH is valid or not. If
Kenichi Handa <handa@m17n.org>
parents:
35535
diff
changeset
|
1831 { |
37734
3d05b438e278
(ccl_driver): Don't copy remaining bytes in case
Gerd Moellmann <gerd@gnu.org>
parents:
36565
diff
changeset
|
1832 #if 0 /* If the remaining bytes contain 0x80..0x9F, copying them |
3d05b438e278
(ccl_driver): Don't copy remaining bytes in case
Gerd Moellmann <gerd@gnu.org>
parents:
36565
diff
changeset
|
1833 results in an invalid multibyte sequence. */ |
3d05b438e278
(ccl_driver): Don't copy remaining bytes in case
Gerd Moellmann <gerd@gnu.org>
parents:
36565
diff
changeset
|
1834 |
35883
aedc87e25ce2
(CCL_WRITE_CHAR): Check if CH is valid or not. If
Kenichi Handa <handa@m17n.org>
parents:
35535
diff
changeset
|
1835 /* Copy the remaining source data. */ |
aedc87e25ce2
(CCL_WRITE_CHAR): Check if CH is valid or not. If
Kenichi Handa <handa@m17n.org>
parents:
35535
diff
changeset
|
1836 int i = src_end - src; |
aedc87e25ce2
(CCL_WRITE_CHAR): Check if CH is valid or not. If
Kenichi Handa <handa@m17n.org>
parents:
35535
diff
changeset
|
1837 if (dst_bytes && (dst_end - dst) < i) |
aedc87e25ce2
(CCL_WRITE_CHAR): Check if CH is valid or not. If
Kenichi Handa <handa@m17n.org>
parents:
35535
diff
changeset
|
1838 i = dst_end - dst; |
aedc87e25ce2
(CCL_WRITE_CHAR): Check if CH is valid or not. If
Kenichi Handa <handa@m17n.org>
parents:
35535
diff
changeset
|
1839 bcopy (src, dst, i); |
aedc87e25ce2
(CCL_WRITE_CHAR): Check if CH is valid or not. If
Kenichi Handa <handa@m17n.org>
parents:
35535
diff
changeset
|
1840 src += i; |
aedc87e25ce2
(CCL_WRITE_CHAR): Check if CH is valid or not. If
Kenichi Handa <handa@m17n.org>
parents:
35535
diff
changeset
|
1841 dst += i; |
37734
3d05b438e278
(ccl_driver): Don't copy remaining bytes in case
Gerd Moellmann <gerd@gnu.org>
parents:
36565
diff
changeset
|
1842 #else |
3d05b438e278
(ccl_driver): Don't copy remaining bytes in case
Gerd Moellmann <gerd@gnu.org>
parents:
36565
diff
changeset
|
1843 /* Signal that we've consumed everything. */ |
3d05b438e278
(ccl_driver): Don't copy remaining bytes in case
Gerd Moellmann <gerd@gnu.org>
parents:
36565
diff
changeset
|
1844 src = src_end; |
3d05b438e278
(ccl_driver): Don't copy remaining bytes in case
Gerd Moellmann <gerd@gnu.org>
parents:
36565
diff
changeset
|
1845 #endif |
35883
aedc87e25ce2
(CCL_WRITE_CHAR): Check if CH is valid or not. If
Kenichi Handa <handa@m17n.org>
parents:
35535
diff
changeset
|
1846 } |
17052 | 1847 } |
1848 | |
1849 ccl_finish: | |
1850 ccl->ic = ic; | |
24688
7b170d2184a4
(ccl_prog_stack_struct): Declare it as static.
Kenichi Handa <handa@m17n.org>
parents:
24567
diff
changeset
|
1851 ccl->stack_idx = stack_idx; |
7b170d2184a4
(ccl_prog_stack_struct): Declare it as static.
Kenichi Handa <handa@m17n.org>
parents:
24567
diff
changeset
|
1852 ccl->prog = ccl_prog; |
36411
120891909abe
(CCL_WRITE_MULTIBYTE_CHAR): New macro.
Kenichi Handa <handa@m17n.org>
parents:
36102
diff
changeset
|
1853 ccl->eight_bit_control = (extra_bytes > 0); |
37734
3d05b438e278
(ccl_driver): Don't copy remaining bytes in case
Gerd Moellmann <gerd@gnu.org>
parents:
36565
diff
changeset
|
1854 if (consumed) |
3d05b438e278
(ccl_driver): Don't copy remaining bytes in case
Gerd Moellmann <gerd@gnu.org>
parents:
36565
diff
changeset
|
1855 *consumed = src - source; |
23280
b4656367043f
(CCL_WRITE_CHAR): Don't use bcopy.
Kenichi Handa <handa@m17n.org>
parents:
23072
diff
changeset
|
1856 return (dst ? dst - destination : 0); |
17052 | 1857 } |
1858 | |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1859 /* Resolve symbols in the specified CCL code (Lisp vector). This |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1860 function converts symbols of code conversion maps and character |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1861 translation tables embeded in the CCL code into their ID numbers. |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1862 |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1863 The return value is a vector (CCL itself or a new vector in which |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1864 all symbols are resolved), Qt if resolving of some symbol failed, |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1865 or nil if CCL contains invalid data. */ |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1866 |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1867 static Lisp_Object |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1868 resolve_symbol_ccl_program (ccl) |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1869 Lisp_Object ccl; |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1870 { |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1871 int i, veclen, unresolved = 0; |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1872 Lisp_Object result, contents, val; |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1873 |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1874 result = ccl; |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1875 veclen = ASIZE (result); |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1876 |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1877 for (i = 0; i < veclen; i++) |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1878 { |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1879 contents = AREF (result, i); |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1880 if (INTEGERP (contents)) |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1881 continue; |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1882 else if (CONSP (contents) |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25066
diff
changeset
|
1883 && SYMBOLP (XCAR (contents)) |
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25066
diff
changeset
|
1884 && SYMBOLP (XCDR (contents))) |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1885 { |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1886 /* This is the new style for embedding symbols. The form is |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1887 (SYMBOL . PROPERTY). (get SYMBOL PROPERTY) should give |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1888 an index number. */ |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1889 |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1890 if (EQ (result, ccl)) |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1891 result = Fcopy_sequence (ccl); |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1892 |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25066
diff
changeset
|
1893 val = Fget (XCAR (contents), XCDR (contents)); |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1894 if (NATNUMP (val)) |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1895 AREF (result, i) = val; |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1896 else |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1897 unresolved = 1; |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1898 continue; |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1899 } |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1900 else if (SYMBOLP (contents)) |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1901 { |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1902 /* This is the old style for embedding symbols. This style |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1903 may lead to a bug if, for instance, a translation table |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1904 and a code conversion map have the same name. */ |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1905 if (EQ (result, ccl)) |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1906 result = Fcopy_sequence (ccl); |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1907 |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1908 val = Fget (contents, Qtranslation_table_id); |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1909 if (NATNUMP (val)) |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1910 AREF (result, i) = val; |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1911 else |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1912 { |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1913 val = Fget (contents, Qcode_conversion_map_id); |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1914 if (NATNUMP (val)) |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1915 AREF (result, i) = val; |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1916 else |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1917 { |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1918 val = Fget (contents, Qccl_program_idx); |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1919 if (NATNUMP (val)) |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1920 AREF (result, i) = val; |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1921 else |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1922 unresolved = 1; |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1923 } |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1924 } |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1925 continue; |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1926 } |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1927 return Qnil; |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1928 } |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1929 |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1930 return (unresolved ? Qt : result); |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1931 } |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1932 |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1933 /* Return the compiled code (vector) of CCL program CCL_PROG. |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1934 CCL_PROG is a name (symbol) of the program or already compiled |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1935 code. If necessary, resolve symbols in the compiled code to index |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1936 numbers. If we failed to get the compiled code or to resolve |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1937 symbols, return Qnil. */ |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1938 |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1939 static Lisp_Object |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1940 ccl_get_compiled_code (ccl_prog) |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1941 Lisp_Object ccl_prog; |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1942 { |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1943 Lisp_Object val, slot; |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1944 |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1945 if (VECTORP (ccl_prog)) |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1946 { |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1947 val = resolve_symbol_ccl_program (ccl_prog); |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1948 return (VECTORP (val) ? val : Qnil); |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1949 } |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1950 if (!SYMBOLP (ccl_prog)) |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1951 return Qnil; |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1952 |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1953 val = Fget (ccl_prog, Qccl_program_idx); |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1954 if (! NATNUMP (val) |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1955 || XINT (val) >= ASIZE (Vccl_program_table)) |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1956 return Qnil; |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1957 slot = AREF (Vccl_program_table, XINT (val)); |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1958 if (! VECTORP (slot) |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1959 || ASIZE (slot) != 3 |
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1960 || ! VECTORP (AREF (slot, 1))) |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1961 return Qnil; |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1962 if (NILP (AREF (slot, 2))) |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1963 { |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1964 val = resolve_symbol_ccl_program (AREF (slot, 1)); |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1965 if (! VECTORP (val)) |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1966 return Qnil; |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1967 AREF (slot, 1) = val; |
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1968 AREF (slot, 2) = Qt; |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1969 } |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
1970 return AREF (slot, 1); |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1971 } |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1972 |
17052 | 1973 /* Setup fields of the structure pointed by CCL appropriately for the |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1974 execution of CCL program CCL_PROG. CCL_PROG is the name (symbol) |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1975 of the CCL program or the already compiled code (vector). |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1976 Return 0 if we succeed this setup, else return -1. |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1977 |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1978 If CCL_PROG is nil, we just reset the structure pointed by CCL. */ |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1979 int |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1980 setup_ccl_program (ccl, ccl_prog) |
17052 | 1981 struct ccl_program *ccl; |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1982 Lisp_Object ccl_prog; |
17052 | 1983 { |
1984 int i; | |
1985 | |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1986 if (! NILP (ccl_prog)) |
23884
179bcb86f12f
(CCL_SUCCESS): Don't set ccl->ic.
Kenichi Handa <handa@m17n.org>
parents:
23768
diff
changeset
|
1987 { |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1988 struct Lisp_Vector *vp; |
23884
179bcb86f12f
(CCL_SUCCESS): Don't set ccl->ic.
Kenichi Handa <handa@m17n.org>
parents:
23768
diff
changeset
|
1989 |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1990 ccl_prog = ccl_get_compiled_code (ccl_prog); |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1991 if (! VECTORP (ccl_prog)) |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1992 return -1; |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
1993 vp = XVECTOR (ccl_prog); |
23884
179bcb86f12f
(CCL_SUCCESS): Don't set ccl->ic.
Kenichi Handa <handa@m17n.org>
parents:
23768
diff
changeset
|
1994 ccl->size = vp->size; |
179bcb86f12f
(CCL_SUCCESS): Don't set ccl->ic.
Kenichi Handa <handa@m17n.org>
parents:
23768
diff
changeset
|
1995 ccl->prog = vp->contents; |
179bcb86f12f
(CCL_SUCCESS): Don't set ccl->ic.
Kenichi Handa <handa@m17n.org>
parents:
23768
diff
changeset
|
1996 ccl->eof_ic = XINT (vp->contents[CCL_HEADER_EOF]); |
179bcb86f12f
(CCL_SUCCESS): Don't set ccl->ic.
Kenichi Handa <handa@m17n.org>
parents:
23768
diff
changeset
|
1997 ccl->buf_magnification = XINT (vp->contents[CCL_HEADER_BUF_MAG]); |
179bcb86f12f
(CCL_SUCCESS): Don't set ccl->ic.
Kenichi Handa <handa@m17n.org>
parents:
23768
diff
changeset
|
1998 } |
17052 | 1999 ccl->ic = CCL_HEADER_MAIN; |
2000 for (i = 0; i < 8; i++) | |
2001 ccl->reg[i] = 0; | |
2002 ccl->last_block = 0; | |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
2003 ccl->private_state = 0; |
17052 | 2004 ccl->status = 0; |
24688
7b170d2184a4
(ccl_prog_stack_struct): Declare it as static.
Kenichi Handa <handa@m17n.org>
parents:
24567
diff
changeset
|
2005 ccl->stack_idx = 0; |
29724
caf7f927357c
(CCL_WRITE_CHAR): Convert NL according to ccl->eol_type.
Kenichi Handa <handa@m17n.org>
parents:
29175
diff
changeset
|
2006 ccl->eol_type = CODING_EOL_LF; |
35529
c0bf5507a0bb
(ccl_driver): If ccl->suppress_error is nonzeor, don't
Kenichi Handa <handa@m17n.org>
parents:
35498
diff
changeset
|
2007 ccl->suppress_error = 0; |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2008 return 0; |
17052 | 2009 } |
2010 | |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2011 #ifdef emacs |
21551 | 2012 |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2013 DEFUN ("ccl-program-p", Fccl_program_p, Sccl_program_p, 1, 1, 0, |
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2014 doc: /* Return t if OBJECT is a CCL program name or a compiled CCL program code. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2015 See the documentation of `define-ccl-program' for the detail of CCL program. */) |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2016 (object) |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2017 Lisp_Object object; |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2018 { |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2019 Lisp_Object val; |
21551 | 2020 |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2021 if (VECTORP (object)) |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2022 { |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2023 val = resolve_symbol_ccl_program (object); |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2024 return (VECTORP (val) ? Qt : Qnil); |
21551 | 2025 } |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2026 if (!SYMBOLP (object)) |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2027 return Qnil; |
21551 | 2028 |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2029 val = Fget (object, Qccl_program_idx); |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2030 return ((! NATNUMP (val) |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
2031 || XINT (val) >= ASIZE (Vccl_program_table)) |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2032 ? Qnil : Qt); |
21551 | 2033 } |
2034 | |
17052 | 2035 DEFUN ("ccl-execute", Fccl_execute, Sccl_execute, 2, 2, 0, |
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2036 doc: /* Execute CCL-PROGRAM with registers initialized by REGISTERS. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2037 |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2038 CCL-PROGRAM is a CCL program name (symbol) |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2039 or compiled code generated by `ccl-compile' (for backward compatibility. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2040 In the latter case, the execution overhead is bigger than in the former). |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2041 No I/O commands should appear in CCL-PROGRAM. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2042 |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2043 REGISTERS is a vector of [R0 R1 ... R7] where RN is an initial value |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2044 for the Nth register. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2045 |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2046 As side effect, each element of REGISTERS holds the value of |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2047 the corresponding register after the execution. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2048 |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2049 See the documentation of `define-ccl-program' for a definition of CCL |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2050 programs. */) |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2051 (ccl_prog, reg) |
17052 | 2052 Lisp_Object ccl_prog, reg; |
2053 { | |
2054 struct ccl_program ccl; | |
2055 int i; | |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2056 |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2057 if (setup_ccl_program (&ccl, ccl_prog) < 0) |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2058 error ("Invalid CCL program"); |
17052 | 2059 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40103
diff
changeset
|
2060 CHECK_VECTOR (reg); |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
2061 if (ASIZE (reg) != 8) |
30105
d9e5b40d33c5
(Fccl_execute): Typo fixed.
Kenichi Handa <handa@m17n.org>
parents:
29847
diff
changeset
|
2062 error ("Length of vector REGISTERS is not 8"); |
21551 | 2063 |
17052 | 2064 for (i = 0; i < 8; i++) |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
2065 ccl.reg[i] = (INTEGERP (AREF (reg, i)) |
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
2066 ? XINT (AREF (reg, i)) |
17052 | 2067 : 0); |
2068 | |
34982
a16dc29a46c7
(Fccl_execute): Cast ccl_driver parameters to `unsigned
Eli Zaretskii <eliz@gnu.org>
parents:
34890
diff
changeset
|
2069 ccl_driver (&ccl, (unsigned char *)0, (unsigned char *)0, 0, 0, (int *)0); |
17052 | 2070 QUIT; |
2071 if (ccl.status != CCL_STAT_SUCCESS) | |
2072 error ("Error in CCL program at %dth code", ccl.ic); | |
2073 | |
2074 for (i = 0; i < 8; i++) | |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
2075 XSETINT (AREF (reg, i), ccl.reg[i]); |
17052 | 2076 return Qnil; |
2077 } | |
2078 | |
2079 DEFUN ("ccl-execute-on-string", Fccl_execute_on_string, Sccl_execute_on_string, | |
20934
eebcbb4b56bd
(Fccl_execute_on_string): Add new arg UNIBYTE-P.
Kenichi Handa <handa@m17n.org>
parents:
20722
diff
changeset
|
2080 3, 5, 0, |
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2081 doc: /* Execute CCL-PROGRAM with initial STATUS on STRING. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2082 |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2083 CCL-PROGRAM is a symbol registered by register-ccl-program, |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2084 or a compiled code generated by `ccl-compile' (for backward compatibility, |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2085 in this case, the execution is slower). |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2086 |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2087 Read buffer is set to STRING, and write buffer is allocated automatically. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2088 |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2089 STATUS is a vector of [R0 R1 ... R7 IC], where |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2090 R0..R7 are initial values of corresponding registers, |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2091 IC is the instruction counter specifying from where to start the program. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2092 If R0..R7 are nil, they are initialized to 0. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2093 If IC is nil, it is initialized to head of the CCL program. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2094 |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2095 If optional 4th arg CONTINUE is non-nil, keep IC on read operation |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2096 when read buffer is exausted, else, IC is always set to the end of |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2097 CCL-PROGRAM on exit. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2098 |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2099 It returns the contents of write buffer as a string, |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2100 and as side effect, STATUS is updated. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2101 If the optional 5th arg UNIBYTE-P is non-nil, the returned string |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2102 is a unibyte string. By default it is a multibyte string. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2103 |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2104 See the documentation of `define-ccl-program' for the detail of CCL program. */) |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2105 (ccl_prog, status, str, contin, unibyte_p) |
20934
eebcbb4b56bd
(Fccl_execute_on_string): Add new arg UNIBYTE-P.
Kenichi Handa <handa@m17n.org>
parents:
20722
diff
changeset
|
2106 Lisp_Object ccl_prog, status, str, contin, unibyte_p; |
17052 | 2107 { |
2108 Lisp_Object val; | |
2109 struct ccl_program ccl; | |
2110 int i, produced; | |
2111 int outbufsize; | |
2112 char *outbuf; | |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2113 struct gcpro gcpro1, gcpro2; |
17052 | 2114 |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2115 if (setup_ccl_program (&ccl, ccl_prog) < 0) |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2116 error ("Invalid CCL program"); |
21551 | 2117 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40103
diff
changeset
|
2118 CHECK_VECTOR (status); |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
2119 if (ASIZE (status) != 9) |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2120 error ("Length of vector STATUS is not 9"); |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40103
diff
changeset
|
2121 CHECK_STRING (str); |
17052 | 2122 |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2123 GCPRO2 (status, str); |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2124 |
17052 | 2125 for (i = 0; i < 8; i++) |
2126 { | |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
2127 if (NILP (AREF (status, i))) |
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
2128 XSETINT (AREF (status, i), 0); |
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
2129 if (INTEGERP (AREF (status, i))) |
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
2130 ccl.reg[i] = XINT (AREF (status, i)); |
17052 | 2131 } |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
2132 if (INTEGERP (AREF (status, i))) |
17052 | 2133 { |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
2134 i = XFASTINT (AREF (status, 8)); |
17052 | 2135 if (ccl.ic < i && i < ccl.size) |
2136 ccl.ic = i; | |
2137 } | |
21244
50929073a0ba
Use STRING_BYTES and SET_STRING_BYTES.
Richard M. Stallman <rms@gnu.org>
parents:
20945
diff
changeset
|
2138 outbufsize = STRING_BYTES (XSTRING (str)) * ccl.buf_magnification + 256; |
17052 | 2139 outbuf = (char *) xmalloc (outbufsize); |
17728
25d58ba29c1b
(Fccl_execute_on_string): Add 4th optional arg
Kenichi Handa <handa@m17n.org>
parents:
17370
diff
changeset
|
2140 ccl.last_block = NILP (contin); |
30754
4687d69de88a
(CCL_READ_CHAR): If source is multibyte, pay attention to
Kenichi Handa <handa@m17n.org>
parents:
30344
diff
changeset
|
2141 ccl.multibyte = STRING_MULTIBYTE (str); |
17052 | 2142 produced = ccl_driver (&ccl, XSTRING (str)->data, outbuf, |
31702
ef25c62becab
(Fccl_execute_on_string): Make multibyte string correctly.
Kenichi Handa <handa@m17n.org>
parents:
31551
diff
changeset
|
2143 STRING_BYTES (XSTRING (str)), outbufsize, (int *) 0); |
17052 | 2144 for (i = 0; i < 8; i++) |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
2145 XSET (AREF (status, i), Lisp_Int, ccl.reg[i]); |
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
2146 XSETINT (AREF (status, 8), ccl.ic); |
17052 | 2147 UNGCPRO; |
2148 | |
20934
eebcbb4b56bd
(Fccl_execute_on_string): Add new arg UNIBYTE-P.
Kenichi Handa <handa@m17n.org>
parents:
20722
diff
changeset
|
2149 if (NILP (unibyte_p)) |
31702
ef25c62becab
(Fccl_execute_on_string): Make multibyte string correctly.
Kenichi Handa <handa@m17n.org>
parents:
31551
diff
changeset
|
2150 { |
ef25c62becab
(Fccl_execute_on_string): Make multibyte string correctly.
Kenichi Handa <handa@m17n.org>
parents:
31551
diff
changeset
|
2151 int nchars; |
ef25c62becab
(Fccl_execute_on_string): Make multibyte string correctly.
Kenichi Handa <handa@m17n.org>
parents:
31551
diff
changeset
|
2152 |
ef25c62becab
(Fccl_execute_on_string): Make multibyte string correctly.
Kenichi Handa <handa@m17n.org>
parents:
31551
diff
changeset
|
2153 produced = str_as_multibyte (outbuf, outbufsize, produced, &nchars); |
ef25c62becab
(Fccl_execute_on_string): Make multibyte string correctly.
Kenichi Handa <handa@m17n.org>
parents:
31551
diff
changeset
|
2154 val = make_multibyte_string (outbuf, nchars, produced); |
ef25c62becab
(Fccl_execute_on_string): Make multibyte string correctly.
Kenichi Handa <handa@m17n.org>
parents:
31551
diff
changeset
|
2155 } |
20934
eebcbb4b56bd
(Fccl_execute_on_string): Add new arg UNIBYTE-P.
Kenichi Handa <handa@m17n.org>
parents:
20722
diff
changeset
|
2156 else |
eebcbb4b56bd
(Fccl_execute_on_string): Add new arg UNIBYTE-P.
Kenichi Handa <handa@m17n.org>
parents:
20722
diff
changeset
|
2157 val = make_unibyte_string (outbuf, produced); |
30344
9f2a382a22e3
(Fccl_execute_on_string): Don't check xmalloc return. Use xfree, not
Dave Love <fx@gnu.org>
parents:
30105
diff
changeset
|
2158 xfree (outbuf); |
17052 | 2159 QUIT; |
31702
ef25c62becab
(Fccl_execute_on_string): Make multibyte string correctly.
Kenichi Handa <handa@m17n.org>
parents:
31551
diff
changeset
|
2160 if (ccl.status == CCL_STAT_SUSPEND_BY_DST) |
ef25c62becab
(Fccl_execute_on_string): Make multibyte string correctly.
Kenichi Handa <handa@m17n.org>
parents:
31551
diff
changeset
|
2161 error ("Output buffer for the CCL programs overflow"); |
17052 | 2162 if (ccl.status != CCL_STAT_SUCCESS |
31702
ef25c62becab
(Fccl_execute_on_string): Make multibyte string correctly.
Kenichi Handa <handa@m17n.org>
parents:
31551
diff
changeset
|
2163 && ccl.status != CCL_STAT_SUSPEND_BY_SRC) |
17052 | 2164 error ("Error in CCL program at %dth code", ccl.ic); |
2165 | |
2166 return val; | |
2167 } | |
2168 | |
2169 DEFUN ("register-ccl-program", Fregister_ccl_program, Sregister_ccl_program, | |
2170 2, 2, 0, | |
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2171 doc: /* Register CCL program CCL_PROG as NAME in `ccl-program-table'. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2172 CCL_PROG should be a compiled CCL program (vector), or nil. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2173 If it is nil, just reserve NAME as a CCL program name. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2174 Return index number of the registered CCL program. */) |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2175 (name, ccl_prog) |
17052 | 2176 Lisp_Object name, ccl_prog; |
2177 { | |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
2178 int len = ASIZE (Vccl_program_table); |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2179 int idx; |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2180 Lisp_Object resolved; |
17052 | 2181 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40103
diff
changeset
|
2182 CHECK_SYMBOL (name); |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2183 resolved = Qnil; |
17052 | 2184 if (!NILP (ccl_prog)) |
21551 | 2185 { |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40103
diff
changeset
|
2186 CHECK_VECTOR (ccl_prog); |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2187 resolved = resolve_symbol_ccl_program (ccl_prog); |
35322
ac015053a9a1
(Fregister_ccl_program): Handle the return value of
Kenichi Handa <handa@m17n.org>
parents:
34982
diff
changeset
|
2188 if (NILP (resolved)) |
ac015053a9a1
(Fregister_ccl_program): Handle the return value of
Kenichi Handa <handa@m17n.org>
parents:
34982
diff
changeset
|
2189 error ("Error in CCL program"); |
ac015053a9a1
(Fregister_ccl_program): Handle the return value of
Kenichi Handa <handa@m17n.org>
parents:
34982
diff
changeset
|
2190 if (VECTORP (resolved)) |
17052 | 2191 { |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2192 ccl_prog = resolved; |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2193 resolved = Qt; |
17052 | 2194 } |
35322
ac015053a9a1
(Fregister_ccl_program): Handle the return value of
Kenichi Handa <handa@m17n.org>
parents:
34982
diff
changeset
|
2195 else |
ac015053a9a1
(Fregister_ccl_program): Handle the return value of
Kenichi Handa <handa@m17n.org>
parents:
34982
diff
changeset
|
2196 resolved = Qnil; |
17052 | 2197 } |
2198 | |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2199 for (idx = 0; idx < len; idx++) |
17052 | 2200 { |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2201 Lisp_Object slot; |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2202 |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
2203 slot = AREF (Vccl_program_table, idx); |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2204 if (!VECTORP (slot)) |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2205 /* This is the first unsed slot. Register NAME here. */ |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2206 break; |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2207 |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
2208 if (EQ (name, AREF (slot, 0))) |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2209 { |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2210 /* Update this slot. */ |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
2211 AREF (slot, 1) = ccl_prog; |
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
2212 AREF (slot, 2) = resolved; |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2213 return make_number (idx); |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2214 } |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2215 } |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2216 |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2217 if (idx == len) |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2218 { |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2219 /* Extend the table. */ |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2220 Lisp_Object new_table; |
17052 | 2221 int j; |
2222 | |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2223 new_table = Fmake_vector (make_number (len * 2), Qnil); |
17052 | 2224 for (j = 0; j < len; j++) |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
2225 AREF (new_table, j) |
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
2226 = AREF (Vccl_program_table, j); |
17052 | 2227 Vccl_program_table = new_table; |
2228 } | |
2229 | |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2230 { |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2231 Lisp_Object elt; |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2232 |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2233 elt = Fmake_vector (make_number (3), Qnil); |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
2234 AREF (elt, 0) = name; |
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
2235 AREF (elt, 1) = ccl_prog; |
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
2236 AREF (elt, 2) = resolved; |
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
2237 AREF (Vccl_program_table, idx) = elt; |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2238 } |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2239 |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2240 Fput (name, Qccl_program_idx, make_number (idx)); |
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2241 return make_number (idx); |
17052 | 2242 } |
2243 | |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
2244 /* Register code conversion map. |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
2245 A code conversion map consists of numbers, Qt, Qnil, and Qlambda. |
36467 | 2246 The first element is the start code point. |
2247 The other elements are mapped numbers. | |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
2248 Symbol t means to map to an original number before mapping. |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
2249 Symbol nil means that the corresponding element is empty. |
36467 | 2250 Symbol lambda means to terminate mapping here. |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
2251 */ |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
2252 |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
2253 DEFUN ("register-code-conversion-map", Fregister_code_conversion_map, |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
2254 Sregister_code_conversion_map, |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
2255 2, 2, 0, |
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2256 doc: /* Register SYMBOL as code conversion map MAP. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2257 Return index number of the registered map. */) |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2258 (symbol, map) |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
2259 Lisp_Object symbol, map; |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
2260 { |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
2261 int len = ASIZE (Vcode_conversion_map_vector); |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
2262 int i; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
2263 Lisp_Object index; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
2264 |
40656
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40103
diff
changeset
|
2265 CHECK_SYMBOL (symbol); |
cdfd4d09b79a
Update usage of CHECK_ macros (remove unused second argument).
Pavel Janík <Pavel@Janik.cz>
parents:
40103
diff
changeset
|
2266 CHECK_VECTOR (map); |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
2267 |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
2268 for (i = 0; i < len; i++) |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
2269 { |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
2270 Lisp_Object slot = AREF (Vcode_conversion_map_vector, i); |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
2271 |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
2272 if (!CONSP (slot)) |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
2273 break; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
2274 |
25662
0a7261c1d487
Use XCAR, XCDR, and XFLOAT_DATA instead of explicit member access.
Ken Raeburn <raeburn@raeburn.org>
parents:
25066
diff
changeset
|
2275 if (EQ (symbol, XCAR (slot))) |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
2276 { |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
2277 index = make_number (i); |
39973
579177964efa
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
Ken Raeburn <raeburn@raeburn.org>
parents:
37765
diff
changeset
|
2278 XSETCDR (slot, map); |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
2279 Fput (symbol, Qcode_conversion_map, map); |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
2280 Fput (symbol, Qcode_conversion_map_id, index); |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
2281 return index; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
2282 } |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
2283 } |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
2284 |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
2285 if (i == len) |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
2286 { |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
2287 Lisp_Object new_vector = Fmake_vector (make_number (len * 2), Qnil); |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
2288 int j; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
2289 |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
2290 for (j = 0; j < len; j++) |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
2291 AREF (new_vector, j) |
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
2292 = AREF (Vcode_conversion_map_vector, j); |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
2293 Vcode_conversion_map_vector = new_vector; |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
2294 } |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
2295 |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
2296 index = make_number (i); |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
2297 Fput (symbol, Qcode_conversion_map, map); |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
2298 Fput (symbol, Qcode_conversion_map_id, index); |
41622
2c3898d7bbef
Use AREF and ASIZE.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
40940
diff
changeset
|
2299 AREF (Vcode_conversion_map_vector, i) = Fcons (symbol, map); |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
2300 return index; |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
2301 } |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
2302 |
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
2303 |
21514 | 2304 void |
17052 | 2305 syms_of_ccl () |
2306 { | |
2307 staticpro (&Vccl_program_table); | |
18749
d961aeafceba
(Fregister_ccl_program): Convert Fmake_vector argument to Lisp_Integer.
Richard M. Stallman <rms@gnu.org>
parents:
18613
diff
changeset
|
2308 Vccl_program_table = Fmake_vector (make_number (32), Qnil); |
17052 | 2309 |
21551 | 2310 Qccl_program = intern ("ccl-program"); |
2311 staticpro (&Qccl_program); | |
2312 | |
2313 Qccl_program_idx = intern ("ccl-program-idx"); | |
2314 staticpro (&Qccl_program_idx); | |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
2315 |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
2316 Qcode_conversion_map = intern ("code-conversion-map"); |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
2317 staticpro (&Qcode_conversion_map); |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
2318 |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
2319 Qcode_conversion_map_id = intern ("code-conversion-map-id"); |
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
2320 staticpro (&Qcode_conversion_map_id); |
21551 | 2321 |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
2322 DEFVAR_LISP ("code-conversion-map-vector", &Vcode_conversion_map_vector, |
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2323 doc: /* Vector of code conversion maps. */); |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
2324 Vcode_conversion_map_vector = Fmake_vector (make_number (16), Qnil); |
20722
cce3ef478c64
(Vccl_translation_table_vector, Qccl_program,
Kenichi Handa <handa@m17n.org>
parents:
20613
diff
changeset
|
2325 |
17052 | 2326 DEFVAR_LISP ("font-ccl-encoder-alist", &Vfont_ccl_encoder_alist, |
40103
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2327 doc: /* Alist of fontname patterns vs corresponding CCL program. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2328 Each element looks like (REGEXP . CCL-CODE), |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2329 where CCL-CODE is a compiled CCL program. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2330 When a font whose name matches REGEXP is used for displaying a character, |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2331 CCL-CODE is executed to calculate the code point in the font |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2332 from the charset number and position code(s) of the character which are set |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2333 in CCL registers R0, R1, and R2 before the execution. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2334 The code point in the font is set in CCL registers R1 and R2 |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2335 when the execution terminated. |
6b389fb978bc
Change doc-string comments to `new style' [w/`doc:' keyword].
Pavel Janík <Pavel@Janik.cz>
parents:
39973
diff
changeset
|
2336 If the font is single-byte font, the register R2 is not used. */); |
17052 | 2337 Vfont_ccl_encoder_alist = Qnil; |
2338 | |
25066
8b8e54912f5c
(ccl_driver) <CCL_Call>: Now CCL program ID to call may be
Kenichi Handa <handa@m17n.org>
parents:
24688
diff
changeset
|
2339 defsubr (&Sccl_program_p); |
17052 | 2340 defsubr (&Sccl_execute); |
2341 defsubr (&Sccl_execute_on_string); | |
2342 defsubr (&Sregister_ccl_program); | |
22122
dfae9bc3731d
Change term translation to code conversion, then change
Kenichi Handa <handa@m17n.org>
parents:
21665
diff
changeset
|
2343 defsubr (&Sregister_code_conversion_map); |
17052 | 2344 } |
2345 | |
2346 #endif /* emacs */ |