/* CCL (Code Conversion Language) interpreter.
Copyright (C) 1995, 1997 Electrotechnical Laboratory, JAPAN.
- Copyright (C) 2001 Free Software Foundation, Inc.
- Licensed to the Free Software Foundation.
- Copyright (C) 2001, 2002
+ Licensed to the Free Software Foundation.
+ Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 2003
National Institute of Advanced Industrial Science and Technology (AIST)
Registration Number H13PRO009
/* Return a hash table of id number ID. */
#define GET_HASH_TABLE(id) \
(XHASH_TABLE (XCDR(XVECTOR(Vtranslation_hash_table_vector)->contents[(id)])))
-/* Copied from fns.c. */
-#define HASH_VALUE(H, IDX) AREF ((H)->key_and_value, 2 * (IDX) + 1)
extern int charset_unicode;
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).
3:MAP-ID1
4:MAP-ID2
...
- */
+ */
/* Map the code in reg[rrr] by MAPs starting from the Nth (N =
reg[RRR]) map.
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
((id) == 0 ? (code) \
: (charset = CHARSET_FROM_ID ((id)), DECODE_CHAR (charset, (code))))
-
/* Encode character C by some of charsets in CHARSET_LIST. Set ID to
the id of the used charset, ENCODED to the resulf of encoding.
Assume that we can use the variable `charset'. */
-#define CCL_ENCODE_CHAR(c, charset_list, id, encoded) \
- do { \
- unsigned code; \
- \
- charset = char_charset ((c), (charset_list), &code); \
- if (! charset && ! NILP (charset_list)) \
- charset = char_charset ((c), Qnil, &code); \
- if (charset) \
- { \
- (id) = CHARSET_ID (charset); \
- (encoded) = code; \
- } \
- } while (0)
-
-
+#define CCL_ENCODE_CHAR(c, charset_list, id, encoded) \
+ do { \
+ unsigned code; \
+ \
+ charset = char_charset ((c), (charset_list), &code); \
+ if (! charset && ! NILP (charset_list)) \
+ charset = char_charset ((c), Qnil, &code); \
+ if (charset) \
+ { \
+ (id) = CHARSET_ID (charset); \
+ (encoded) = code; \
+ } \
+ } while (0)
/* Execute CCL code on characters at SOURCE (length SRC_SIZE). The
resulting text goes to a place pointed by DESTINATION, the length
#ifdef CCL_DEBUG
#define CCL_DEBUG_BACKTRACE_LEN 256
-int ccl_backtrace_table[CCL_BACKTRACE_TABLE];
+int ccl_backtrace_table[CCL_DEBUG_BACKTRACE_LEN];
int ccl_backtrace_idx;
#endif
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];
void
}
CCL_INVALID_CMD;
}
-
+
ccl_prog_stack_struct[stack_idx].ccl_prog = ccl_prog;
ccl_prog_stack_struct[stack_idx].ic = ic;
stack_idx++;
case CCL_LookupIntConstTbl:
op = XINT (ccl_prog[ic]); /* table */
ic++;
- {
+ {
struct Lisp_Hash_Table *h = GET_HASH_TABLE (op);
op = hash_lookup (h, make_number (reg[RRR]), NULL);
if (op >= 0)
{
- Lisp_Object opl;
+ Lisp_Object opl;
opl = HASH_VALUE (h, op);
- if (!CHARACTERP (opl))
+ if (! CHARACTERP (XINT (opl)))
CCL_INVALID_CMD;
reg[RRR] = charset_unicode;
reg[rrr] = op;
op = XINT (ccl_prog[ic]); /* table */
ic++;
i = CCL_DECODE_CHAR (reg[RRR], reg[rrr]);
- {
+ {
struct Lisp_Hash_Table *h = GET_HASH_TABLE (op);
op = hash_lookup (h, make_number (i), NULL);
if (op >= 0)
{
- Lisp_Object opl;
+ Lisp_Object opl;
opl = HASH_VALUE (h, op);
if (!INTEGERP (opl))
CCL_INVALID_CMD;
else
continue;
}
- else
+ else
continue;
if (NILP (content))
ic = fin_ic;
}
break;
-
+
case CCL_MapMultiple:
{
Lisp_Object map, content, attrib, value;
}
}
map_vector_size = ASIZE (Vcode_conversion_map_vector);
-
+
do {
for (;map_set_rest_length > 0;i++, ic++, map_set_rest_length--)
{
else
continue;
}
- else
+ else
continue;
if (NILP (content))
}
}
break;
-
+
default:
CCL_INVALID_CMD;
}
for (i = 0; i < msglen; i++)
*dst++ = msg[i];
}
+
+ if (ccl->status == CCL_STAT_INVALID_CMD)
+ {
+#if 0 /* If the remaining bytes contain 0x80..0x9F, copying them
+ results in an invalid multibyte sequence. */
+
+ /* Copy the remaining source data. */
+ int i = src_end - src;
+ if (dst_bytes && (dst_end - dst) < i)
+ i = dst_end - dst;
+ bcopy (src, dst, i);
+ src += i;
+ dst += i;
+#else
+ /* Signal that we've consumed everything. */
+ src = src_end;
+#endif
+ }
}
ccl_finish:
ccl->status = 0;
ccl->stack_idx = 0;
ccl->suppress_error = 0;
+ ccl->eight_bit_control = 0;
return 0;
}
if (ASIZE (status) != 9)
error ("Length of vector STATUS is not 9");
CHECK_STRING (str);
- str_chars = XSTRING (str)->size;
- str_bytes = STRING_BYTES (XSTRING (str));
+
+ str_chars = SCHARS (str);
+ str_bytes = SBYTES (str);
for (i = 0; i < 8; i++)
{
produced_chars = 0;
while (consumed_bytes < str_bytes)
{
- const unsigned char *p = XSTRING (str)->data + consumed_bytes;
- const unsigned char *endp = XSTRING (str)->data + str_bytes;
+ const unsigned char *p = SDATA (str) + consumed_bytes;
+ const unsigned char *endp = SDATA (str) + str_bytes;
int i = 0;
int *src, src_size;
while (i < CCL_EXECUTE_BUF_SIZE && p < endp)
source[i++] = STRING_CHAR_ADVANCE (p);
consumed_chars += i;
- consumed_bytes = p - XSTRING (str)->data;
+ consumed_bytes = p - SDATA (str);
if (consumed_bytes == str_bytes)
ccl.last_block = NILP (contin);
if (ccl.status != CCL_STAT_SUSPEND_BY_SRC)
break;
- }
+ }
if (ccl.status != CCL_STAT_SUCCESS
&& ccl.status != CCL_STAT_SUSPEND_BY_SRC)
error ("Error in CCL program at %dth code", ccl.ic);
-
+
for (i = 0; i < 8; i++)
XSET (XVECTOR (status)->contents[i], Lisp_Int, ccl.reg[i]);
XSETINT (XVECTOR (status)->contents[8], ccl.ic);
CHECK_SYMBOL (symbol);
CHECK_VECTOR (map);
-
+
for (i = 0; i < len; i++)
{
Lisp_Object slot = AREF (Vcode_conversion_map_vector, i);