# HG changeset patch # User Kenichi Handa # Date 906124240 0 # Node ID b4656367043fd9db49b51c3c78e4380241ac0305 # Parent ca159e828a68690ee3946ecc4ca0dfe07dd84f99 (CCL_WRITE_CHAR): Don't use bcopy. (ccl_driver): If BUFFER-MAGNIFICATION of the CCL program is 0, cause error if the program is going to output some bytes. When outputing a string to notify an error, check the case that DST_BYTES is zero. diff -r ca159e828a68 -r b4656367043f src/ccl.c --- a/src/ccl.c Fri Sep 18 13:10:40 1998 +0000 +++ b/src/ccl.c Fri Sep 18 13:10:40 1998 +0000 @@ -670,8 +670,7 @@ int len = CHAR_STRING (ch, work, str); \ if (dst + len <= (dst_bytes ? dst_end : src)) \ { \ - bcopy (str, dst, len); \ - dst += len; \ + while (len--) *dst++ = *str++; \ } \ else \ CCL_SUSPEND (CCL_STAT_SUSPEND_BY_DST); \ @@ -751,6 +750,9 @@ if (ic >= ccl->eof_ic) ic = CCL_HEADER_MAIN; + if (ccl->buf_magnification ==0) /* We can't produce any bytes. */ + dst = NULL; + #ifdef CCL_DEBUG ccl_backtrace_idx = 0; #endif @@ -1543,6 +1545,9 @@ char msg[256]; int msglen; + if (!dst) + dst = destination; + switch (ccl->status) { case CCL_STAT_INVALID_CMD: @@ -1554,7 +1559,7 @@ int j; msglen = strlen (msg); - if (dst + msglen <= dst_end) + if (dst + msglen <= (dst_bytes ? dst_end : src)) { bcopy (msg, dst, msglen); dst += msglen; @@ -1567,14 +1572,15 @@ break; sprintf(msg, " %d", ccl_backtrace_table[i]); msglen = strlen (msg); - if (dst + msglen > dst_end) + if (dst + msglen > (dst_bytes ? dst_end : src)) break; bcopy (msg, dst, msglen); dst += msglen; } + goto ccl_finish; } #endif - goto ccl_finish; + break; case CCL_STAT_QUIT: sprintf(msg, "\nCCL: Quited."); @@ -1585,7 +1591,7 @@ } msglen = strlen (msg); - if (dst + msglen <= dst_end) + if (dst + msglen <= (dst_bytes ? dst_end : src)) { bcopy (msg, dst, msglen); dst += msglen; @@ -1595,7 +1601,7 @@ ccl_finish: ccl->ic = ic; if (consumed) *consumed = src - source; - return dst - destination; + return (dst ? dst - destination : 0); } /* Setup fields of the structure pointed by CCL appropriately for the