X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fmule-ccl.c;h=68d123e2f174fa689a004800545f748429a337c6;hb=2cbece6401b2279497293e6dc54cda607f49db2f;hp=e84c7e1e038bb09434140d1e90db2ac3612d4973;hpb=ea1ea793fe6e244ef5555ed983423a204101af13;p=chise%2Fxemacs-chise.git- diff --git a/src/mule-ccl.c b/src/mule-ccl.c index e84c7e1..68d123e 100644 --- a/src/mule-ccl.c +++ b/src/mule-ccl.c @@ -34,7 +34,7 @@ Boston, MA 02111-1307, USA. */ #include "lisp.h" #include "buffer.h" -#include "mule-charset.h" +#include "character.h" #include "mule-ccl.h" #include "file-coding.h" @@ -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:... @@ -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. */ @@ -746,7 +756,7 @@ struct ccl_prog_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,7 +765,7 @@ 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; @@ -1114,9 +1124,10 @@ ccl_driver (struct ccl_program *ccl, CONST unsigned char *source, ic = jump_address; break; - case CCL_Extention: + case CCL_Extension: switch (EXCMD) { +#ifndef UTF2000 case CCL_ReadMultibyteChar2: if (!src) CCL_INVALID_CMD; @@ -1230,7 +1241,9 @@ ccl_driver (struct ccl_program *ccl, CONST unsigned char *source, CCL_SUSPEND (CCL_STAT_SUSPEND_BY_SRC); break; +#endif +#ifndef UTF2000 case CCL_WriteMultibyteChar2: i = reg[RRR]; /* charset */ if (i == LEADING_BYTE_ASCII) @@ -1250,6 +1263,7 @@ ccl_driver (struct ccl_program *ccl, CONST unsigned char *source, CCL_WRITE_CHAR (i); break; +#endif #if 0 case CCL_TranslateCharacter: @@ -1758,7 +1772,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) @@ -1838,7 +1852,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);