diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ccl.c | 14 |
1 files changed, 13 insertions, 1 deletions
| @@ -669,11 +669,22 @@ static tr_stack *mapping_stack_pointer; | |||
| 669 | #define CCL_WRITE_CHAR(ch) \ | 669 | #define CCL_WRITE_CHAR(ch) \ |
| 670 | do { \ | 670 | do { \ |
| 671 | int bytes = SINGLE_BYTE_CHAR_P (ch) ? 1: CHAR_BYTES (ch); \ | 671 | int bytes = SINGLE_BYTE_CHAR_P (ch) ? 1: CHAR_BYTES (ch); \ |
| 672 | if (ch == '\n' && ccl->eol_type == CODING_EOL_CRLF) \ | ||
| 673 | bytes++; \ | ||
| 672 | if (!dst) \ | 674 | if (!dst) \ |
| 673 | CCL_INVALID_CMD; \ | 675 | CCL_INVALID_CMD; \ |
| 674 | else if (dst + bytes <= (dst_bytes ? dst_end : src)) \ | 676 | else if (dst + bytes <= (dst_bytes ? dst_end : src)) \ |
| 675 | { \ | 677 | { \ |
| 676 | if (bytes == 1) \ | 678 | if (ch == '\n') \ |
| 679 | { \ | ||
| 680 | if (ccl->eol_type == CODING_EOL_CRLF) \ | ||
| 681 | *dst++ = '\r', *dst++ = '\n'; \ | ||
| 682 | else if (ccl->eol_type == CODING_EOL_CR) \ | ||
| 683 | *dst++ = '\r'; \ | ||
| 684 | else \ | ||
| 685 | *dst++ = '\n'; \ | ||
| 686 | } \ | ||
| 687 | else if (bytes == 1) \ | ||
| 677 | *dst++ = (ch); \ | 688 | *dst++ = (ch); \ |
| 678 | else \ | 689 | else \ |
| 679 | dst += CHAR_STRING (ch, dst); \ | 690 | dst += CHAR_STRING (ch, dst); \ |
| @@ -1755,6 +1766,7 @@ setup_ccl_program (ccl, ccl_prog) | |||
| 1755 | ccl->private_state = 0; | 1766 | ccl->private_state = 0; |
| 1756 | ccl->status = 0; | 1767 | ccl->status = 0; |
| 1757 | ccl->stack_idx = 0; | 1768 | ccl->stack_idx = 0; |
| 1769 | ccl->eol_type = CODING_EOL_LF; | ||
| 1758 | return 0; | 1770 | return 0; |
| 1759 | } | 1771 | } |
| 1760 | 1772 | ||