cccccccccccccccccccc rrr XXXXX
or
|------------- constant or other args ----------------|
- cccccccccccccccccccccccccccc
+ cccccccccccccccccccccccccccc
where, `cc...c' is a non-negative integer indicating constant value
(the left most `c' is always 0) or an absolute jump address, `RRR'
r[7] = LOWER_BYTE (SJIS (Y, Z) */
/* Terminate CCL program successfully. */
-#define CCL_SUCCESS \
- do { \
+#define CCL_SUCCESS \
+ do { \
ccl->status = CCL_STAT_SUCCESS; \
/* The "if (1)" inhibits the warning \
"end-of loop code not reached" */ \
/* Terminate CCL program because of invalid command. Should not occur
in the normal case. */
-#define CCL_INVALID_CMD \
- do { \
+#define CCL_INVALID_CMD \
+ do { \
ccl->status = CCL_STAT_INVALID_CMD; \
/* The "if (1)" inhibits the warning \
"end-of loop code not reached" */ \
case CCL_SetArray: /* CCCCCCCCCCCCCCCCCCCCRRRrrrXXXXX */
i = reg[RRR];
j = field1 >> 3;
- if ((unsigned int)i < j)
+ if (i < j)
reg[rrr] = XINT(ccl_prog[ic + i]);
ic += j;
break;
case CCL_WriteArrayReadJump: /* A--D--D--R--E--S--S-rrrXXXXX */
i = reg[rrr];
j = XINT(ccl_prog[ic]);
- if ((unsigned int)i < j) {
+ if (i < j) {
i = XINT(ccl_prog[ic + 1 + i]);
CCL_WRITE_CHAR(i);
}
CCL_READ_CHAR(reg[rrr]);
/* fall through ... */
case CCL_Branch: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */
- if ((unsigned int)reg[rrr] < field1)
+ if (reg[rrr] < field1)
ic += XINT(ccl_prog[ic + reg[rrr]]);
else
ic += XINT(ccl_prog[ic + field1]);
case CCL_WriteArray: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */
i = reg[rrr];
- if ((unsigned int)i < field1) {
+ if (i < field1) {
j = XINT(ccl_prog[ic + i]);
CCL_WRITE_CHAR(j);
}
specified and we still have a room to store the message
there. */
char msg[256];
-
+ int sz;
switch (ccl->status) {
case CCL_STAT_INVALID_CMD:
- sprintf(msg,
- "\nCCL: Invalid command %x (ccl_code = %x) at %d.",
- code & 0x1F, code, this_ic);
+ sz = snprintf(msg, sizeof(msg),
+ "\nCCL: Invalid command %x (ccl_code = %x) at %d.",
+ code & 0x1F, code, this_ic);
+ assert(sz >= 0 && sz < sizeof(msg));
#ifdef CCL_DEBUG
{
int i = ccl_backtrace_idx - 1;
i = CCL_DEBUG_BACKTRACE_LEN - 1;
if (ccl_backtrace_table[i] == 0)
break;
- sprintf(msg, " %d",
- ccl_backtrace_table[i]);
+ sz = snprintf(msg, sizeof(msg), " %d",
+ ccl_backtrace_table[i]);
+ assert(sz >= 0 && sz < sizeof(msg));
Dynarr_add_many(destination,
(unsigned char *)msg,
strlen(msg));
break;
case CCL_STAT_QUIT:
- sprintf(msg, "\nCCL: Exited.");
+ sz = snprintf(msg, sizeof(msg), "\nCCL: Exited.");
+ assert(sz >= 0 && sz < sizeof(msg));
break;
default:
- sprintf(msg, "\nCCL: Unknown error type (%d).",
- ccl->status);
+ sz = snprintf(msg, sizeof(msg), "\nCCL: Unknown error type (%d).",
+ ccl->status);
+ assert(sz >= 0 && sz < sizeof(msg));
}
Dynarr_add_many(destination, (unsigned char *)msg, strlen(msg));