X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fmule-ccl.c;h=fc15f56e47f0df57bc25fac6f41454eeb68266df;hb=59eec5f21669e81977b5b1fe9bf717cab49cf7fb;hp=356c7de2097ad5f1c0b939062bba7b49e9a66f4d;hpb=1e7fd761ecf5fd2208bde8e30fc6f7cbf789b7db;p=chise%2Fxemacs-chise.git diff --git a/src/mule-ccl.c b/src/mule-ccl.c index 356c7de..fc15f56 100644 --- a/src/mule-ccl.c +++ b/src/mule-ccl.c @@ -181,18 +181,18 @@ Lisp_Object Vccl_program_table; #define CCL_WriteConstJump 0x08 /* Write constant and jump: 1:A--D--D--R--E--S--S-000XXXXX - 2:CONST + 2:const ------------------------------ - write (CONST); + write (const); IC += ADDRESS; */ #define CCL_WriteConstReadJump 0x09 /* Write constant, read, and jump: 1:A--D--D--R--E--S--S-rrrXXXXX - 2:CONST + 2:const 3:A--D--D--R--E--S--S-rrrYYYYY ----------------------------- - write (CONST); + write (const); IC += 2; read (reg[rrr]); IC += ADDRESS; @@ -422,7 +422,7 @@ Lisp_Object Vccl_program_table; IC += 2; */ -#define CCL_Extention 0x1F /* Extended CCL code +#define CCL_Extension 0x1F /* Extended CCL code 1:ExtendedCOMMNDRrrRRRrrrXXXXX 2:ARGUEMENT 3:... @@ -430,7 +430,7 @@ Lisp_Object Vccl_program_table; extended_command (rrr,RRR,Rrr,ARGS) */ -/* +/* Here after, Extended CCL Instructions. Bit length of extended command is 14. Therefore, the instruction code range is 0..16384(0x3fff). @@ -489,7 +489,7 @@ Lisp_Object Vccl_program_table; 3:MAP-ID1 4:MAP-ID2 ... - */ + */ /* Map the code in reg[rrr] by MAPs starting from the Nth (N = reg[RRR]) map. @@ -560,7 +560,7 @@ Lisp_Object Vccl_program_table; where STARTPOINT is an offset to be used for indexing a map, ENDPOINT is a maximum index number of a map, - VAL and VALn is a number, nil, t, or lambda. + VAL and VALn is a number, nil, t, or lambda. Valid index range of a map of type (a) is: STARTPOINT <= index < STARTPOINT + map_size - 1 @@ -645,20 +645,20 @@ static tr_stack *mapping_stack_pointer; /* Suspend CCL program because of reading from empty input buffer or writing to full output buffer. When this program is resumed, the - same I/O command is executed. */ + same I/O command is executed. The `if (1)' is for warning suppression. */ #define CCL_SUSPEND(stat) \ do { \ ic--; \ ccl->status = stat; \ - goto ccl_finish; \ + if (1) goto ccl_finish; \ } while (0) /* Terminate CCL program because of invalid command. Should not occur - in the normal case. */ + in the normal case. The `if (1)' is for warning suppression. */ #define CCL_INVALID_CMD \ do { \ ccl->status = CCL_STAT_INVALID_CMD; \ - goto ccl_error_handler; \ + if (1) goto ccl_error_handler; \ } while (0) /* Encode one character CH to multibyte form and write to the current @@ -682,17 +682,27 @@ static tr_stack *mapping_stack_pointer; /* Write a string at ccl_prog[IC] of length LEN to the current output buffer. */ -#define CCL_WRITE_STRING(len) do { \ - if (!destination) \ - { \ - ccl->status = CCL_STAT_INVALID_CMD; \ - goto ccl_error_handler; \ - } \ - else \ - for (i = 0; i < len; i++) \ - Dynarr_add(destination, \ - (XINT (ccl_prog[ic + (i / 3)]) \ - >> ((2 - (i % 3)) * 8)) & 0xFF); \ +#define CCL_WRITE_STRING(len) do { \ + if (!destination) \ + { \ + ccl->status = CCL_STAT_INVALID_CMD; \ + goto ccl_error_handler; \ + } \ + else \ + { \ + Bufbyte work[MAX_EMCHAR_LEN]; \ + for (i = 0; i < len; i++) \ + { \ + int ch = (XINT (ccl_prog[ic + (i / 3)]) \ + >> ((2 - (i % 3)) * 8)) & 0xFF; \ + int bytes = \ + ( ch < ( conversion_mode == CCL_MODE_ENCODING ? \ + 256 : 128 ) ) ? \ + simple_set_charptr_emchar (work, ch) : \ + non_ascii_set_charptr_emchar (work, ch); \ + Dynarr_add_many (destination, work, bytes); \ + } \ + } \ } while (0) /* Read one byte from the current input buffer into Rth register. */ @@ -742,11 +752,11 @@ struct ccl_prog_stack int ic; /* Instruction Counter. */ }; -/* For the moment, we only support depth 256 of stack. */ +/* For the moment, we only support depth 256 of stack. */ static struct ccl_prog_stack ccl_prog_stack_struct[256]; int -ccl_driver (struct ccl_program *ccl, CONST unsigned char *source, +ccl_driver (struct ccl_program *ccl, const unsigned char *source, unsigned_char_dynarr *destination, int src_bytes, int *consumed, int conversion_mode) { @@ -755,12 +765,12 @@ ccl_driver (struct ccl_program *ccl, CONST unsigned char *source, int code = -1; /* init to illegal value, */ int field1, field2; Lisp_Object *ccl_prog = ccl->prog; - CONST unsigned char *src = source, *src_end = src + src_bytes; + const unsigned char *src = source, *src_end = src + src_bytes; int jump_address = 0; /* shut up the compiler */ int i, j, op; int stack_idx = ccl->stack_idx; /* Instruction counter of the current CCL code. */ - int this_ic; + int this_ic = 0; if (ic >= ccl->eof_ic) ic = CCL_HEADER_MAIN; @@ -1114,7 +1124,7 @@ ccl_driver (struct ccl_program *ccl, CONST unsigned char *source, ic = jump_address; break; - case CCL_Extention: + case CCL_Extension: switch (EXCMD) { case CCL_ReadMultibyteChar2: @@ -1127,7 +1137,7 @@ ccl_driver (struct ccl_program *ccl, CONST unsigned char *source, src++; goto ccl_read_multibyte_character_suspend; } - + i = *src++; #if 0 if (i == LEADING_CODE_COMPOSITION) @@ -1273,7 +1283,7 @@ ccl_driver (struct ccl_program *ccl, CONST unsigned char *source, SPLIT_CHAR (op, reg[RRR], i, j); if (j != -1) i = (i << 7) | j; - + reg[rrr] = i; break; @@ -1299,7 +1309,7 @@ ccl_driver (struct ccl_program *ccl, CONST unsigned char *source, SPLIT_CHAR (op, reg[RRR], i, j); if (j != -1) i = (i << 7) | j; - + reg[rrr] = i; break; @@ -1360,7 +1370,7 @@ ccl_driver (struct ccl_program *ccl, CONST unsigned char *source, else continue; } - else + else continue; if (NILP (content)) @@ -1392,7 +1402,7 @@ ccl_driver (struct ccl_program *ccl, CONST unsigned char *source, ic = fin_ic; } break; - + case CCL_MapMultiple: { Lisp_Object map, content, attrib, value; @@ -1469,7 +1479,7 @@ ccl_driver (struct ccl_program *ccl, CONST unsigned char *source, else continue; } - else + else continue; if (NILP (content)) @@ -1565,7 +1575,7 @@ ccl_driver (struct ccl_program *ccl, CONST unsigned char *source, } break; #endif - + default: CCL_INVALID_CMD; } @@ -1667,7 +1677,7 @@ setup_ccl_program (struct ccl_program *ccl, Lisp_Object vec) function converts symbols of code conversion maps and character translation tables embeded in the CCL code into their ID numbers. */ -Lisp_Object +static Lisp_Object resolve_symbol_ccl_program (Lisp_Object ccl) { int i, veclen; @@ -1734,8 +1744,8 @@ As side effect, each element of REGISTER holds the value of int i; Lisp_Object ccl_id; - if ((SYMBOLP (ccl_prog)) && - (!NILP (ccl_id = Fget (ccl_prog, Qccl_program_idx, Qnil)))) + if (SYMBOLP (ccl_prog) && + !NILP (ccl_id = Fget (ccl_prog, Qccl_program_idx, Qnil))) { ccl_prog = XVECTOR_DATA (Vccl_program_table)[XUINT (ccl_id)]; CHECK_LIST (ccl_prog); @@ -1758,7 +1768,7 @@ As side effect, each element of REGISTER holds the value of ? XINT (XVECTOR_DATA (reg)[i]) : 0); - ccl_driver (&ccl, (CONST unsigned char *)0, (unsigned_char_dynarr *)0, + ccl_driver (&ccl, (const unsigned char *)0, (unsigned_char_dynarr *)0, 0, (int *)0, CCL_MODE_ENCODING); QUIT; if (ccl.status != CCL_STAT_SUCCESS) @@ -1801,8 +1811,8 @@ It returns the contents of write buffer as a string, struct gcpro gcpro1, gcpro2, gcpro3; Lisp_Object ccl_id; - if ((SYMBOLP (ccl_prog)) && - (!NILP (ccl_id = Fget (ccl_prog, Qccl_program_idx, Qnil)))) + if (SYMBOLP (ccl_prog) && + !NILP (ccl_id = Fget (ccl_prog, Qccl_program_idx, Qnil))) { ccl_prog = XVECTOR (Vccl_program_table)->contents[XUINT (ccl_id)]; CHECK_LIST (ccl_prog); @@ -1838,7 +1848,7 @@ It returns the contents of write buffer as a string, outbuf = Dynarr_new (unsigned_char); ccl.last_block = NILP (contin); produced = ccl_driver (&ccl, XSTRING_DATA (str), outbuf, - XSTRING_LENGTH (str), (int *)0, CCL_MODE_ENCODING); + XSTRING_LENGTH (str), (int *)0, CCL_MODE_DECODING); for (i = 0; i < 8; i++) XVECTOR_DATA (status)[i] = make_int(ccl.reg[i]); XSETINT (XVECTOR_DATA (status)[8], ccl.ic); @@ -1909,7 +1919,7 @@ Return index number of the registered CCL program. The rest elements are mapped numbers. Symbol t means to map to an original number before mapping. Symbol nil means that the corresponding element is empty. - Symbol lambda menas to terminate mapping here. + Symbol lambda means to terminate mapping here. */ DEFUN ("register-code-conversion-map", Fregister_code_conversion_map, @@ -1926,7 +1936,7 @@ Return index number of the registered map.") CHECK_SYMBOL (symbol, 0); CHECK_VECTOR (map, 1); - + for (i = 0; i < len; i++) { Lisp_Object slot = XVECTOR (Vcode_conversion_map_vector)->contents[i];