comparison src/process.c @ 22523:b02a5ea8cf93

(read_process_output): Handle carryover correctly.
author Kenichi Handa <handa@m17n.org>
date Sat, 20 Jun 1998 03:01:00 +0000
parents bb9dd4758e7e
children fd9324c5a498
comparison
equal deleted inserted replaced
22522:f56d8440c0a4 22523:b02a5ea8cf93
2831 nbytes = nbytes + 1; 2831 nbytes = nbytes + 1;
2832 } 2832 }
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;
2839 2841
2840 /* Now set NBYTES how many bytes we must decode. */ 2842 /* Now set NBYTES how many bytes we must decode. */
2849 if (STRING_BYTES (XSTRING (p->decoding_buf)) < require) 2851 if (STRING_BYTES (XSTRING (p->decoding_buf)) < require)
2850 p->decoding_buf = make_uninit_string (require); 2852 p->decoding_buf = make_uninit_string (require);
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))
2857 { 2871 {
2858 p->decode_coding_system = coding->symbol; 2872 p->decode_coding_system = coding->symbol;
2902 bcopy (chars, XSTRING (p->decoding_buf)->data, nbytes); 2916 bcopy (chars, XSTRING (p->decoding_buf)->data, nbytes);
2903 free (chars); 2917 free (chars);
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; 2921 }
2908 } 2922 #endif
2909 #endif 2923
2910
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
2915 inherit the coding-system used to decode the process output. */ 2927 inherit the coding-system used to decode the process output. */
2916 if (! NILP (p->inherit_coding_system_flag) 2928 if (! NILP (p->inherit_coding_system_flag)