/* Return a hash table of id number ID. */
#define GET_HASH_TABLE(id) \
- (XHASH_TABLE (XCDR(XVECTOR(Vtranslation_hash_table_vector)->contents[(id)])))
+ (XHASH_TABLE (XCDR (XVECTOR (Vtranslation_hash_table_vector)->contents[(id)])))
/* CCL (Code Conversion Language) is a simple language which has
operations on one input buffer, one output buffer, and 7 registers.
#define CCL_Extension 0x1F /* Extended CCL code
1:ExtendedCOMMNDRrrRRRrrrXXXXX
- 2:ARGUEMENT
+ 2:ARGUMENT
3:...
------------------------------
extended_command (rrr,RRR,Rrr,ARGS)
ccl->status = CCL_STAT_SUCCESS; \
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
ccl->status = CCL_STAT_INVALID_CMD; \
goto ccl_error_handler; \
} \
-while(0)
+while (0)
#else
ccl->status = CCL_STAT_INVALID_CMD; \
goto ccl_error_handler; \
} \
-while(0)
+while (0)
#endif
else if (INTEGERP (content) && IN_INT_RANGE (XINT (content)))
{
reg[RRR] = i;
- reg[rrr] = XINT(content);
+ reg[rrr] = XINT (content);
break;
}
else if (EQ (content, Qt) || EQ (content, Qlambda))
value = XCDR (content);
if (!INTEGERP (attrib) || !INTEGERP (value))
continue;
- reg[rrr] = XINT(value);
+ reg[rrr] = XINT (value);
break;
}
else if (SYMBOLP (content))
switch (ccl->status)
{
case CCL_STAT_INVALID_CMD:
- sprintf(msg, "\nCCL: Invalid command %x (ccl_code = %x) at %d.",
- code & 0x1F, code, this_ic);
+ sprintf (msg, "\nCCL: Invalid command %x (ccl_code = %x) at %d.",
+ code & 0x1F, code, this_ic);
#ifdef CCL_DEBUG
{
int i = ccl_backtrace_idx - 1;
if (i < 0) i = CCL_DEBUG_BACKTRACE_LEN - 1;
if (ccl_backtrace_table[i] == 0)
break;
- sprintf(msg, " %d", ccl_backtrace_table[i]);
+ sprintf (msg, " %d", ccl_backtrace_table[i]);
msglen = strlen (msg);
if (dst + msglen > (dst_bytes ? dst_end : src))
break;
case CCL_STAT_QUIT:
if (! ccl->quit_silently)
- sprintf(msg, "\nCCL: Quited.");
+ sprintf (msg, "\nCCL: Quited.");
break;
default:
- sprintf(msg, "\nCCL: Unknown error type (%d)", ccl->status);
+ sprintf (msg, "\nCCL: Unknown error type (%d)", ccl->status);
}
msglen = strlen (msg);
- if (dst + msglen <= dst_end)
+ if (msglen <= dst_end - dst)
{
for (i = 0; i < msglen; i++)
*dst++ = msg[i];
src_size = j;
while (1)
{
+ int max_expansion = NILP (unibyte_p) ? MAX_MULTIBYTE_LENGTH : 1;
+ ptrdiff_t offset, shortfall;
ccl_driver (&ccl, src, destination, src_size, CCL_EXECUTE_BUF_SIZE,
Qnil);
produced_chars += ccl.produced;
+ offset = outp - outbuf;
+ shortfall = ccl.produced * max_expansion - (outbufsize - offset);
+ if (0 < shortfall)
+ {
+ outbuf = xpalloc (outbuf, &outbufsize, shortfall, -1, 1);
+ outp = outbuf + offset;
+ }
if (NILP (unibyte_p))
{
- /* FIXME: Surely this should be buf_magnification instead.
- MAX_MULTIBYTE_LENGTH overestimates the storage needed. */
- int magnification = MAX_MULTIBYTE_LENGTH;
-
- ptrdiff_t offset = outp - outbuf;
- ptrdiff_t shortfall;
- if (INT_MULTIPLY_OVERFLOW (ccl.produced, magnification))
- memory_full (SIZE_MAX);
- shortfall = ccl.produced * magnification - (outbufsize - offset);
- if (0 < shortfall)
- {
- outbuf = xpalloc (outbuf, &outbufsize, shortfall, -1, 1);
- outp = outbuf + offset;
- }
for (j = 0; j < ccl.produced; j++)
CHAR_STRING_ADVANCE (destination[j], outp);
}
else
{
- ptrdiff_t offset = outp - outbuf;
- ptrdiff_t shortfall = ccl.produced - (outbufsize - offset);
- if (0 < shortfall)
- {
- outbuf = xpalloc (outbuf, &outbufsize, shortfall, -1, 1);
- outp = outbuf + offset;
- }
for (j = 0; j < ccl.produced; j++)
*outp++ = destination[j];
}