comparison src/coding.c @ 45239:6a20d4c6bb78

(decode_coding) <coding_type_ccl>: If a lone CR characters is carried over from the previous block of text, adjust coding->produced to account for the extra character.
author Eli Zaretskii <eliz@gnu.org>
date Sat, 11 May 2002 21:32:52 +0000
parents 3bb204606957
children cab845213388
comparison
equal deleted inserted replaced
45238:193ea38d0029 45239:6a20d4c6bb78
4588 if (! (coding->mode & CODING_MODE_LAST_BLOCK) 4588 if (! (coding->mode & CODING_MODE_LAST_BLOCK)
4589 && *(pend - 1) == '\r') 4589 && *(pend - 1) == '\r')
4590 { 4590 {
4591 /* If the last character is CR, we can't handle it here 4591 /* If the last character is CR, we can't handle it here
4592 because LF will be in the not-yet-decoded source text. 4592 because LF will be in the not-yet-decoded source text.
4593 Recorded that the CR is not yet processed. */ 4593 Record that the CR is not yet processed. */
4594 coding->spec.ccl.cr_carryover = 1; 4594 coding->spec.ccl.cr_carryover = 1;
4595 coding->produced--; 4595 coding->produced--;
4596 coding->produced_char--; 4596 coding->produced_char--;
4597 pend--; 4597 pend--;
4598 } 4598 }
4684 decode_coding (coding, source, destination, src_bytes, dst_bytes) 4684 decode_coding (coding, source, destination, src_bytes, dst_bytes)
4685 struct coding_system *coding; 4685 struct coding_system *coding;
4686 unsigned char *source, *destination; 4686 unsigned char *source, *destination;
4687 int src_bytes, dst_bytes; 4687 int src_bytes, dst_bytes;
4688 { 4688 {
4689 int extra = 0;
4690
4689 if (coding->type == coding_type_undecided) 4691 if (coding->type == coding_type_undecided)
4690 detect_coding (coding, source, src_bytes); 4692 detect_coding (coding, source, src_bytes);
4691 4693
4692 if (coding->eol_type == CODING_EOL_UNDECIDED 4694 if (coding->eol_type == CODING_EOL_UNDECIDED
4693 && coding->type != coding_type_ccl) 4695 && coding->type != coding_type_ccl)
4726 break; 4728 break;
4727 4729
4728 case coding_type_ccl: 4730 case coding_type_ccl:
4729 if (coding->spec.ccl.cr_carryover) 4731 if (coding->spec.ccl.cr_carryover)
4730 { 4732 {
4731 /* Set the CR which is not processed by the previous call of 4733 /* Put the CR which was not processed by the previous call
4732 decode_eol_post_ccl in DESTINATION. */ 4734 of decode_eol_post_ccl in DESTINATION. It will be
4735 decoded together with the following LF by the call to
4736 decode_eol_post_ccl below. */
4733 *destination = '\r'; 4737 *destination = '\r';
4734 coding->produced++; 4738 coding->produced++;
4735 coding->produced_char++; 4739 coding->produced_char++;
4736 dst_bytes--; 4740 dst_bytes--;
4737 } 4741 extra = coding->spec.ccl.cr_carryover;
4738 ccl_coding_driver (coding, source, 4742 }
4739 destination + coding->spec.ccl.cr_carryover, 4743 ccl_coding_driver (coding, source, destination + extra,
4740 src_bytes, dst_bytes, 0); 4744 src_bytes, dst_bytes, 0);
4741 if (coding->eol_type != CODING_EOL_LF) 4745 if (coding->eol_type != CODING_EOL_LF)
4742 decode_eol_post_ccl (coding, destination, coding->produced); 4746 {
4747 coding->produced += extra;
4748 coding->produced_char += extra;
4749 decode_eol_post_ccl (coding, destination, coding->produced);
4750 }
4743 break; 4751 break;
4744 4752
4745 default: 4753 default:
4746 decode_eol (coding, source, destination, src_bytes, dst_bytes); 4754 decode_eol (coding, source, destination, src_bytes, dst_bytes);
4747 } 4755 }