2011-05-23 Paul Eggert <eggert@cs.ucla.edu>
+ * ccl.c (ccl_driver): Redo slightly to avoid the need for 'unsigned'.
+
ccl: add integer overflow checks
* ccl.c (CCL_CODE_MAX, GET_CCL_RANGE, GET_CCL_CODE, GET_CCL_INT):
(IN_INT_RANGE): New macros.
case CCL_SetArray: /* CCCCCCCCCCCCCCCCCCCCRRRrrrXXXXX */
i = reg[RRR];
j = field1 >> 3;
- if ((unsigned int) i < j)
+ if (0 <= i && i < j)
GET_CCL_INT (reg[rrr], ccl_prog, ic + i);
ic += j;
break;
case CCL_WriteArrayReadJump: /* A--D--D--R--E--S--S-rrrXXXXX */
i = reg[rrr];
GET_CCL_INT (j, ccl_prog, ic);
- if ((unsigned int) i < j)
+ if (0 <= i && i < j)
{
GET_CCL_INT (i, ccl_prog, ic + 1 + i);
CCL_WRITE_CHAR (i);
{
int incr;
GET_CCL_INT (incr, ccl_prog,
- ic + ((unsigned int) reg[rrr] < field1
+ ic + (0 <= reg[rrr] && reg[rrr] < field1
? reg[rrr]
: field1));
ic += incr;
case CCL_WriteArray: /* CCCCCCCCCCCCCCCCCCCCrrrXXXXX */
i = reg[rrr];
- if ((unsigned int) i < field1)
+ if (0 <= i && i < field1)
{
GET_CCL_INT (j, ccl_prog, ic + i);
CCL_WRITE_CHAR (j);