#include "lisp.h"
#include "buffer.h"
-#include "mule-charset.h"
+#include "character.h"
#include "mule-ccl.h"
#include "file-coding.h"
r[7] = LOWER_BYTE (SJIS (Y, Z) */
/* Terminate CCL program successfully. */
-#define CCL_SUCCESS \
-do { \
- ccl->status = CCL_STAT_SUCCESS; \
+#define CCL_SUCCESS \
+ do { \
+ ccl->status = CCL_STAT_SUCCESS; \
/* The "if (1)" inhibits the warning \
"end-of loop code not reached" */ \
if (1) goto ccl_finish; \
-} while (0)
+ } while (0)
/* 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. */
-#define CCL_SUSPEND(stat) \
-do { \
- ic--; \
+#define CCL_SUSPEND(stat) \
+ do { \
+ ic--; \
ccl->status = (stat); \
/* The "if (1)" inhibits the warning \
"end-of loop code not reached" */ \
if (1) goto ccl_finish; \
-} while (0)
+ } while (0)
/* Terminate CCL program because of invalid command. Should not occur
in the normal case. */
-#define CCL_INVALID_CMD \
-do { \
- ccl->status = CCL_STAT_INVALID_CMD; \
+#define CCL_INVALID_CMD \
+ do { \
+ ccl->status = CCL_STAT_INVALID_CMD; \
/* The "if (1)" inhibits the warning \
"end-of loop code not reached" */ \
if (1) goto ccl_error_handler; \
-} while (0)
+ } while (0)
/* Encode one character CH to multibyte form and write to the current
output buffer. At encoding time, if CH is less than 256, CH is
case CCL_Extension:
switch (EXCMD)
{
+#ifndef UTF2000
case CCL_ReadMultibyteChar2:
if (!src)
CCL_INVALID_CMD;
- if (src >= src_end)
- {
- src++;
- goto ccl_read_multibyte_character_suspend;
- }
-
- i = *src++;
- if (i < 0x80)
- {
- /* ASCII */
- reg[rrr] = i;
- reg[RRR] = LEADING_BYTE_ASCII;
- }
- else if (i <= MAX_LEADING_BYTE_OFFICIAL_1)
- {
- if (src >= src_end)
- goto ccl_read_multibyte_character_suspend;
- reg[RRR] = i;
- reg[rrr] = (*src++ & 0x7F);
- }
- else if (i <= MAX_LEADING_BYTE_OFFICIAL_2)
- {
- if ((src + 1) >= src_end)
- goto ccl_read_multibyte_character_suspend;
- reg[RRR] = i;
- i = (*src++ & 0x7F);
- reg[rrr] = ((i << 7) | (*src & 0x7F));
- src++;
- }
- else if (i == PRE_LEADING_BYTE_PRIVATE_1)
- {
- if ((src + 1) >= src_end)
- goto ccl_read_multibyte_character_suspend;
- reg[RRR] = *src++;
- reg[rrr] = (*src++ & 0x7F);
- }
- else if (i == PRE_LEADING_BYTE_PRIVATE_2)
- {
- if ((src + 2) >= src_end)
+ if (src >= src_end)
+ {
+ src++;
goto ccl_read_multibyte_character_suspend;
- reg[RRR] = *src++;
- i = (*src++ & 0x7F);
- reg[rrr] = ((i << 7) | (*src & 0x7F));
- src++;
- }
- else
- {
- /* INVALID CODE. Return a single byte character. */
- reg[RRR] = LEADING_BYTE_ASCII;
- reg[rrr] = i;
- }
+ }
+
+ i = *src++;
+ if (i < 0x80)
+ {
+ /* ASCII */
+ reg[rrr] = i;
+ reg[RRR] = LEADING_BYTE_ASCII;
+ }
+ else if (i <= MAX_LEADING_BYTE_OFFICIAL_1)
+ {
+ if (src >= src_end)
+ goto ccl_read_multibyte_character_suspend;
+ reg[RRR] = i;
+ reg[rrr] = (*src++ & 0x7F);
+ }
+ else if (LEADING_BYTE_CONTROL_1 == i)
+ {
+ if (src >= src_end)
+ goto ccl_read_multibyte_character_suspend;
+ reg[RRR] = i;
+ reg[rrr] = (*src++ - 0xA0);
+ }
+ else if (i <= MAX_LEADING_BYTE_OFFICIAL_2)
+ {
+ if ((src + 1) >= src_end)
+ goto ccl_read_multibyte_character_suspend;
+ reg[RRR] = i;
+ i = (*src++ & 0x7F);
+ reg[rrr] = ((i << 7) | (*src & 0x7F));
+ src++;
+ }
+ else if (i == PRE_LEADING_BYTE_PRIVATE_1)
+ {
+ if ((src + 1) >= src_end)
+ goto ccl_read_multibyte_character_suspend;
+ reg[RRR] = *src++;
+ reg[rrr] = (*src++ & 0x7F);
+ }
+ else if (i == PRE_LEADING_BYTE_PRIVATE_2)
+ {
+ if ((src + 2) >= src_end)
+ goto ccl_read_multibyte_character_suspend;
+ reg[RRR] = *src++;
+ i = (*src++ & 0x7F);
+ reg[rrr] = ((i << 7) | (*src & 0x7F));
+ src++;
+ }
+ else
+ {
+ /* INVALID CODE. Return a single byte character. */
+ reg[RRR] = LEADING_BYTE_ASCII;
+ reg[rrr] = i;
+ }
break;
ccl_read_multibyte_character_suspend:
CCL_SUSPEND (CCL_STAT_SUSPEND_BY_SRC);
break;
+#endif
+#ifndef UTF2000
case CCL_WriteMultibyteChar2:
i = reg[RRR]; /* charset */
- if (i == LEADING_BYTE_ASCII)
+ if (i == LEADING_BYTE_ASCII || i == LEADING_BYTE_CONTROL_1)
i = reg[rrr] & 0xFF;
else if (XCHARSET_DIMENSION (CHARSET_BY_LEADING_BYTE (i)) == 1)
i = (((i - FIELD2_TO_OFFICIAL_LEADING_BYTE) << 7)
CCL_WRITE_CHAR (i);
break;
+#endif
case CCL_TranslateCharacter:
#if 0
/* +1 is for including separator. */
point = -point + 1;
if (mapping_stack_pointer
- >= &mapping_stack[MAX_MAP_SET_LEVEL])
+ >= mapping_stack + countof (mapping_stack))
CCL_INVALID_CMD;
PUSH_MAPPING_STACK (map_set_rest_length - point,
reg[rrr]);
else if (SYMBOLP (content))
{
if (mapping_stack_pointer
- >= &mapping_stack[MAX_MAP_SET_LEVEL])
+ >= mapping_stack + countof (mapping_stack))
CCL_INVALID_CMD;
PUSH_MAPPING_STACK (map_set_rest_length, reg[rrr]);
PUSH_MAPPING_STACK (map_set_rest_length, op);