comparison src/process.c @ 29017:8f10362eb5ff

(Fstart_process): GCPRO current_dir before calling Ffind_operation_coding_system. Encode arguments here. (create_process): Don't encode arguments here. Setup src_multibyte and dst_multibyte members of struct coding. (read_process_output): Setup src_multibyte and dst_multibyte members of struct coding. If the output is to multibyte buffer, always decode the output of the process. Adjust the representation of 8-bit characters to the multibyteness of the output. (send_process): Setup coding->src_multibyte according to the multibyteness of the source.
author Kenichi Handa <handa@m17n.org>
date Sat, 20 May 2000 00:04:37 +0000
parents 336858b2b11a
children 95e767e77a88
comparison
equal deleted inserted replaced
29016:35074eb2a443 29017:8f10362eb5ff
1080 1080
1081 program = args[2]; 1081 program = args[2];
1082 1082
1083 CHECK_STRING (program, 2); 1083 CHECK_STRING (program, 2);
1084 1084
1085 #ifdef VMS
1086 /* Make a one member argv with all args concatenated
1087 together separated by a blank. */
1088 len = STRING_BYTES (XSTRING (program)) + 2;
1089 for (i = 3; i < nargs; i++)
1090 {
1091 tem = args[i];
1092 CHECK_STRING (tem, i);
1093 len += STRING_BYTES (XSTRING (tem)) + 1; /* count the blank */
1094 }
1095 new_argv = (unsigned char *) alloca (len);
1096 strcpy (new_argv, XSTRING (program)->data);
1097 for (i = 3; i < nargs; i++)
1098 {
1099 tem = args[i];
1100 CHECK_STRING (tem, i);
1101 strcat (new_argv, " ");
1102 strcat (new_argv, XSTRING (tem)->data);
1103 }
1104 /* Need to add code here to check for program existence on VMS */
1105
1106 #else /* not VMS */
1107 new_argv = (unsigned char **) alloca ((nargs - 1) * sizeof (char *));
1108
1109 /* If program file name is not absolute, search our path for it */
1110 if (!IS_DIRECTORY_SEP (XSTRING (program)->data[0])
1111 && !(XSTRING (program)->size > 1
1112 && IS_DEVICE_SEP (XSTRING (program)->data[1])))
1113 {
1114 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
1115
1116 tem = Qnil;
1117 GCPRO4 (name, program, buffer, current_dir);
1118 openp (Vexec_path, program, EXEC_SUFFIXES, &tem, 1);
1119 UNGCPRO;
1120 if (NILP (tem))
1121 report_file_error ("Searching for program", Fcons (program, Qnil));
1122 tem = Fexpand_file_name (tem, Qnil);
1123 new_argv[0] = XSTRING (tem)->data;
1124 }
1125 else
1126 {
1127 if (!NILP (Ffile_directory_p (program)))
1128 error ("Specified program for new process is a directory");
1129
1130 new_argv[0] = XSTRING (program)->data;
1131 }
1132
1133 for (i = 3; i < nargs; i++)
1134 {
1135 tem = args[i];
1136 CHECK_STRING (tem, i);
1137 new_argv[i - 2] = XSTRING (tem)->data;
1138 }
1139 new_argv[i - 2] = 0;
1140 #endif /* not VMS */
1141
1142 proc = make_process (name); 1085 proc = make_process (name);
1143 /* If an error occurs and we can't start the process, we want to 1086 /* If an error occurs and we can't start the process, we want to
1144 remove it from the process list. This means that each error 1087 remove it from the process list. This means that each error
1145 check in create_process doesn't need to call remove_process 1088 check in create_process doesn't need to call remove_process
1146 itself; it's all taken care of here. */ 1089 itself; it's all taken care of here. */
1165 unibyte mode. They are done in create_process. */ 1108 unibyte mode. They are done in create_process. */
1166 1109
1167 /* Qt denotes we have not yet called Ffind_operation_coding_system. */ 1110 /* Qt denotes we have not yet called Ffind_operation_coding_system. */
1168 Lisp_Object coding_systems = Qt; 1111 Lisp_Object coding_systems = Qt;
1169 Lisp_Object val, *args2; 1112 Lisp_Object val, *args2;
1170 struct gcpro gcpro1; 1113 struct gcpro gcpro1, gcpro2;
1171 1114
1172 val = Vcoding_system_for_read; 1115 val = Vcoding_system_for_read;
1173 if (NILP (val)) 1116 if (NILP (val))
1174 { 1117 {
1175 args2 = (Lisp_Object *) alloca ((nargs + 1) * sizeof *args2); 1118 args2 = (Lisp_Object *) alloca ((nargs + 1) * sizeof *args2);
1176 args2[0] = Qstart_process; 1119 args2[0] = Qstart_process;
1177 for (i = 0; i < nargs; i++) args2[i + 1] = args[i]; 1120 for (i = 0; i < nargs; i++) args2[i + 1] = args[i];
1178 GCPRO1 (proc); 1121 GCPRO2 (proc, current_dir);
1179 coding_systems = Ffind_operation_coding_system (nargs + 1, args2); 1122 coding_systems = Ffind_operation_coding_system (nargs + 1, args2);
1180 UNGCPRO; 1123 UNGCPRO;
1181 if (CONSP (coding_systems)) 1124 if (CONSP (coding_systems))
1182 val = XCAR (coding_systems); 1125 val = XCAR (coding_systems);
1183 else if (CONSP (Vdefault_process_coding_system)) 1126 else if (CONSP (Vdefault_process_coding_system))
1191 if (EQ (coding_systems, Qt)) 1134 if (EQ (coding_systems, Qt))
1192 { 1135 {
1193 args2 = (Lisp_Object *) alloca ((nargs + 1) * sizeof args2); 1136 args2 = (Lisp_Object *) alloca ((nargs + 1) * sizeof args2);
1194 args2[0] = Qstart_process; 1137 args2[0] = Qstart_process;
1195 for (i = 0; i < nargs; i++) args2[i + 1] = args[i]; 1138 for (i = 0; i < nargs; i++) args2[i + 1] = args[i];
1196 GCPRO1 (proc); 1139 GCPRO2 (proc, current_dir);
1197 coding_systems = Ffind_operation_coding_system (nargs + 1, args2); 1140 coding_systems = Ffind_operation_coding_system (nargs + 1, args2);
1198 UNGCPRO; 1141 UNGCPRO;
1199 } 1142 }
1200 if (CONSP (coding_systems)) 1143 if (CONSP (coding_systems))
1201 val = XCDR (coding_systems); 1144 val = XCDR (coding_systems);
1202 else if (CONSP (Vdefault_process_coding_system)) 1145 else if (CONSP (Vdefault_process_coding_system))
1203 val = XCDR (Vdefault_process_coding_system); 1146 val = XCDR (Vdefault_process_coding_system);
1204 } 1147 }
1205 XPROCESS (proc)->encode_coding_system = val; 1148 XPROCESS (proc)->encode_coding_system = val;
1206 } 1149 }
1150
1151 #ifdef VMS
1152 /* Make a one member argv with all args concatenated
1153 together separated by a blank. */
1154 len = STRING_BYTES (XSTRING (program)) + 2;
1155 for (i = 3; i < nargs; i++)
1156 {
1157 tem = args[i];
1158 CHECK_STRING (tem, i);
1159 len += STRING_BYTES (XSTRING (tem)) + 1; /* count the blank */
1160 }
1161 new_argv = (unsigned char *) alloca (len);
1162 strcpy (new_argv, XSTRING (program)->data);
1163 for (i = 3; i < nargs; i++)
1164 {
1165 tem = args[i];
1166 CHECK_STRING (tem, i);
1167 strcat (new_argv, " ");
1168 strcat (new_argv, XSTRING (tem)->data);
1169 }
1170 /* Need to add code here to check for program existence on VMS */
1171
1172 #else /* not VMS */
1173 new_argv = (unsigned char **) alloca ((nargs - 1) * sizeof (char *));
1174
1175 /* If program file name is not absolute, search our path for it */
1176 if (!IS_DIRECTORY_SEP (XSTRING (program)->data[0])
1177 && !(XSTRING (program)->size > 1
1178 && IS_DEVICE_SEP (XSTRING (program)->data[1])))
1179 {
1180 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
1181
1182 tem = Qnil;
1183 GCPRO4 (name, program, buffer, current_dir);
1184 openp (Vexec_path, program, EXEC_SUFFIXES, &tem, 1);
1185 UNGCPRO;
1186 if (NILP (tem))
1187 report_file_error ("Searching for program", Fcons (program, Qnil));
1188 tem = Fexpand_file_name (tem, Qnil);
1189 tem = ENCODE_FILE (tem);
1190 new_argv[0] = XSTRING (tem)->data;
1191 }
1192 else
1193 {
1194 if (!NILP (Ffile_directory_p (program)))
1195 error ("Specified program for new process is a directory");
1196
1197 tem = ENCODE_FILE (program);
1198 new_argv[0] = XSTRING (tem)->data;
1199 }
1200
1201 /* Here we encode arguments by the coding system used for sending
1202 data to the process. We don't support using different coding
1203 systems for encoding arguments and for encoding data sent to the
1204 process. */
1205
1206 for (i = 3; i < nargs; i++)
1207 {
1208 tem = args[i];
1209 CHECK_STRING (tem, i);
1210 if (STRING_MULTIBYTE (tem))
1211 tem = (code_convert_string_norecord
1212 (tem, XPROCESS (proc)->encode_coding_system, 1));
1213 new_argv[i - 2] = XSTRING (tem)->data;
1214 }
1215 new_argv[i - 2] = 0;
1216 #endif /* not VMS */
1207 1217
1208 XPROCESS (proc)->decoding_buf = make_uninit_string (0); 1218 XPROCESS (proc)->decoding_buf = make_uninit_string (0);
1209 XPROCESS (proc)->decoding_carryover = make_number (0); 1219 XPROCESS (proc)->decoding_carryover = make_number (0);
1210 XPROCESS (proc)->encoding_buf = make_uninit_string (0); 1220 XPROCESS (proc)->encoding_buf = make_uninit_string (0);
1211 XPROCESS (proc)->encoding_carryover = make_number (0); 1221 XPROCESS (proc)->encoding_carryover = make_number (0);
1404 of the subsidiary according to the information just setup. */ 1414 of the subsidiary according to the information just setup. */
1405 if (!NILP (XPROCESS (process)->decode_coding_system)) 1415 if (!NILP (XPROCESS (process)->decode_coding_system))
1406 setup_raw_text_coding_system (proc_decode_coding_system[inchannel]); 1416 setup_raw_text_coding_system (proc_decode_coding_system[inchannel]);
1407 if (!NILP (XPROCESS (process)->encode_coding_system)) 1417 if (!NILP (XPROCESS (process)->encode_coding_system))
1408 setup_raw_text_coding_system (proc_encode_coding_system[outchannel]); 1418 setup_raw_text_coding_system (proc_encode_coding_system[outchannel]);
1409 }
1410
1411 if (CODING_REQUIRE_ENCODING (proc_encode_coding_system[outchannel]))
1412 {
1413 /* Here we encode arguments by the coding system used for
1414 sending data to the process. We don't support using
1415 different coding systems for encoding arguments and for
1416 encoding data sent to the process. */
1417 struct gcpro gcpro1;
1418 int i = 1;
1419 struct coding_system *coding = proc_encode_coding_system[outchannel];
1420
1421 coding->mode |= CODING_MODE_LAST_BLOCK;
1422 GCPRO1 (process);
1423 while (new_argv[i] != 0)
1424 {
1425 int len = strlen (new_argv[i]);
1426 int size = encoding_buffer_size (coding, len);
1427 unsigned char *buf = (unsigned char *) alloca (size);
1428
1429 encode_coding (coding, (unsigned char *)new_argv[i], buf, len, size);
1430 buf[coding->produced] = 0;
1431 /* We don't have to free new_argv[i] because it points to a
1432 Lisp string given as an argument to `start-process'. */
1433 new_argv[i++] = (char *) buf;
1434 }
1435 UNGCPRO;
1436 coding->mode &= ~CODING_MODE_LAST_BLOCK;
1437 } 1419 }
1438 1420
1439 /* Delay interrupts until we have a chance to store 1421 /* Delay interrupts until we have a chance to store
1440 the new fork's pid in its process structure */ 1422 the new fork's pid in its process structure */
1441 #ifdef POSIX_SIGNALS 1423 #ifdef POSIX_SIGNALS
2112 if (!proc_decode_coding_system[inch]) 2094 if (!proc_decode_coding_system[inch])
2113 proc_decode_coding_system[inch] 2095 proc_decode_coding_system[inch]
2114 = (struct coding_system *) xmalloc (sizeof (struct coding_system)); 2096 = (struct coding_system *) xmalloc (sizeof (struct coding_system));
2115 setup_coding_system (XPROCESS (proc)->decode_coding_system, 2097 setup_coding_system (XPROCESS (proc)->decode_coding_system,
2116 proc_decode_coding_system[inch]); 2098 proc_decode_coding_system[inch]);
2099 proc_decode_coding_system[inch]->src_multibyte = 1;
2100 proc_decode_coding_system[inch]->dst_multibyte = 0;
2117 if (!proc_encode_coding_system[outch]) 2101 if (!proc_encode_coding_system[outch])
2118 proc_encode_coding_system[outch] 2102 proc_encode_coding_system[outch]
2119 = (struct coding_system *) xmalloc (sizeof (struct coding_system)); 2103 = (struct coding_system *) xmalloc (sizeof (struct coding_system));
2120 setup_coding_system (XPROCESS (proc)->encode_coding_system, 2104 setup_coding_system (XPROCESS (proc)->encode_coding_system,
2121 proc_encode_coding_system[outch]); 2105 proc_encode_coding_system[outch]);
2106 proc_encode_coding_system[inch]->src_multibyte = 0;
2107 proc_encode_coding_system[inch]->dst_multibyte = 1;
2122 2108
2123 XPROCESS (proc)->decoding_buf = make_uninit_string (0); 2109 XPROCESS (proc)->decoding_buf = make_uninit_string (0);
2124 XPROCESS (proc)->decoding_carryover = make_number (0); 2110 XPROCESS (proc)->decoding_carryover = make_number (0);
2125 XPROCESS (proc)->encoding_buf = make_uninit_string (0); 2111 XPROCESS (proc)->encoding_buf = make_uninit_string (0);
2126 XPROCESS (proc)->encoding_carryover = make_number (0); 2112 XPROCESS (proc)->encoding_carryover = make_number (0);
2856 register int opoint; 2842 register int opoint;
2857 struct coding_system *coding = proc_decode_coding_system[channel]; 2843 struct coding_system *coding = proc_decode_coding_system[channel];
2858 int chars_in_decoding_buf = 0; /* If 1, `chars' points 2844 int chars_in_decoding_buf = 0; /* If 1, `chars' points
2859 XSTRING (p->decoding_buf)->data. */ 2845 XSTRING (p->decoding_buf)->data. */
2860 int carryover = XINT (p->decoding_carryover); 2846 int carryover = XINT (p->decoding_carryover);
2847 int require_decoding;
2861 2848
2862 #ifdef VMS 2849 #ifdef VMS
2863 VMS_PROC_STUFF *vs, *get_vms_process_pointer(); 2850 VMS_PROC_STUFF *vs, *get_vms_process_pointer();
2864 2851
2865 vs = get_vms_process_pointer (p->pid); 2852 vs = get_vms_process_pointer (p->pid);
2928 coding->mode |= CODING_MODE_LAST_BLOCK; 2915 coding->mode |= CODING_MODE_LAST_BLOCK;
2929 } 2916 }
2930 2917
2931 /* Now set NBYTES how many bytes we must decode. */ 2918 /* Now set NBYTES how many bytes we must decode. */
2932 nbytes += carryover; 2919 nbytes += carryover;
2933 nchars = nbytes; 2920
2934 2921 require_decoding = 1;
2935 if (CODING_MAY_REQUIRE_DECODING (coding)) 2922 coding->src_multibyte = 0;
2923 /* Decide the multibyteness of the decoded text. */
2924 if (!NILP (p->filter))
2925 /* We make a string given to the process filter. The
2926 multibyteness is decided by which coding system we use for
2927 decoding. */
2928 coding->dst_multibyte = (coding->type != coding_type_no_conversion
2929 && coding->type != coding_type_raw_text);
2930 else if (!NILP (p->buffer) && !NILP (XBUFFER (p->buffer)->name))
2931 /* The decoded text is inserted in a buffer. The multibyteness is
2932 decided by that of the buffer. */
2933 coding->dst_multibyte
2934 = !NILP (XBUFFER (p->buffer)->enable_multibyte_characters);
2935 else
2936 /* We can discard the source, thus no need of decoding. */
2937 require_decoding = 0;
2938
2939 if (require_decoding
2940 || CODING_MAY_REQUIRE_DECODING (coding))
2936 { 2941 {
2937 int require = decoding_buffer_size (coding, nbytes); 2942 int require = decoding_buffer_size (coding, nbytes);
2943 int dst_bytes = STRING_BYTES (XSTRING (p->decoding_buf));
2938 int result; 2944 int result;
2939 2945
2940 if (STRING_BYTES (XSTRING (p->decoding_buf)) < require) 2946 if (dst_bytes < require)
2941 p->decoding_buf = make_uninit_string (require); 2947 p->decoding_buf = make_uninit_string (require), dst_bytes = require;
2942 result = decode_coding (coding, chars, XSTRING (p->decoding_buf)->data, 2948 result = decode_coding (coding, chars, XSTRING (p->decoding_buf)->data,
2943 nbytes, STRING_BYTES (XSTRING (p->decoding_buf))); 2949 nbytes, dst_bytes);
2944 carryover = nbytes - coding->consumed; 2950 carryover = nbytes - coding->consumed;
2945 if (carryover > 0) 2951 if (carryover > 0)
2946 { 2952 {
2947 /* Copy the carryover bytes to the end of p->decoding_buf, to 2953 /* Copy the carryover bytes to the end of p->decoding_buf, to
2948 be processed on the next read. Since decoding_buffer_size 2954 be processed on the next read. Since decoding_buffer_size
2949 asks for an extra amount of space beyond the maximum 2955 asks for an extra amount of space beyond the maximum
2950 expected for the output, there should always be sufficient 2956 expected for the output, there should always be sufficient
2951 space for the carryover (which is by definition a sequence 2957 space for the carryover (which is by definition a sequence
2952 of bytes that was not long enough to be decoded, and thus 2958 of bytes that was not long enough to be decoded, and thus
2953 has a bounded length). */ 2959 has a bounded length). */
2954 if (STRING_BYTES (XSTRING (p->decoding_buf)) 2960 if (dst_bytes < coding->produced + carryover)
2955 < coding->produced + carryover)
2956 abort (); 2961 abort ();
2957 bcopy (chars + coding->consumed, 2962 bcopy (chars + coding->consumed,
2958 XSTRING (p->decoding_buf)->data 2963 XSTRING (p->decoding_buf)->data + dst_bytes - carryover,
2959 + STRING_BYTES (XSTRING (p->decoding_buf)) - carryover,
2960 carryover); 2964 carryover);
2961 XSETINT (p->decoding_carryover, carryover); 2965 XSETINT (p->decoding_carryover, carryover);
2962 } 2966 }
2963 2967
2964 /* A new coding system might be found by `decode_coding'. */ 2968 /* A new coding system might be found by `decode_coding'. */
2987 } 2991 }
2988 2992
2989 #ifdef VMS 2993 #ifdef VMS
2990 /* Now we don't need the contents of `chars'. */ 2994 /* Now we don't need the contents of `chars'. */
2991 if (chars_allocated) 2995 if (chars_allocated)
2992 free (chars); 2996 xfree (chars);
2993 #endif 2997 #endif
2994 if (coding->produced == 0) 2998 if (coding->produced == 0)
2995 return 0; 2999 return 0;
2996 chars = (char *) XSTRING (p->decoding_buf)->data; 3000 chars = (char *) XSTRING (p->decoding_buf)->data;
2997 nbytes = coding->produced; 3001 nbytes = coding->produced;
2998 nchars = (coding->fake_multibyte 3002 nchars = coding->produced_char;
2999 ? multibyte_chars_in_text (chars, nbytes)
3000 : coding->produced_char);
3001 chars_in_decoding_buf = 1; 3003 chars_in_decoding_buf = 1;
3002 } 3004 }
3003 else 3005 else
3004 { 3006 {
3005 #ifdef VMS 3007 #ifdef VMS
3010 if (! STRINGP (p->decoding_buf) 3012 if (! STRINGP (p->decoding_buf)
3011 || STRING_BYTES (XSTRING (p->decoding_buf)) < nbytes) 3013 || STRING_BYTES (XSTRING (p->decoding_buf)) < nbytes)
3012 p->decoding_buf = make_uninit_string (nbytes); 3014 p->decoding_buf = make_uninit_string (nbytes);
3013 bcopy (chars, XSTRING (p->decoding_buf)->data, nbytes); 3015 bcopy (chars, XSTRING (p->decoding_buf)->data, nbytes);
3014 free (chars); 3016 free (chars);
3015 chars = XSTRING (p->decoding_buf)->data;
3016 chars_in_decoding_buf = 1; 3017 chars_in_decoding_buf = 1;
3017 } 3018 }
3018 #endif 3019 #endif
3019 nchars = multibyte_chars_in_text (chars, nbytes); 3020 nchars = nbytes;
3020 } 3021 }
3021 3022
3022 Vlast_coding_system_used = coding->symbol; 3023 Vlast_coding_system_used = coding->symbol;
3023 3024
3024 /* If the caller required, let the process associated buffer 3025 /* If the caller required, let the process associated buffer
3074 save the match data in a special nonrecursive fashion. */ 3075 save the match data in a special nonrecursive fashion. */
3075 running_asynch_code = 1; 3076 running_asynch_code = 1;
3076 3077
3077 /* The multibyteness of a string given to the filter is decided 3078 /* The multibyteness of a string given to the filter is decided
3078 by which coding system we used for decoding. */ 3079 by which coding system we used for decoding. */
3079 if (coding->type == coding_type_no_conversion 3080 if (coding->dst_multibyte)
3080 || coding->type == coding_type_raw_text) 3081 text = make_multibyte_string (chars, nchars, nbytes);
3082 else
3081 text = make_unibyte_string (chars, nbytes); 3083 text = make_unibyte_string (chars, nbytes);
3082 else
3083 text = make_multibyte_string (chars, nchars, nbytes);
3084 3084
3085 internal_condition_case_1 (read_process_output_call, 3085 internal_condition_case_1 (read_process_output_call,
3086 Fcons (outstream, 3086 Fcons (outstream,
3087 Fcons (proc, Fcons (text, Qnil))), 3087 Fcons (proc, Fcons (text, Qnil))),
3088 !NILP (Vdebug_on_error) ? Qnil : Qerror, 3088 !NILP (Vdebug_on_error) ? Qnil : Qerror,
3156 /* If the output marker is outside of the visible region, save 3156 /* If the output marker is outside of the visible region, save
3157 the restriction and widen. */ 3157 the restriction and widen. */
3158 if (! (BEGV <= PT && PT <= ZV)) 3158 if (! (BEGV <= PT && PT <= ZV))
3159 Fwiden (); 3159 Fwiden ();
3160 3160
3161 if (NILP (current_buffer->enable_multibyte_characters)) 3161 /* If the text to insert is in decoding buffer (Lisp String), we
3162 nchars = nbytes; 3162 must move it to a relocation-free memory space. */
3163 if (chars_in_decoding_buf)
3164 {
3165 chars = (char *) alloca (nbytes);
3166 bcopy (XSTRING (p->decoding_buf)->data, chars, nbytes);
3167 }
3163 3168
3164 /* Insert before markers in case we are inserting where 3169 /* Insert before markers in case we are inserting where
3165 the buffer's mark is, and the user's next command is Meta-y. */ 3170 the buffer's mark is, and the user's next command is Meta-y. */
3166 if (chars_in_decoding_buf) 3171 insert_1_both (chars, nchars, nbytes, 0, 1, 1);
3167 { 3172 signal_after_change (before, 0, PT - before);
3168 /* Since multibyteness of p->docoding_buf is corrupted, we 3173 update_compositions (before, PT, CHECK_BORDER);
3169 can't use insert_from_string_before_markers. */ 3174
3170 char *temp_buf;
3171
3172 temp_buf = (char *) alloca (nbytes);
3173 bcopy (XSTRING (p->decoding_buf)->data, temp_buf, nbytes);
3174 insert_before_markers (temp_buf, nbytes);
3175 }
3176 else
3177 {
3178 insert_1_both (chars, nchars, nbytes, 0, 1, 1);
3179 signal_after_change (before, 0, PT - before);
3180 update_compositions (before, PT, CHECK_BORDER);
3181 }
3182 set_marker_both (p->mark, p->buffer, PT, PT_BYTE); 3175 set_marker_both (p->mark, p->buffer, PT, PT_BYTE);
3183 3176
3184 update_mode_lines++; 3177 update_mode_lines++;
3185 3178
3186 /* Make sure opoint and the old restrictions 3179 /* Make sure opoint and the old restrictions
3263 /* Use volatile to protect variables from being clobbered by longjmp. */ 3256 /* Use volatile to protect variables from being clobbered by longjmp. */
3264 int rv; 3257 int rv;
3265 struct coding_system *coding; 3258 struct coding_system *coding;
3266 struct gcpro gcpro1; 3259 struct gcpro gcpro1;
3267 int carryover = XINT (XPROCESS (proc)->encoding_carryover); 3260 int carryover = XINT (XPROCESS (proc)->encoding_carryover);
3261 int require_encoding;
3268 3262
3269 GCPRO1 (object); 3263 GCPRO1 (object);
3270 3264
3271 #ifdef VMS 3265 #ifdef VMS
3272 struct Lisp_Process *p = XPROCESS (proc); 3266 struct Lisp_Process *p = XPROCESS (proc);
3283 XSTRING (XPROCESS (proc)->name)->data); 3277 XSTRING (XPROCESS (proc)->name)->data);
3284 3278
3285 coding = proc_encode_coding_system[XINT (XPROCESS (proc)->outfd)]; 3279 coding = proc_encode_coding_system[XINT (XPROCESS (proc)->outfd)];
3286 Vlast_coding_system_used = coding->symbol; 3280 Vlast_coding_system_used = coding->symbol;
3287 3281
3288 if (CODING_REQUIRE_ENCODING (coding)) 3282 require_encoding = 0;
3283 if (STRINGP (object) && STRING_MULTIBYTE (object))
3284 coding->src_multibyte = require_encoding = 1;
3285 else if (BUFFERP (object)
3286 && !NILP (XBUFFER (object)->enable_multibyte_characters))
3287 coding->src_multibyte = require_encoding = 1;
3288 else
3289 require_encoding = 0;
3290 coding->dst_multibyte = 0;
3291
3292 if (require_encoding
3293 || CODING_REQUIRE_ENCODING (coding))
3289 { 3294 {
3290 int require = encoding_buffer_size (coding, len); 3295 int require = encoding_buffer_size (coding, len);
3291 int offset; 3296 int offset;
3292 unsigned char *temp_buf = NULL; 3297 unsigned char *temp_buf = NULL;
3293 3298