aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
authorKenichi Handa1998-09-25 07:32:05 +0000
committerKenichi Handa1998-09-25 07:32:05 +0000
commitfdfcf19d011ff49e5191da329e992150c89b05b7 (patch)
tree6408bdd4d60c46bbf93db70a833e28c8190c87bf /src/coding.c
parentf695b4b18a5c2c9a55e3a87167278f3e582505ff (diff)
downloademacs-fdfcf19d011ff49e5191da329e992150c89b05b7.tar.gz
emacs-fdfcf19d011ff49e5191da329e992150c89b05b7.zip
(decode_eol): While decoding DOS-like eol, handle a
single CR code correctly. (shrink_decoding_region) <CODING_CATEGORY_IDX_ISO_7 or CODING_CATEGORY_IDX_ISO_7_TIGHT>: Skip also 8-bit codes.
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/src/coding.c b/src/coding.c
index 47268d340bf..fa2bbc620a0 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -2529,18 +2529,20 @@ decode_eol (coding, source, destination, src_bytes, dst_bytes)
2529 if (c == '\r') 2529 if (c == '\r')
2530 { 2530 {
2531 ONE_MORE_BYTE (c); 2531 ONE_MORE_BYTE (c);
2532 if (c != '\n') 2532 if (c == '\n')
2533 *dst++ = c;
2534 else
2533 { 2535 {
2534 if (coding->mode & CODING_MODE_INHIBIT_INCONSISTENT_EOL) 2536 if (coding->mode & CODING_MODE_INHIBIT_INCONSISTENT_EOL)
2535 { 2537 {
2536 result = CODING_FINISH_INCONSISTENT_EOL; 2538 result = CODING_FINISH_INCONSISTENT_EOL;
2537 goto label_end_of_loop_2; 2539 goto label_end_of_loop_2;
2538 } 2540 }
2541 src--;
2539 *dst++ = '\r'; 2542 *dst++ = '\r';
2540 if (BASE_LEADING_CODE_P (c)) 2543 if (BASE_LEADING_CODE_P (c))
2541 coding->fake_multibyte = 1; 2544 coding->fake_multibyte = 1;
2542 } 2545 }
2543 *dst++ = c;
2544 } 2546 }
2545 else if (c == '\n' 2547 else if (c == '\n'
2546 && (coding->mode & CODING_MODE_INHIBIT_INCONSISTENT_EOL)) 2548 && (coding->mode & CODING_MODE_INHIBIT_INCONSISTENT_EOL))
@@ -2562,9 +2564,23 @@ decode_eol (coding, source, destination, src_bytes, dst_bytes)
2562 src = src_base; 2564 src = src_base;
2563 break; 2565 break;
2564 } 2566 }
2565 if (result == CODING_FINISH_NORMAL 2567 if (src < src_end)
2566 && src < src_end) 2568 {
2567 result = CODING_FINISH_INSUFFICIENT_DST; 2569 if (result == CODING_FINISH_NORMAL)
2570 result = CODING_FINISH_INSUFFICIENT_DST;
2571 else if (result != CODING_FINISH_INCONSISTENT_EOL
2572 && coding->mode & CODING_MODE_LAST_BLOCK)
2573 {
2574 /* This is the last block of the text to be decoded.
2575 We flush out all remaining codes. */
2576 src_bytes = src_end - src;
2577 if (dst_bytes && (dst_end - dst < src_bytes))
2578 src_bytes = dst_end - dst;
2579 bcopy (src, dst, src_bytes);
2580 dst += src_bytes;
2581 src += src_bytes;
2582 }
2583 }
2568 } 2584 }
2569 break; 2585 break;
2570 2586
@@ -3926,11 +3942,11 @@ shrink_decoding_region (beg, end, coding, str)
3926 the following 2-byte at the tail. */ 3942 the following 2-byte at the tail. */
3927 if (eol_conversion) 3943 if (eol_conversion)
3928 while (begp < endp 3944 while (begp < endp
3929 && (c = endp[-1]) < 0x80 && c != ISO_CODE_ESC && c != '\r') 3945 && (c = endp[-1]) != ISO_CODE_ESC && c != '\r')
3930 endp--; 3946 endp--;
3931 else 3947 else
3932 while (begp < endp 3948 while (begp < endp
3933 && (c = endp[-1]) < 0x80 && c != ISO_CODE_ESC) 3949 && (c = endp[-1]) != ISO_CODE_ESC)
3934 endp--; 3950 endp--;
3935 /* Do not consider LF as ascii if preceded by CR, since that 3951 /* Do not consider LF as ascii if preceded by CR, since that
3936 confuses eol decoding. */ 3952 confuses eol decoding. */