diff options
| author | Kenichi Handa | 1998-05-18 00:59:38 +0000 |
|---|---|---|
| committer | Kenichi Handa | 1998-05-18 00:59:38 +0000 |
| commit | 8146262a46cd8fd2c971eac30301a9a7d32903ab (patch) | |
| tree | 01b20d35598366a74932a7180d976603c4fd6b14 /src | |
| parent | b4e9dd77cc1a9627f5cb8a8057f27ad960b039e9 (diff) | |
| download | emacs-8146262a46cd8fd2c971eac30301a9a7d32903ab.tar.gz emacs-8146262a46cd8fd2c971eac30301a9a7d32903ab.zip | |
Change term translation to code conversion, then change
terms unify/unification to translate/translation respectively
throughtout the file.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ccl.c | 405 |
1 files changed, 197 insertions, 208 deletions
| @@ -40,8 +40,8 @@ Boston, MA 02111-1307, USA. */ | |||
| 40 | 40 | ||
| 41 | #endif /* not emacs */ | 41 | #endif /* not emacs */ |
| 42 | 42 | ||
| 43 | /* Where is stored translation tables for CCL program. */ | 43 | /* This contains all code conversion map avairable to CCL. */ |
| 44 | Lisp_Object Vccl_translation_table_vector; | 44 | Lisp_Object Vcode_conversion_map_vector; |
| 45 | 45 | ||
| 46 | /* Alist of fontname patterns vs corresponding CCL program. */ | 46 | /* Alist of fontname patterns vs corresponding CCL program. */ |
| 47 | Lisp_Object Vfont_ccl_encoder_alist; | 47 | Lisp_Object Vfont_ccl_encoder_alist; |
| @@ -50,20 +50,15 @@ Lisp_Object Vfont_ccl_encoder_alist; | |||
| 50 | Ex: (get 'ccl-big5-encoder 'ccl-program) returns ccl program vector. */ | 50 | Ex: (get 'ccl-big5-encoder 'ccl-program) returns ccl program vector. */ |
| 51 | Lisp_Object Qccl_program; | 51 | Lisp_Object Qccl_program; |
| 52 | 52 | ||
| 53 | /* These symbols are properties which associate with ccl translation | 53 | /* These symbols are properties which associate with code conversion |
| 54 | tables and their ID respectively. */ | 54 | map and their ID respectively. */ |
| 55 | Lisp_Object Qccl_translation_table; | 55 | Lisp_Object Qcode_conversion_map; |
| 56 | Lisp_Object Qccl_translation_table_id; | 56 | Lisp_Object Qcode_conversion_map_id; |
| 57 | 57 | ||
| 58 | /* Symbols of ccl program have this property, a value of the property | 58 | /* Symbols of ccl program have this property, a value of the property |
| 59 | is an index for Vccl_protram_table. */ | 59 | is an index for Vccl_protram_table. */ |
| 60 | Lisp_Object Qccl_program_idx; | 60 | Lisp_Object Qccl_program_idx; |
| 61 | 61 | ||
| 62 | /* These symbols are properties which associate with character | ||
| 63 | unification tables and their ID respectively. */ | ||
| 64 | Lisp_Object Qunification_table; | ||
| 65 | Lisp_Object Qunification_table_id; | ||
| 66 | |||
| 67 | /* Vector of CCL program names vs corresponding program data. */ | 62 | /* Vector of CCL program names vs corresponding program data. */ |
| 68 | Lisp_Object Vccl_program_table; | 63 | Lisp_Object Vccl_program_table; |
| 69 | 64 | ||
| @@ -446,126 +441,128 @@ Lisp_Object Vccl_program_table; | |||
| 446 | #define CCL_WriteMultibyteChar2 0x01 /* Write Multibyte Character | 441 | #define CCL_WriteMultibyteChar2 0x01 /* Write Multibyte Character |
| 447 | 1:ExtendedCOMMNDRrrRRRrrrXXXXX */ | 442 | 1:ExtendedCOMMNDRrrRRRrrrXXXXX */ |
| 448 | 443 | ||
| 449 | /* Unify a character whose code point is reg[rrr] the charset ID is | 444 | /* Translate a character whose code point is reg[rrr] and the charset |
| 450 | reg[RRR] with a unification table whose ID is reg[Rrr]. | 445 | ID is reg[RRR] by a character translation table whose ID is |
| 446 | reg[Rrr]. | ||
| 451 | 447 | ||
| 452 | A unified character is set in reg[rrr] (code point) and reg[RRR] | 448 | A translated character is set in reg[rrr] (code point) and reg[RRR] |
| 453 | (charset ID). */ | 449 | (charset ID). */ |
| 454 | 450 | ||
| 455 | #define CCL_UnifyCharacter 0x02 /* Unify Multibyte Character | 451 | #define CCL_TranslateCharacter 0x02 /* Translate a multibyte character |
| 456 | 1:ExtendedCOMMNDRrrRRRrrrXXXXX */ | 452 | 1:ExtendedCOMMNDRrrRRRrrrXXXXX */ |
| 457 | 453 | ||
| 458 | /* Unify a character whose code point is reg[rrr] and the charset ID | 454 | /* Translate a character whose code point is reg[rrr] and the charset |
| 459 | is reg[RRR] with a unification table whose ID is ARGUMENT. | 455 | ID is reg[RRR] by a character translation table whose ID is |
| 456 | ARGUMENT. | ||
| 460 | 457 | ||
| 461 | A unified character is set in reg[rrr] (code point) and reg[RRR] | 458 | A translated character is set in reg[rrr] (code point) and reg[RRR] |
| 462 | (charset ID). */ | 459 | (charset ID). */ |
| 463 | 460 | ||
| 464 | #define CCL_UnifyCharacterConstTbl 0x03 /* Unify Multibyte Character | 461 | #define CCL_TranslateCharacterConstTbl 0x03 /* Translate a multibyte character |
| 465 | 1:ExtendedCOMMNDRrrRRRrrrXXXXX | 462 | 1:ExtendedCOMMNDRrrRRRrrrXXXXX |
| 466 | 2:ARGUMENT(Unification Table ID) | 463 | 2:ARGUMENT(Translation Table ID) |
| 467 | */ | 464 | */ |
| 468 | 465 | ||
| 469 | /* Iterate looking up TABLEs for reg[rrr] starting from the Nth (N = | 466 | /* Iterate looking up MAPs for reg[rrr] starting from the Nth (N = |
| 470 | reg[RRR]) TABLE until some value is found. | 467 | reg[RRR]) MAP until some value is found. |
| 471 | 468 | ||
| 472 | Each TABLE is a Lisp vector whose element is number, nil, t, or | 469 | Each MAP is a Lisp vector whose element is number, nil, t, or |
| 473 | lambda. | 470 | lambda. |
| 474 | If the element is nil, ignore the table and proceed to the next table. | 471 | If the element is nil, ignore the map and proceed to the next map. |
| 475 | If the element is t or lambda, finish without changing reg[rrr]. | 472 | If the element is t or lambda, finish without changing reg[rrr]. |
| 476 | If the element is a number, set reg[rrr] to the number and finish. | 473 | If the element is a number, set reg[rrr] to the number and finish. |
| 477 | 474 | ||
| 478 | Detail of the table structure is descibed in the comment for | 475 | Detail of the map structure is descibed in the comment for |
| 479 | CCL_TranslateMultipleMap below. */ | 476 | CCL_MapMultiple below. */ |
| 480 | 477 | ||
| 481 | #define CCL_IterateMultipleMap 0x10 /* Iterate Multiple Map | 478 | #define CCL_IterateMultipleMap 0x10 /* Iterate multiple maps |
| 482 | 1:ExtendedCOMMNDXXXRRRrrrXXXXX | 479 | 1:ExtendedCOMMNDXXXRRRrrrXXXXX |
| 483 | 2:NUMBER of TABLEs | 480 | 2:NUMBER of MAPs |
| 484 | 3:TABLE-ID1 | 481 | 3:MAP-ID1 |
| 485 | 4:TABLE-ID2 | 482 | 4:MAP-ID2 |
| 486 | ... | 483 | ... |
| 487 | */ | 484 | */ |
| 488 | 485 | ||
| 489 | /* Translate code point reg[rrr] by TABLEs starting from the Nth (N = | 486 | /* Map the code in reg[rrr] by MAPs starting from the Nth (N = |
| 490 | reg[RRR]) table. | 487 | reg[RRR]) map. |
| 491 | 488 | ||
| 492 | TABLEs are suppried in the succeeding CCL codes as follows: | 489 | MAPs are suppried in the succeeding CCL codes as follows: |
| 493 | 490 | ||
| 494 | When CCL program gives this nested structure of table to this command: | 491 | When CCL program gives this nested structure of map to this command: |
| 495 | ((TABLE-ID11 | 492 | ((MAP-ID11 |
| 496 | TABLE-ID12 | 493 | MAP-ID12 |
| 497 | (TABLE-ID121 TABLE-ID122 TABLE-ID123) | 494 | (MAP-ID121 MAP-ID122 MAP-ID123) |
| 498 | TABLE-ID13) | 495 | MAP-ID13) |
| 499 | (TABLE-ID21 | 496 | (MAP-ID21 |
| 500 | (TABLE-ID211 (TABLE-ID2111) TABLE-ID212) | 497 | (MAP-ID211 (MAP-ID2111) MAP-ID212) |
| 501 | TABLE-ID22)), | 498 | MAP-ID22)), |
| 502 | the compiled CCL codes has this sequence: | 499 | the compiled CCL codes has this sequence: |
| 503 | CCL_TranslateMultipleMap (CCL code of this command) | 500 | CCL_MapMultiple (CCL code of this command) |
| 504 | 16 (total number of TABLEs and SEPARATERs) | 501 | 16 (total number of MAPs and SEPARATERs) |
| 505 | -7 (1st SEPARATER) | 502 | -7 (1st SEPARATER) |
| 506 | TABLE-ID11 | 503 | MAP-ID11 |
| 507 | TABLE-ID12 | 504 | MAP-ID12 |
| 508 | -3 (2nd SEPARATER) | 505 | -3 (2nd SEPARATER) |
| 509 | TABLE-ID121 | 506 | MAP-ID121 |
| 510 | TABLE-ID122 | 507 | MAP-ID122 |
| 511 | TABLE-ID123 | 508 | MAP-ID123 |
| 512 | TABLE-ID13 | 509 | MAP-ID13 |
| 513 | -7 (3rd SEPARATER) | 510 | -7 (3rd SEPARATER) |
| 514 | TABLE-ID21 | 511 | MAP-ID21 |
| 515 | -4 (4th SEPARATER) | 512 | -4 (4th SEPARATER) |
| 516 | TABLE-ID211 | 513 | MAP-ID211 |
| 517 | -1 (5th SEPARATER) | 514 | -1 (5th SEPARATER) |
| 518 | TABLE_ID2111 | 515 | MAP_ID2111 |
| 519 | TABLE-ID212 | 516 | MAP-ID212 |
| 520 | TABLE-ID22 | 517 | MAP-ID22 |
| 521 | 518 | ||
| 522 | A value of each SEPARATER follows this rule: | 519 | A value of each SEPARATER follows this rule: |
| 523 | TABLE-SET := SEPARATOR [(TABLE-ID | TABLE-SET)]+ | 520 | MAP-SET := SEPARATOR [(MAP-ID | MAP-SET)]+ |
| 524 | SEPARATOR := -(number of TABLE-IDs and SEPARATORs in the TABLE-SET) | 521 | SEPARATOR := -(number of MAP-IDs and SEPARATORs in the MAP-SET) |
| 525 | 522 | ||
| 526 | (*)....Nest level of TABLE-SET must not be over than MAX_TABLE_SET_LEVEL. | 523 | (*)....Nest level of MAP-SET must not be over than MAX_MAP_SET_LEVEL. |
| 527 | 524 | ||
| 528 | When some table fails to translate (i.e. it doesn't have a value | 525 | When some map fails to map (i.e. it doesn't have a value for |
| 529 | for reg[rrr]), the translation is treated as identity. | 526 | reg[rrr]), the mapping is treated as identity. |
| 530 | 527 | ||
| 531 | The translation is iterated for all tables in each table set (set | 528 | The mapping is iterated for all maps in each map set (set of maps |
| 532 | of tables separators by a SEPARATOR) except the case that lambda is | 529 | separators by a SEPARATOR) except the case that lambda is |
| 533 | encountered (see below). | 530 | encountered (see below). |
| 534 | 531 | ||
| 535 | Each table is a Lisp vector of the following format (a) or (b): | 532 | Each map is a Lisp vector of the following format (a) or (b): |
| 536 | (a)......[STARTPOINT VAL1 VAL2 ...] | 533 | (a)......[STARTPOINT VAL1 VAL2 ...] |
| 537 | (b)......[t VAL STARTPOINT ENDPOINT], | 534 | (b)......[t VAL STARTPOINT ENDPOINT], |
| 538 | where | 535 | where |
| 539 | STARTPOINT is an offset to be used for indexing a table, | 536 | STARTPOINT is an offset to be used for indexing a map, |
| 540 | ENDPOINT is a maxmum index number of a table, | 537 | ENDPOINT is a maxmum index number of a map, |
| 541 | VAL and VALn is a number, nil, t, or lambda. | 538 | VAL and VALn is a number, nil, t, or lambda. |
| 542 | 539 | ||
| 543 | Valid index range of a table of type (a) is: | 540 | Valid index range of a map of type (a) is: |
| 544 | STARTPOINT <= index < STARTPOINT + table_size - 1 | 541 | STARTPOINT <= index < STARTPOINT + map_size - 1 |
| 545 | Valid index range of a table of type (b) is: | 542 | Valid index range of a map of type (b) is: |
| 546 | STARTPOINT <= index < ENDPOINT | 543 | STARTPOINT <= index < ENDPOINT |
| 547 | 544 | ||
| 548 | If VALn is nil, the table is ignored and translation proceed to the | 545 | If VALn is nil, the map is ignored and mapping proceed to the next |
| 549 | next table. | 546 | map. |
| 550 | In VALn is t, reg[rrr] is reverted to the original value and | 547 | In VALn is t, reg[rrr] is reverted to the original value and |
| 551 | translation proceed to the next table. | 548 | mapping proceed to the next map. |
| 552 | If VALn is lambda, translation in the current TABLE-SET finishes | 549 | If VALn is lambda, mapping in the current MAP-SET finishes |
| 553 | and proceed to the upper level TABLE-SET. */ | 550 | and proceed to the upper level MAP-SET. */ |
| 554 | 551 | ||
| 555 | #define CCL_TranslateMultipleMap 0x11 /* Translate Multiple Map | 552 | #define CCL_MapMultiple 0x11 /* Mapping by multiple code conversion maps |
| 556 | 1:ExtendedCOMMNDXXXRRRrrrXXXXX | 553 | 1:ExtendedCOMMNDXXXRRRrrrXXXXX |
| 557 | 2:N-2 | 554 | 2:N-2 |
| 558 | 3:SEPARATOR_1 (< 0) | 555 | 3:SEPARATOR_1 (< 0) |
| 559 | 4:TABLE-ID_1 | 556 | 4:MAP-ID_1 |
| 560 | 5:TABLE-ID_2 | 557 | 5:MAP-ID_2 |
| 561 | ... | 558 | ... |
| 562 | M:SEPARATOR_x (< 0) | 559 | M:SEPARATOR_x (< 0) |
| 563 | M+1:TABLE-ID_y | 560 | M+1:MAP-ID_y |
| 564 | ... | 561 | ... |
| 565 | N:SEPARATOR_z (< 0) | 562 | N:SEPARATOR_z (< 0) |
| 566 | */ | 563 | */ |
| 567 | 564 | ||
| 568 | #define MAX_TABLE_SET_LEVEL 20 | 565 | #define MAX_MAP_SET_LEVEL 20 |
| 569 | 566 | ||
| 570 | typedef struct | 567 | typedef struct |
| 571 | { | 568 | { |
| @@ -573,29 +570,29 @@ typedef struct | |||
| 573 | int orig_val; | 570 | int orig_val; |
| 574 | } tr_stack; | 571 | } tr_stack; |
| 575 | 572 | ||
| 576 | static tr_stack translate_stack[MAX_TABLE_SET_LEVEL]; | 573 | static tr_stack mapping_stack[MAX_MAP_SET_LEVEL]; |
| 577 | static tr_stack *translate_stack_pointer; | 574 | static tr_stack *mapping_stack_pointer; |
| 578 | 575 | ||
| 579 | #define PUSH_TRANSLATE_STACK(restlen, orig) \ | 576 | #define PUSH_MAPPING_STACK(restlen, orig) \ |
| 580 | { \ | 577 | { \ |
| 581 | translate_stack_pointer->rest_length = (restlen); \ | 578 | mapping_stack_pointer->rest_length = (restlen); \ |
| 582 | translate_stack_pointer->orig_val = (orig); \ | 579 | mapping_stack_pointer->orig_val = (orig); \ |
| 583 | translate_stack_pointer++; \ | 580 | mapping_stack_pointer++; \ |
| 584 | } | 581 | } |
| 585 | 582 | ||
| 586 | #define POP_TRANSLATE_STACK(restlen, orig) \ | 583 | #define POP_MAPPING_STACK(restlen, orig) \ |
| 587 | { \ | 584 | { \ |
| 588 | translate_stack_pointer--; \ | 585 | mapping_stack_pointer--; \ |
| 589 | (restlen) = translate_stack_pointer->rest_length; \ | 586 | (restlen) = mapping_stack_pointer->rest_length; \ |
| 590 | (orig) = translate_stack_pointer->orig_val; \ | 587 | (orig) = mapping_stack_pointer->orig_val; \ |
| 591 | } \ | 588 | } \ |
| 592 | 589 | ||
| 593 | #define CCL_TranslateSingleMap 0x12 /* Translate Single Map | 590 | #define CCL_MapSingle 0x12 /* Map by single code conversion map |
| 594 | 1:ExtendedCOMMNDXXXRRRrrrXXXXX | 591 | 1:ExtendedCOMMNDXXXRRRrrrXXXXX |
| 595 | 2:TABLE-ID | 592 | 2:MAP-ID |
| 596 | ------------------------------ | 593 | ------------------------------ |
| 597 | Translate reg[rrr] by TABLE-ID. | 594 | Map reg[rrr] by MAP-ID. |
| 598 | If some valid translation is found, | 595 | If some valid mapping is found, |
| 599 | set reg[rrr] to the result, | 596 | set reg[rrr] to the result, |
| 600 | else | 597 | else |
| 601 | set reg[RRR] to -1. | 598 | set reg[RRR] to -1. |
| @@ -1205,7 +1202,7 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed) | |||
| 1205 | 1202 | ||
| 1206 | break; | 1203 | break; |
| 1207 | 1204 | ||
| 1208 | case CCL_UnifyCharacter: | 1205 | case CCL_TranslateCharacter: |
| 1209 | i = reg[RRR]; /* charset */ | 1206 | i = reg[RRR]; /* charset */ |
| 1210 | if (i == CHARSET_ASCII) | 1207 | if (i == CHARSET_ASCII) |
| 1211 | i = reg[rrr] & 0x7F; | 1208 | i = reg[rrr] & 0x7F; |
| @@ -1221,7 +1218,8 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed) | |||
| 1221 | else | 1218 | else |
| 1222 | i = ((i - 0xE0) << 14) | (reg[rrr] & 0x3FFF); | 1219 | i = ((i - 0xE0) << 14) | (reg[rrr] & 0x3FFF); |
| 1223 | 1220 | ||
| 1224 | op = unify_char (UNIFICATION_ID_TABLE (reg[Rrr]), i, -1, 0, 0); | 1221 | op = translate_char (GET_TRANSLATION_TABLE (reg[Rrr]), |
| 1222 | i, -1, 0, 0); | ||
| 1225 | SPLIT_CHAR (op, reg[RRR], i, j); | 1223 | SPLIT_CHAR (op, reg[RRR], i, j); |
| 1226 | if (j != -1) | 1224 | if (j != -1) |
| 1227 | i = (i << 7) | j; | 1225 | i = (i << 7) | j; |
| @@ -1229,7 +1227,7 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed) | |||
| 1229 | reg[rrr] = i; | 1227 | reg[rrr] = i; |
| 1230 | break; | 1228 | break; |
| 1231 | 1229 | ||
| 1232 | case CCL_UnifyCharacterConstTbl: | 1230 | case CCL_TranslateCharacterConstTbl: |
| 1233 | op = XINT (ccl_prog[ic]); /* table */ | 1231 | op = XINT (ccl_prog[ic]); /* table */ |
| 1234 | ic++; | 1232 | ic++; |
| 1235 | i = reg[RRR]; /* charset */ | 1233 | i = reg[RRR]; /* charset */ |
| @@ -1247,7 +1245,7 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed) | |||
| 1247 | else | 1245 | else |
| 1248 | i = ((i - 0xE0) << 14) | (reg[rrr] & 0x3FFF); | 1246 | i = ((i - 0xE0) << 14) | (reg[rrr] & 0x3FFF); |
| 1249 | 1247 | ||
| 1250 | op = unify_char (UNIFICATION_ID_TABLE (op), i, -1, 0, 0); | 1248 | op = translate_char (GET_TRANSLATION_TABLE (op), i, -1, 0, 0); |
| 1251 | SPLIT_CHAR (op, reg[RRR], i, j); | 1249 | SPLIT_CHAR (op, reg[RRR], i, j); |
| 1252 | if (j != -1) | 1250 | if (j != -1) |
| 1253 | i = (i << 7) | j; | 1251 | i = (i << 7) | j; |
| @@ -1257,10 +1255,10 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed) | |||
| 1257 | 1255 | ||
| 1258 | case CCL_IterateMultipleMap: | 1256 | case CCL_IterateMultipleMap: |
| 1259 | { | 1257 | { |
| 1260 | Lisp_Object table, content, attrib, value; | 1258 | Lisp_Object map, content, attrib, value; |
| 1261 | int point, size, fin_ic; | 1259 | int point, size, fin_ic; |
| 1262 | 1260 | ||
| 1263 | j = XINT (ccl_prog[ic++]); /* number of tables. */ | 1261 | j = XINT (ccl_prog[ic++]); /* number of maps. */ |
| 1264 | fin_ic = ic + j; | 1262 | fin_ic = ic + j; |
| 1265 | op = reg[rrr]; | 1263 | op = reg[rrr]; |
| 1266 | if ((j > reg[RRR]) && (j >= 0)) | 1264 | if ((j > reg[RRR]) && (j >= 0)) |
| @@ -1278,22 +1276,22 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed) | |||
| 1278 | for (;i < j;i++) | 1276 | for (;i < j;i++) |
| 1279 | { | 1277 | { |
| 1280 | 1278 | ||
| 1281 | size = XVECTOR (Vccl_translation_table_vector)->size; | 1279 | size = XVECTOR (Vcode_conversion_map_vector)->size; |
| 1282 | point = XINT (ccl_prog[ic++]); | 1280 | point = XINT (ccl_prog[ic++]); |
| 1283 | if (point >= size) continue; | 1281 | if (point >= size) continue; |
| 1284 | table = | 1282 | map = |
| 1285 | XVECTOR (Vccl_translation_table_vector)->contents[point]; | 1283 | XVECTOR (Vcode_conversion_map_vector)->contents[point]; |
| 1286 | 1284 | ||
| 1287 | /* Check table varidity. */ | 1285 | /* Check map varidity. */ |
| 1288 | if (!CONSP (table)) continue; | 1286 | if (!CONSP (map)) continue; |
| 1289 | table = XCONS(table)->cdr; | 1287 | map = XCONS(map)->cdr; |
| 1290 | if (!VECTORP (table)) continue; | 1288 | if (!VECTORP (map)) continue; |
| 1291 | size = XVECTOR (table)->size; | 1289 | size = XVECTOR (map)->size; |
| 1292 | if (size <= 1) continue; | 1290 | if (size <= 1) continue; |
| 1293 | 1291 | ||
| 1294 | content = XVECTOR (table)->contents[0]; | 1292 | content = XVECTOR (map)->contents[0]; |
| 1295 | 1293 | ||
| 1296 | /* check table type, | 1294 | /* check map type, |
| 1297 | [STARTPOINT VAL1 VAL2 ...] or | 1295 | [STARTPOINT VAL1 VAL2 ...] or |
| 1298 | [t ELELMENT STARTPOINT ENDPOINT] */ | 1296 | [t ELELMENT STARTPOINT ENDPOINT] */ |
| 1299 | if (NUMBERP (content)) | 1297 | if (NUMBERP (content)) |
| @@ -1301,14 +1299,14 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed) | |||
| 1301 | point = XUINT (content); | 1299 | point = XUINT (content); |
| 1302 | point = op - point + 1; | 1300 | point = op - point + 1; |
| 1303 | if (!((point >= 1) && (point < size))) continue; | 1301 | if (!((point >= 1) && (point < size))) continue; |
| 1304 | content = XVECTOR (table)->contents[point]; | 1302 | content = XVECTOR (map)->contents[point]; |
| 1305 | } | 1303 | } |
| 1306 | else if (EQ (content, Qt)) | 1304 | else if (EQ (content, Qt)) |
| 1307 | { | 1305 | { |
| 1308 | if (size != 4) continue; | 1306 | if (size != 4) continue; |
| 1309 | if ((op >= XUINT (XVECTOR (table)->contents[2])) | 1307 | if ((op >= XUINT (XVECTOR (map)->contents[2])) |
| 1310 | && (op < XUINT (XVECTOR (table)->contents[3]))) | 1308 | && (op < XUINT (XVECTOR (map)->contents[3]))) |
| 1311 | content = XVECTOR (table)->contents[1]; | 1309 | content = XVECTOR (map)->contents[1]; |
| 1312 | else | 1310 | else |
| 1313 | continue; | 1311 | continue; |
| 1314 | } | 1312 | } |
| @@ -1345,20 +1343,20 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed) | |||
| 1345 | } | 1343 | } |
| 1346 | break; | 1344 | break; |
| 1347 | 1345 | ||
| 1348 | case CCL_TranslateMultipleMap: | 1346 | case CCL_MapMultiple: |
| 1349 | { | 1347 | { |
| 1350 | Lisp_Object table, content, attrib, value; | 1348 | Lisp_Object map, content, attrib, value; |
| 1351 | int point, size, table_vector_size; | 1349 | int point, size, map_vector_size; |
| 1352 | int table_set_rest_length, fin_ic; | 1350 | int map_set_rest_length, fin_ic; |
| 1353 | 1351 | ||
| 1354 | table_set_rest_length = | 1352 | map_set_rest_length = |
| 1355 | XINT (ccl_prog[ic++]); /* number of tables and separators. */ | 1353 | XINT (ccl_prog[ic++]); /* number of maps and separators. */ |
| 1356 | fin_ic = ic + table_set_rest_length; | 1354 | fin_ic = ic + map_set_rest_length; |
| 1357 | if ((table_set_rest_length > reg[RRR]) && (reg[RRR] >= 0)) | 1355 | if ((map_set_rest_length > reg[RRR]) && (reg[RRR] >= 0)) |
| 1358 | { | 1356 | { |
| 1359 | ic += reg[RRR]; | 1357 | ic += reg[RRR]; |
| 1360 | i = reg[RRR]; | 1358 | i = reg[RRR]; |
| 1361 | table_set_rest_length -= i; | 1359 | map_set_rest_length -= i; |
| 1362 | } | 1360 | } |
| 1363 | else | 1361 | else |
| 1364 | { | 1362 | { |
| @@ -1366,44 +1364,43 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed) | |||
| 1366 | reg[RRR] = -1; | 1364 | reg[RRR] = -1; |
| 1367 | break; | 1365 | break; |
| 1368 | } | 1366 | } |
| 1369 | translate_stack_pointer = translate_stack; | 1367 | mapping_stack_pointer = mapping_stack; |
| 1370 | op = reg[rrr]; | 1368 | op = reg[rrr]; |
| 1371 | PUSH_TRANSLATE_STACK (0, op); | 1369 | PUSH_MAPPING_STACK (0, op); |
| 1372 | reg[RRR] = -1; | 1370 | reg[RRR] = -1; |
| 1373 | table_vector_size | 1371 | map_vector_size = XVECTOR (Vcode_conversion_map_vector)->size; |
| 1374 | = XVECTOR (Vccl_translation_table_vector)->size; | 1372 | for (;map_set_rest_length > 0;i++, map_set_rest_length--) |
| 1375 | for (;table_set_rest_length > 0;i++, table_set_rest_length--) | ||
| 1376 | { | 1373 | { |
| 1377 | point = XINT(ccl_prog[ic++]); | 1374 | point = XINT(ccl_prog[ic++]); |
| 1378 | if (point < 0) | 1375 | if (point < 0) |
| 1379 | { | 1376 | { |
| 1380 | point = -point; | 1377 | point = -point; |
| 1381 | if (translate_stack_pointer | 1378 | if (mapping_stack_pointer |
| 1382 | >= &translate_stack[MAX_TABLE_SET_LEVEL]) | 1379 | >= &mapping_stack[MAX_MAP_SET_LEVEL]) |
| 1383 | { | 1380 | { |
| 1384 | CCL_INVALID_CMD; | 1381 | CCL_INVALID_CMD; |
| 1385 | } | 1382 | } |
| 1386 | PUSH_TRANSLATE_STACK (table_set_rest_length - point, | 1383 | PUSH_MAPPING_STACK (map_set_rest_length - point, |
| 1387 | reg[rrr]); | 1384 | reg[rrr]); |
| 1388 | table_set_rest_length = point + 1; | 1385 | map_set_rest_length = point + 1; |
| 1389 | reg[rrr] = op; | 1386 | reg[rrr] = op; |
| 1390 | continue; | 1387 | continue; |
| 1391 | } | 1388 | } |
| 1392 | 1389 | ||
| 1393 | if (point >= table_vector_size) continue; | 1390 | if (point >= map_vector_size) continue; |
| 1394 | table = | 1391 | map = (XVECTOR (Vcode_conversion_map_vector) |
| 1395 | XVECTOR (Vccl_translation_table_vector)->contents[point]; | 1392 | ->contents[point]); |
| 1396 | 1393 | ||
| 1397 | /* Check table varidity. */ | 1394 | /* Check map varidity. */ |
| 1398 | if (!CONSP (table)) continue; | 1395 | if (!CONSP (map)) continue; |
| 1399 | table = XCONS (table)->cdr; | 1396 | map = XCONS (map)->cdr; |
| 1400 | if (!VECTORP (table)) continue; | 1397 | if (!VECTORP (map)) continue; |
| 1401 | size = XVECTOR (table)->size; | 1398 | size = XVECTOR (map)->size; |
| 1402 | if (size <= 1) continue; | 1399 | if (size <= 1) continue; |
| 1403 | 1400 | ||
| 1404 | content = XVECTOR (table)->contents[0]; | 1401 | content = XVECTOR (map)->contents[0]; |
| 1405 | 1402 | ||
| 1406 | /* check table type, | 1403 | /* check map type, |
| 1407 | [STARTPOINT VAL1 VAL2 ...] or | 1404 | [STARTPOINT VAL1 VAL2 ...] or |
| 1408 | [t ELEMENT STARTPOINT ENDPOINT] */ | 1405 | [t ELEMENT STARTPOINT ENDPOINT] */ |
| 1409 | if (NUMBERP (content)) | 1406 | if (NUMBERP (content)) |
| @@ -1411,14 +1408,14 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed) | |||
| 1411 | point = XUINT (content); | 1408 | point = XUINT (content); |
| 1412 | point = op - point + 1; | 1409 | point = op - point + 1; |
| 1413 | if (!((point >= 1) && (point < size))) continue; | 1410 | if (!((point >= 1) && (point < size))) continue; |
| 1414 | content = XVECTOR (table)->contents[point]; | 1411 | content = XVECTOR (map)->contents[point]; |
| 1415 | } | 1412 | } |
| 1416 | else if (EQ (content, Qt)) | 1413 | else if (EQ (content, Qt)) |
| 1417 | { | 1414 | { |
| 1418 | if (size != 4) continue; | 1415 | if (size != 4) continue; |
| 1419 | if ((op >= XUINT (XVECTOR (table)->contents[2])) && | 1416 | if ((op >= XUINT (XVECTOR (map)->contents[2])) && |
| 1420 | (op < XUINT (XVECTOR (table)->contents[3]))) | 1417 | (op < XUINT (XVECTOR (map)->contents[3]))) |
| 1421 | content = XVECTOR (table)->contents[1]; | 1418 | content = XVECTOR (map)->contents[1]; |
| 1422 | else | 1419 | else |
| 1423 | continue; | 1420 | continue; |
| 1424 | } | 1421 | } |
| @@ -1431,8 +1428,8 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed) | |||
| 1431 | { | 1428 | { |
| 1432 | op = XINT (content); | 1429 | op = XINT (content); |
| 1433 | reg[RRR] = i; | 1430 | reg[RRR] = i; |
| 1434 | i += table_set_rest_length; | 1431 | i += map_set_rest_length; |
| 1435 | POP_TRANSLATE_STACK (table_set_rest_length, reg[rrr]); | 1432 | POP_MAPPING_STACK (map_set_rest_length, reg[rrr]); |
| 1436 | } | 1433 | } |
| 1437 | else if (CONSP (content)) | 1434 | else if (CONSP (content)) |
| 1438 | { | 1435 | { |
| @@ -1442,15 +1439,15 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed) | |||
| 1442 | continue; | 1439 | continue; |
| 1443 | reg[RRR] = i; | 1440 | reg[RRR] = i; |
| 1444 | op = XUINT (value); | 1441 | op = XUINT (value); |
| 1445 | i += table_set_rest_length; | 1442 | i += map_set_rest_length; |
| 1446 | POP_TRANSLATE_STACK (table_set_rest_length, reg[rrr]); | 1443 | POP_MAPPING_STACK (map_set_rest_length, reg[rrr]); |
| 1447 | } | 1444 | } |
| 1448 | else if (EQ (content, Qt)) | 1445 | else if (EQ (content, Qt)) |
| 1449 | { | 1446 | { |
| 1450 | reg[RRR] = i; | 1447 | reg[RRR] = i; |
| 1451 | op = reg[rrr]; | 1448 | op = reg[rrr]; |
| 1452 | i += table_set_rest_length; | 1449 | i += map_set_rest_length; |
| 1453 | POP_TRANSLATE_STACK (table_set_rest_length, reg[rrr]); | 1450 | POP_MAPPING_STACK (map_set_rest_length, reg[rrr]); |
| 1454 | } | 1451 | } |
| 1455 | else if (EQ (content, Qlambda)) | 1452 | else if (EQ (content, Qlambda)) |
| 1456 | { | 1453 | { |
| @@ -1464,31 +1461,31 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed) | |||
| 1464 | reg[rrr] = op; | 1461 | reg[rrr] = op; |
| 1465 | break; | 1462 | break; |
| 1466 | 1463 | ||
| 1467 | case CCL_TranslateSingleMap: | 1464 | case CCL_MapSingle: |
| 1468 | { | 1465 | { |
| 1469 | Lisp_Object table, attrib, value, content; | 1466 | Lisp_Object map, attrib, value, content; |
| 1470 | int size, point; | 1467 | int size, point; |
| 1471 | j = XINT (ccl_prog[ic++]); /* table_id */ | 1468 | j = XINT (ccl_prog[ic++]); /* map_id */ |
| 1472 | op = reg[rrr]; | 1469 | op = reg[rrr]; |
| 1473 | if (j >= XVECTOR (Vccl_translation_table_vector)->size) | 1470 | if (j >= XVECTOR (Vcode_conversion_map_vector)->size) |
| 1474 | { | 1471 | { |
| 1475 | reg[RRR] = -1; | 1472 | reg[RRR] = -1; |
| 1476 | break; | 1473 | break; |
| 1477 | } | 1474 | } |
| 1478 | table = XVECTOR (Vccl_translation_table_vector)->contents[j]; | 1475 | map = XVECTOR (Vcode_conversion_map_vector)->contents[j]; |
| 1479 | if (!CONSP (table)) | 1476 | if (!CONSP (map)) |
| 1480 | { | 1477 | { |
| 1481 | reg[RRR] = -1; | 1478 | reg[RRR] = -1; |
| 1482 | break; | 1479 | break; |
| 1483 | } | 1480 | } |
| 1484 | table = XCONS(table)->cdr; | 1481 | map = XCONS(map)->cdr; |
| 1485 | if (!VECTORP (table)) | 1482 | if (!VECTORP (map)) |
| 1486 | { | 1483 | { |
| 1487 | reg[RRR] = -1; | 1484 | reg[RRR] = -1; |
| 1488 | break; | 1485 | break; |
| 1489 | } | 1486 | } |
| 1490 | size = XVECTOR (table)->size; | 1487 | size = XVECTOR (map)->size; |
| 1491 | point = XUINT (XVECTOR (table)->contents[0]); | 1488 | point = XUINT (XVECTOR (map)->contents[0]); |
| 1492 | point = op - point + 1; | 1489 | point = op - point + 1; |
| 1493 | reg[RRR] = 0; | 1490 | reg[RRR] = 0; |
| 1494 | if ((size <= 1) || | 1491 | if ((size <= 1) || |
| @@ -1496,7 +1493,7 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed) | |||
| 1496 | reg[RRR] = -1; | 1493 | reg[RRR] = -1; |
| 1497 | else | 1494 | else |
| 1498 | { | 1495 | { |
| 1499 | content = XVECTOR (table)->contents[point]; | 1496 | content = XVECTOR (map)->contents[point]; |
| 1500 | if (NILP (content)) | 1497 | if (NILP (content)) |
| 1501 | reg[RRR] = -1; | 1498 | reg[RRR] = -1; |
| 1502 | else if (NUMBERP (content)) | 1499 | else if (NUMBERP (content)) |
| @@ -1614,8 +1611,8 @@ setup_ccl_program (ccl, vec) | |||
| 1614 | } | 1611 | } |
| 1615 | 1612 | ||
| 1616 | /* Resolve symbols in the specified CCL code (Lisp vector). This | 1613 | /* Resolve symbols in the specified CCL code (Lisp vector). This |
| 1617 | function converts translation-table and unification-table symbols | 1614 | function converts symbols of code conversion maps and character |
| 1618 | embeded in the CCL code into their ID numbers. */ | 1615 | translation tables embeded in the CCL code into their ID numbers. */ |
| 1619 | 1616 | ||
| 1620 | Lisp_Object | 1617 | Lisp_Object |
| 1621 | resolve_symbol_ccl_program (ccl) | 1618 | resolve_symbol_ccl_program (ccl) |
| @@ -1636,13 +1633,13 @@ resolve_symbol_ccl_program (ccl) | |||
| 1636 | if (EQ(result, ccl)) | 1633 | if (EQ(result, ccl)) |
| 1637 | result = Fcopy_sequence (ccl); | 1634 | result = Fcopy_sequence (ccl); |
| 1638 | 1635 | ||
| 1639 | prop = Fget (contents, Qunification_table_id); | 1636 | prop = Fget (contents, Qcharacter_translation_table_id); |
| 1640 | if (NUMBERP (prop)) | 1637 | if (NUMBERP (prop)) |
| 1641 | { | 1638 | { |
| 1642 | XVECTOR (result)->contents[i] = prop; | 1639 | XVECTOR (result)->contents[i] = prop; |
| 1643 | continue; | 1640 | continue; |
| 1644 | } | 1641 | } |
| 1645 | prop = Fget (contents, Qccl_translation_table_id); | 1642 | prop = Fget (contents, Qcode_conversion_map_id); |
| 1646 | if (NUMBERP (prop)) | 1643 | if (NUMBERP (prop)) |
| 1647 | { | 1644 | { |
| 1648 | XVECTOR (result)->contents[i] = prop; | 1645 | XVECTOR (result)->contents[i] = prop; |
| @@ -1860,34 +1857,33 @@ Return index number of the registered CCL program.") | |||
| 1860 | return make_number (i); | 1857 | return make_number (i); |
| 1861 | } | 1858 | } |
| 1862 | 1859 | ||
| 1863 | /* register CCL translation table. | 1860 | /* Register code conversion map. |
| 1864 | CCL translation table consists of numbers and Qt and Qnil and Qlambda. | 1861 | A code conversion map consists of numbers, Qt, Qnil, and Qlambda. |
| 1865 | The first element is start code point. | 1862 | The first element is start code point. |
| 1866 | The rest elements are translated numbers. | 1863 | The rest elements are mapped numbers. |
| 1867 | Qt shows that an original number before translation. | 1864 | Symbol t means to map to an original number before mapping. |
| 1868 | Qnil shows that an empty element. | 1865 | Symbol nil means that the corresponding element is empty. |
| 1869 | Qlambda makes translation stopped. | 1866 | Symbol lambda menas to terminate mapping here. |
| 1870 | */ | 1867 | */ |
| 1871 | 1868 | ||
| 1872 | DEFUN ("register-ccl-translation-table", Fregister_ccl_translation_table, | 1869 | DEFUN ("register-code-conversion-map", Fregister_code_conversion_map, |
| 1873 | Sregister_ccl_translation_table, | 1870 | Sregister_code_conversion_map, |
| 1874 | 2, 2, 0, | 1871 | 2, 2, 0, |
| 1875 | "Register CCL translation table.\n\ | 1872 | "Register SYMBOL as code conversion map MAP.\n\ |
| 1876 | TABLE should be a vector. SYMBOL is used for pointing the translation table out.\n\ | 1873 | Return index number of the registered map.") |
| 1877 | Return index number of the registered translation table.") | 1874 | (symbol, map) |
| 1878 | (symbol, table) | 1875 | Lisp_Object symbol, map; |
| 1879 | Lisp_Object symbol, table; | ||
| 1880 | { | 1876 | { |
| 1881 | int len = XVECTOR (Vccl_translation_table_vector)->size; | 1877 | int len = XVECTOR (Vcode_conversion_map_vector)->size; |
| 1882 | int i; | 1878 | int i; |
| 1883 | Lisp_Object index; | 1879 | Lisp_Object index; |
| 1884 | 1880 | ||
| 1885 | CHECK_SYMBOL (symbol, 0); | 1881 | CHECK_SYMBOL (symbol, 0); |
| 1886 | CHECK_VECTOR (table, 1); | 1882 | CHECK_VECTOR (map, 1); |
| 1887 | 1883 | ||
| 1888 | for (i = 0; i < len; i++) | 1884 | for (i = 0; i < len; i++) |
| 1889 | { | 1885 | { |
| 1890 | Lisp_Object slot = XVECTOR (Vccl_translation_table_vector)->contents[i]; | 1886 | Lisp_Object slot = XVECTOR (Vcode_conversion_map_vector)->contents[i]; |
| 1891 | 1887 | ||
| 1892 | if (!CONSP (slot)) | 1888 | if (!CONSP (slot)) |
| 1893 | break; | 1889 | break; |
| @@ -1895,9 +1891,9 @@ Return index number of the registered translation table.") | |||
| 1895 | if (EQ (symbol, XCONS (slot)->car)) | 1891 | if (EQ (symbol, XCONS (slot)->car)) |
| 1896 | { | 1892 | { |
| 1897 | index = make_number (i); | 1893 | index = make_number (i); |
| 1898 | XCONS (slot)->cdr = table; | 1894 | XCONS (slot)->cdr = map; |
| 1899 | Fput (symbol, Qccl_translation_table, table); | 1895 | Fput (symbol, Qcode_conversion_map, map); |
| 1900 | Fput (symbol, Qccl_translation_table_id, index); | 1896 | Fput (symbol, Qcode_conversion_map_id, index); |
| 1901 | return index; | 1897 | return index; |
| 1902 | } | 1898 | } |
| 1903 | } | 1899 | } |
| @@ -1909,14 +1905,14 @@ Return index number of the registered translation table.") | |||
| 1909 | 1905 | ||
| 1910 | for (j = 0; j < len; j++) | 1906 | for (j = 0; j < len; j++) |
| 1911 | XVECTOR (new_vector)->contents[j] | 1907 | XVECTOR (new_vector)->contents[j] |
| 1912 | = XVECTOR (Vccl_translation_table_vector)->contents[j]; | 1908 | = XVECTOR (Vcode_conversion_map_vector)->contents[j]; |
| 1913 | Vccl_translation_table_vector = new_vector; | 1909 | Vcode_conversion_map_vector = new_vector; |
| 1914 | } | 1910 | } |
| 1915 | 1911 | ||
| 1916 | index = make_number (i); | 1912 | index = make_number (i); |
| 1917 | Fput (symbol, Qccl_translation_table, table); | 1913 | Fput (symbol, Qcode_conversion_map, map); |
| 1918 | Fput (symbol, Qccl_translation_table_id, index); | 1914 | Fput (symbol, Qcode_conversion_map_id, index); |
| 1919 | XVECTOR (Vccl_translation_table_vector)->contents[i] = Fcons (symbol, table); | 1915 | XVECTOR (Vcode_conversion_map_vector)->contents[i] = Fcons (symbol, map); |
| 1920 | return index; | 1916 | return index; |
| 1921 | } | 1917 | } |
| 1922 | 1918 | ||
| @@ -1933,22 +1929,15 @@ syms_of_ccl () | |||
| 1933 | Qccl_program_idx = intern ("ccl-program-idx"); | 1929 | Qccl_program_idx = intern ("ccl-program-idx"); |
| 1934 | staticpro (&Qccl_program_idx); | 1930 | staticpro (&Qccl_program_idx); |
| 1935 | 1931 | ||
| 1936 | Qccl_translation_table = intern ("ccl-translation-table"); | 1932 | Qcode_conversion_map = intern ("code-conversion-map"); |
| 1937 | staticpro (&Qccl_translation_table); | 1933 | staticpro (&Qcode_conversion_map); |
| 1938 | |||
| 1939 | Qccl_translation_table_id = intern ("ccl-translation-table-id"); | ||
| 1940 | staticpro (&Qccl_translation_table_id); | ||
| 1941 | |||
| 1942 | Qunification_table = intern ("unification-table"); | ||
| 1943 | staticpro (&Qunification_table); | ||
| 1944 | 1934 | ||
| 1945 | Qunification_table_id = intern ("unification-table-id"); | 1935 | Qcode_conversion_map_id = intern ("code-conversion-map-id"); |
| 1946 | staticpro (&Qunification_table_id); | 1936 | staticpro (&Qcode_conversion_map_id); |
| 1947 | 1937 | ||
| 1948 | DEFVAR_LISP ("ccl-translation-table-vector", &Vccl_translation_table_vector, | 1938 | DEFVAR_LISP ("code-conversion-map-vector", &Vcode_conversion_map_vector, |
| 1949 | "Where is stored translation tables for CCL program.\n\ | 1939 | "Vector of code conversion maps."); |
| 1950 | Because CCL program can't access these tables except by the index of the vector."); | 1940 | Vcode_conversion_map_vector = Fmake_vector (make_number (16), Qnil); |
| 1951 | Vccl_translation_table_vector = Fmake_vector (make_number (16), Qnil); | ||
| 1952 | 1941 | ||
| 1953 | DEFVAR_LISP ("font-ccl-encoder-alist", &Vfont_ccl_encoder_alist, | 1942 | DEFVAR_LISP ("font-ccl-encoder-alist", &Vfont_ccl_encoder_alist, |
| 1954 | "Alist of fontname patterns vs corresponding CCL program.\n\ | 1943 | "Alist of fontname patterns vs corresponding CCL program.\n\ |
| @@ -1966,7 +1955,7 @@ If the font is single-byte font, the register R2 is not used."); | |||
| 1966 | defsubr (&Sccl_execute); | 1955 | defsubr (&Sccl_execute); |
| 1967 | defsubr (&Sccl_execute_on_string); | 1956 | defsubr (&Sccl_execute_on_string); |
| 1968 | defsubr (&Sregister_ccl_program); | 1957 | defsubr (&Sregister_ccl_program); |
| 1969 | defsubr (&Sregister_ccl_translation_table); | 1958 | defsubr (&Sregister_code_conversion_map); |
| 1970 | } | 1959 | } |
| 1971 | 1960 | ||
| 1972 | #endif /* emacs */ | 1961 | #endif /* emacs */ |