diff options
| author | Richard M. Stallman | 1998-04-24 01:05:25 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-04-24 01:05:25 +0000 |
| commit | ee59c65fd03eb52630e689916844423a32e77359 (patch) | |
| tree | 98b6eabeacd85977a1de3a550fddc4d19ac02581 /src/coding.c | |
| parent | 912aace821c8fe9d4a0af95540c29ba842011e4a (diff) | |
| download | emacs-ee59c65fd03eb52630e689916844423a32e77359.tar.gz emacs-ee59c65fd03eb52630e689916844423a32e77359.zip | |
(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.
Diffstat (limited to 'src/coding.c')
| -rw-r--r-- | src/coding.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/coding.c b/src/coding.c index 4dc4f68143f..09d0ec68de0 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -3782,8 +3782,12 @@ shrink_decoding_region (beg, end, coding, str) | |||
| 3782 | { | 3782 | { |
| 3783 | if (coding->heading_ascii < 0) | 3783 | if (coding->heading_ascii < 0) |
| 3784 | while (begp < endp && *begp != '\r' && *begp < 0x80) begp++; | 3784 | while (begp < endp && *begp != '\r' && *begp < 0x80) begp++; |
| 3785 | while (begp < endp && *(endp - 1) != '\r' && *(endp - 1) < 0x80) | 3785 | while (begp < endp && endp[-1] != '\r' && endp[-1] < 0x80) |
| 3786 | endp--; | 3786 | endp--; |
| 3787 | /* Do not consider LF as ascii if preceded by CR, since that | ||
| 3788 | confuses eol decoding. */ | ||
| 3789 | if (begp < endp && endp < endp_orig && endp[-1] == '\r' && endp[0] == '\n') | ||
| 3790 | endp++; | ||
| 3787 | } | 3791 | } |
| 3788 | else | 3792 | else |
| 3789 | begp = endp; | 3793 | begp = endp; |
| @@ -3805,6 +3809,10 @@ shrink_decoding_region (beg, end, coding, str) | |||
| 3805 | while (begp < endp && endp[-1] < 0x80 && endp[-1] != '\r') endp--; | 3809 | while (begp < endp && endp[-1] < 0x80 && endp[-1] != '\r') endp--; |
| 3806 | else | 3810 | else |
| 3807 | while (begp < endp && endp[-1] < 0x80) endp--; | 3811 | while (begp < endp && endp[-1] < 0x80) endp--; |
| 3812 | /* Do not consider LF as ascii if preceded by CR, since that | ||
| 3813 | confuses eol decoding. */ | ||
| 3814 | if (begp < endp && endp < endp_orig && endp[-1] == '\r' && endp[0] == '\n') | ||
| 3815 | endp++; | ||
| 3808 | if (begp < endp && endp < endp_orig && endp[-1] >= 0x80) | 3816 | if (begp < endp && endp < endp_orig && endp[-1] >= 0x80) |
| 3809 | endp++; | 3817 | endp++; |
| 3810 | break; | 3818 | break; |
| @@ -3829,6 +3837,10 @@ shrink_decoding_region (beg, end, coding, str) | |||
| 3829 | while (begp < endp && (c = endp[-1]) < 0x80 && c != '\r') endp--; | 3837 | while (begp < endp && (c = endp[-1]) < 0x80 && c != '\r') endp--; |
| 3830 | else | 3838 | else |
| 3831 | while (begp < endp && endp[-1] < 0x80) endp--; | 3839 | while (begp < endp && endp[-1] < 0x80) endp--; |
| 3840 | /* Do not consider LF as ascii if preceded by CR, since that | ||
| 3841 | confuses eol decoding. */ | ||
| 3842 | if (begp < endp && endp < endp_orig && endp[-1] == '\r' && endp[0] == '\n') | ||
| 3843 | endp++; | ||
| 3832 | break; | 3844 | break; |
| 3833 | 3845 | ||
| 3834 | case CODING_CATEGORY_IDX_ISO_7: | 3846 | case CODING_CATEGORY_IDX_ISO_7: |
| @@ -3843,6 +3855,10 @@ shrink_decoding_region (beg, end, coding, str) | |||
| 3843 | while (begp < endp | 3855 | while (begp < endp |
| 3844 | && (c = endp[-1]) < 0x80 && c != ISO_CODE_ESC) | 3856 | && (c = endp[-1]) < 0x80 && c != ISO_CODE_ESC) |
| 3845 | endp--; | 3857 | endp--; |
| 3858 | /* Do not consider LF as ascii if preceded by CR, since that | ||
| 3859 | confuses eol decoding. */ | ||
| 3860 | if (begp < endp && endp < endp_orig && endp[-1] == '\r' && endp[0] == '\n') | ||
| 3861 | endp++; | ||
| 3846 | if (begp < endp && endp[-1] == ISO_CODE_ESC) | 3862 | if (begp < endp && endp[-1] == ISO_CODE_ESC) |
| 3847 | { | 3863 | { |
| 3848 | if (endp + 1 < endp_orig && end[0] == '(' && end[1] == 'B') | 3864 | if (endp + 1 < endp_orig && end[0] == '(' && end[1] == 'B') |
| @@ -4222,7 +4238,7 @@ code_convert_region (from, from_byte, to, to_byte, coding, encodep, replace) | |||
| 4222 | inserted += len_byte; | 4238 | inserted += len_byte; |
| 4223 | inserted_byte += len_byte; | 4239 | inserted_byte += len_byte; |
| 4224 | while (len_byte--) | 4240 | while (len_byte--) |
| 4225 | *src++ = *dst++; | 4241 | *dst++ = *src++; |
| 4226 | fake_multibyte = 1; | 4242 | fake_multibyte = 1; |
| 4227 | break; | 4243 | break; |
| 4228 | } | 4244 | } |