diff options
| author | Kenichi Handa | 1998-09-18 13:10:40 +0000 |
|---|---|---|
| committer | Kenichi Handa | 1998-09-18 13:10:40 +0000 |
| commit | 12abd7d10f3c1130a59732b01eab70c38e294f93 (patch) | |
| tree | 6d6424e39a8cd2c919cefaef7cefd713bfaa7759 /src | |
| parent | 9864ebcee4638bddc1f0ffb4a0742713c5024318 (diff) | |
| download | emacs-12abd7d10f3c1130a59732b01eab70c38e294f93.tar.gz emacs-12abd7d10f3c1130a59732b01eab70c38e294f93.zip | |
(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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ccl.c | 20 |
1 files changed, 13 insertions, 7 deletions
| @@ -670,8 +670,7 @@ static tr_stack *mapping_stack_pointer; | |||
| 670 | int len = CHAR_STRING (ch, work, str); \ | 670 | int len = CHAR_STRING (ch, work, str); \ |
| 671 | if (dst + len <= (dst_bytes ? dst_end : src)) \ | 671 | if (dst + len <= (dst_bytes ? dst_end : src)) \ |
| 672 | { \ | 672 | { \ |
| 673 | bcopy (str, dst, len); \ | 673 | while (len--) *dst++ = *str++; \ |
| 674 | dst += len; \ | ||
| 675 | } \ | 674 | } \ |
| 676 | else \ | 675 | else \ |
| 677 | CCL_SUSPEND (CCL_STAT_SUSPEND_BY_DST); \ | 676 | CCL_SUSPEND (CCL_STAT_SUSPEND_BY_DST); \ |
| @@ -751,6 +750,9 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed) | |||
| 751 | if (ic >= ccl->eof_ic) | 750 | if (ic >= ccl->eof_ic) |
| 752 | ic = CCL_HEADER_MAIN; | 751 | ic = CCL_HEADER_MAIN; |
| 753 | 752 | ||
| 753 | if (ccl->buf_magnification ==0) /* We can't produce any bytes. */ | ||
| 754 | dst = NULL; | ||
| 755 | |||
| 754 | #ifdef CCL_DEBUG | 756 | #ifdef CCL_DEBUG |
| 755 | ccl_backtrace_idx = 0; | 757 | ccl_backtrace_idx = 0; |
| 756 | #endif | 758 | #endif |
| @@ -1543,6 +1545,9 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed) | |||
| 1543 | char msg[256]; | 1545 | char msg[256]; |
| 1544 | int msglen; | 1546 | int msglen; |
| 1545 | 1547 | ||
| 1548 | if (!dst) | ||
| 1549 | dst = destination; | ||
| 1550 | |||
| 1546 | switch (ccl->status) | 1551 | switch (ccl->status) |
| 1547 | { | 1552 | { |
| 1548 | case CCL_STAT_INVALID_CMD: | 1553 | case CCL_STAT_INVALID_CMD: |
| @@ -1554,7 +1559,7 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed) | |||
| 1554 | int j; | 1559 | int j; |
| 1555 | 1560 | ||
| 1556 | msglen = strlen (msg); | 1561 | msglen = strlen (msg); |
| 1557 | if (dst + msglen <= dst_end) | 1562 | if (dst + msglen <= (dst_bytes ? dst_end : src)) |
| 1558 | { | 1563 | { |
| 1559 | bcopy (msg, dst, msglen); | 1564 | bcopy (msg, dst, msglen); |
| 1560 | dst += msglen; | 1565 | dst += msglen; |
| @@ -1567,14 +1572,15 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed) | |||
| 1567 | break; | 1572 | break; |
| 1568 | sprintf(msg, " %d", ccl_backtrace_table[i]); | 1573 | sprintf(msg, " %d", ccl_backtrace_table[i]); |
| 1569 | msglen = strlen (msg); | 1574 | msglen = strlen (msg); |
| 1570 | if (dst + msglen > dst_end) | 1575 | if (dst + msglen > (dst_bytes ? dst_end : src)) |
| 1571 | break; | 1576 | break; |
| 1572 | bcopy (msg, dst, msglen); | 1577 | bcopy (msg, dst, msglen); |
| 1573 | dst += msglen; | 1578 | dst += msglen; |
| 1574 | } | 1579 | } |
| 1580 | goto ccl_finish; | ||
| 1575 | } | 1581 | } |
| 1576 | #endif | 1582 | #endif |
| 1577 | goto ccl_finish; | 1583 | break; |
| 1578 | 1584 | ||
| 1579 | case CCL_STAT_QUIT: | 1585 | case CCL_STAT_QUIT: |
| 1580 | sprintf(msg, "\nCCL: Quited."); | 1586 | sprintf(msg, "\nCCL: Quited."); |
| @@ -1585,7 +1591,7 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed) | |||
| 1585 | } | 1591 | } |
| 1586 | 1592 | ||
| 1587 | msglen = strlen (msg); | 1593 | msglen = strlen (msg); |
| 1588 | if (dst + msglen <= dst_end) | 1594 | if (dst + msglen <= (dst_bytes ? dst_end : src)) |
| 1589 | { | 1595 | { |
| 1590 | bcopy (msg, dst, msglen); | 1596 | bcopy (msg, dst, msglen); |
| 1591 | dst += msglen; | 1597 | dst += msglen; |
| @@ -1595,7 +1601,7 @@ ccl_driver (ccl, source, destination, src_bytes, dst_bytes, consumed) | |||
| 1595 | ccl_finish: | 1601 | ccl_finish: |
| 1596 | ccl->ic = ic; | 1602 | ccl->ic = ic; |
| 1597 | if (consumed) *consumed = src - source; | 1603 | if (consumed) *consumed = src - source; |
| 1598 | return dst - destination; | 1604 | return (dst ? dst - destination : 0); |
| 1599 | } | 1605 | } |
| 1600 | 1606 | ||
| 1601 | /* Setup fields of the structure pointed by CCL appropriately for the | 1607 | /* Setup fields of the structure pointed by CCL appropriately for the |