aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
authorKenichi Handa1998-06-20 03:01:00 +0000
committerKenichi Handa1998-06-20 03:01:00 +0000
commitca65341ea8fd2488586ddde61380022e5b125551 (patch)
tree3ef1ff84055226d8594b82225589954be73a518b /src/process.c
parenta9a5b0a53c0c91b5025aa806557803e136501ac3 (diff)
downloademacs-ca65341ea8fd2488586ddde61380022e5b125551.tar.gz
emacs-ca65341ea8fd2488586ddde61380022e5b125551.zip
(read_process_output): Handle carryover correctly.
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/process.c b/src/process.c
index 305a6780e41..a9355968590 100644
--- a/src/process.c
+++ b/src/process.c
@@ -2833,6 +2833,8 @@ read_process_output (proc, channel)
2833 chars = buf; 2833 chars = buf;
2834#endif /* not VMS */ 2834#endif /* not VMS */
2835 2835
2836 XSETINT (p->decoding_carryover, 0);
2837
2836 /* At this point, NBYTES holds number of characters just received 2838 /* At this point, NBYTES holds number of characters just received
2837 (including the one in proc_buffered_char[channel]). */ 2839 (including the one in proc_buffered_char[channel]). */
2838 if (nbytes <= 0) return nbytes; 2840 if (nbytes <= 0) return nbytes;
@@ -2851,6 +2853,18 @@ read_process_output (proc, channel)
2851 result = decode_coding (coding, chars, XSTRING (p->decoding_buf)->data, 2853 result = decode_coding (coding, chars, XSTRING (p->decoding_buf)->data,
2852 nbytes, STRING_BYTES (XSTRING (p->decoding_buf))); 2854 nbytes, STRING_BYTES (XSTRING (p->decoding_buf)));
2853 carryover = nbytes - coding->consumed; 2855 carryover = nbytes - coding->consumed;
2856 if (carryover > 0)
2857 {
2858 /* We must move the data carried over to the tail of
2859 decoding buffer. We are sure that the size of decoding
2860 buffer (decided by decoding_buffer_size) is large enough
2861 to contain them. */
2862 bcopy (chars + nbytes - carryover,
2863 (XSTRING (p->decoding_buf)->data
2864 + STRING_BYTES (XSTRING (p->decoding_buf)) - carryover),
2865 carryover);
2866 XSETINT (p->decoding_carryover, carryover);
2867 }
2854 2868
2855 /* A new coding system might be found by `decode_coding'. */ 2869 /* A new coding system might be found by `decode_coding'. */
2856 if (!EQ (p->decode_coding_system, coding->symbol)) 2870 if (!EQ (p->decode_coding_system, coding->symbol))
@@ -2904,11 +2918,9 @@ read_process_output (proc, channel)
2904 chars = XSTRING (p->decoding_buf)->data; 2918 chars = XSTRING (p->decoding_buf)->data;
2905 nchars = multibyte_chars_in_text (chars, nbytes); 2919 nchars = multibyte_chars_in_text (chars, nbytes);
2906 chars_in_decoding_buf = 1; 2920 chars_in_decoding_buf = 1;
2907 carryover = 0;
2908 } 2921 }
2909#endif 2922#endif
2910 2923
2911 XSETINT (p->decoding_carryover, carryover);
2912 Vlast_coding_system_used = coding->symbol; 2924 Vlast_coding_system_used = coding->symbol;
2913 2925
2914 /* If the caller required, let the process associated buffer 2926 /* If the caller required, let the process associated buffer