# HG changeset patch # User Richard M. Stallman # Date 893379925 0 # Node ID 64c815fe1bdcb9023b5e85088223ec86a09a0e3a # Parent 8def8352160640878efe57f72a86556e469f8bbf (shrink_decoding_region): Do not consider LF as ascii if preceded by CR, since that confuses eol decoding. (code_convert_region): When conversion fails with CODING_FINISH_INSUFFICIENT_SRC, was overwriting src with garbage from dst instead of copying from src to dst. diff -r 8def83521606 -r 64c815fe1bdc src/coding.c --- a/src/coding.c Fri Apr 24 00:03:56 1998 +0000 +++ b/src/coding.c Fri Apr 24 01:05:25 1998 +0000 @@ -3782,8 +3782,12 @@ { if (coding->heading_ascii < 0) while (begp < endp && *begp != '\r' && *begp < 0x80) begp++; - while (begp < endp && *(endp - 1) != '\r' && *(endp - 1) < 0x80) + while (begp < endp && endp[-1] != '\r' && endp[-1] < 0x80) endp--; + /* Do not consider LF as ascii if preceded by CR, since that + confuses eol decoding. */ + if (begp < endp && endp < endp_orig && endp[-1] == '\r' && endp[0] == '\n') + endp++; } else begp = endp; @@ -3805,6 +3809,10 @@ while (begp < endp && endp[-1] < 0x80 && endp[-1] != '\r') endp--; else while (begp < endp && endp[-1] < 0x80) endp--; + /* Do not consider LF as ascii if preceded by CR, since that + confuses eol decoding. */ + if (begp < endp && endp < endp_orig && endp[-1] == '\r' && endp[0] == '\n') + endp++; if (begp < endp && endp < endp_orig && endp[-1] >= 0x80) endp++; break; @@ -3829,6 +3837,10 @@ while (begp < endp && (c = endp[-1]) < 0x80 && c != '\r') endp--; else while (begp < endp && endp[-1] < 0x80) endp--; + /* Do not consider LF as ascii if preceded by CR, since that + confuses eol decoding. */ + if (begp < endp && endp < endp_orig && endp[-1] == '\r' && endp[0] == '\n') + endp++; break; case CODING_CATEGORY_IDX_ISO_7: @@ -3843,6 +3855,10 @@ while (begp < endp && (c = endp[-1]) < 0x80 && c != ISO_CODE_ESC) endp--; + /* Do not consider LF as ascii if preceded by CR, since that + confuses eol decoding. */ + if (begp < endp && endp < endp_orig && endp[-1] == '\r' && endp[0] == '\n') + endp++; if (begp < endp && endp[-1] == ISO_CODE_ESC) { if (endp + 1 < endp_orig && end[0] == '(' && end[1] == 'B') @@ -4222,7 +4238,7 @@ inserted += len_byte; inserted_byte += len_byte; while (len_byte--) - *src++ = *dst++; + *dst++ = *src++; fake_multibyte = 1; break; }