Mercurial > emacs
comparison src/callproc.c @ 26838:27b6d3367b47
(Fcall_process): Call code_convert_string to encode
arguments. Use CODING_REQUIRE_DECODING to check if the process
output should be decoded.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Wed, 15 Dec 1999 00:02:12 +0000 |
parents | b7438760079b |
children | 45b919961573 |
comparison
equal
deleted
inserted
replaced
26837:bb9ada50010f | 26838:27b6d3367b47 |
---|---|
378 new_argv[0] = XSTRING (path)->data; | 378 new_argv[0] = XSTRING (path)->data; |
379 if (nargs > 4) | 379 if (nargs > 4) |
380 { | 380 { |
381 register int i; | 381 register int i; |
382 | 382 |
383 if (! CODING_REQUIRE_ENCODING (&argument_coding)) | 383 if (CODING_REQUIRE_ENCODING (&argument_coding)) |
384 { | |
385 for (i = 4; i < nargs; i++) | |
386 new_argv[i - 3] = XSTRING (args[i])->data; | |
387 } | |
388 else | |
389 { | 384 { |
390 /* We must encode the arguments. */ | 385 /* We must encode the arguments. */ |
391 struct gcpro gcpro1, gcpro2, gcpro3; | 386 struct gcpro gcpro1, gcpro2, gcpro3; |
392 | 387 |
393 GCPRO3 (infile, buffer, current_dir); | 388 GCPRO3 (infile, buffer, current_dir); |
394 for (i = 4; i < nargs; i++) | 389 for (i = 4; i < nargs; i++) |
395 { | 390 { |
396 int size = encoding_buffer_size (&argument_coding, | 391 args[i] = code_convert_string (args[i], &argument_coding, 1, 0); |
397 STRING_BYTES (XSTRING (args[i]))); | 392 setup_ccl_program (&(argument_coding.spec.ccl.encoder), Qnil); |
398 unsigned char *dummy1 = (unsigned char *) alloca (size); | |
399 | |
400 /* The Irix 4.0 compiler barfs if we eliminate dummy. */ | |
401 new_argv[i - 3] = dummy1; | |
402 argument_coding.mode |= CODING_MODE_LAST_BLOCK; | |
403 encode_coding (&argument_coding, | |
404 XSTRING (args[i])->data, | |
405 new_argv[i - 3], | |
406 STRING_BYTES (XSTRING (args[i])), | |
407 size); | |
408 new_argv[i - 3][argument_coding.produced] = 0; | |
409 /* We have to initialize CCL program status again. */ | |
410 if (argument_coding.type == coding_type_ccl) | |
411 setup_ccl_program (&(argument_coding.spec.ccl.encoder), Qnil); | |
412 } | 393 } |
413 UNGCPRO; | 394 UNGCPRO; |
414 } | 395 } |
396 for (i = 4; i < nargs; i++) | |
397 new_argv[i - 3] = XSTRING (args[i])->data; | |
415 new_argv[nargs - 3] = 0; | 398 new_argv[nargs - 3] = 0; |
416 } | 399 } |
417 else | 400 else |
418 new_argv[1] = 0; | 401 new_argv[1] = 0; |
419 | 402 |
763 /* Now NREAD is the total amount of data in the buffer. */ | 746 /* Now NREAD is the total amount of data in the buffer. */ |
764 immediate_quit = 0; | 747 immediate_quit = 0; |
765 | 748 |
766 if (!NILP (buffer)) | 749 if (!NILP (buffer)) |
767 { | 750 { |
768 if (process_coding.type == coding_type_no_conversion) | 751 if (! CODING_REQUIRE_DECODING (&process_coding)) |
769 insert (bufptr, nread); | 752 insert (bufptr, nread); |
770 else | 753 else |
771 { /* We have to decode the input. */ | 754 { /* We have to decode the input. */ |
772 int size = decoding_buffer_size (&process_coding, nread); | 755 int size = decoding_buffer_size (&process_coding, nread); |
773 char *decoding_buf = (char *) xmalloc (size); | 756 char *decoding_buf = (char *) xmalloc (size); |
829 immediate_quit = 1; | 812 immediate_quit = 1; |
830 QUIT; | 813 QUIT; |
831 } | 814 } |
832 give_up: ; | 815 give_up: ; |
833 | 816 |
834 Vlast_coding_system_used = process_coding.symbol; | 817 Vlast_coding_system_used = process_coding.symbol; |
835 | 818 |
836 /* If the caller required, let the buffer inherit the | 819 /* If the caller required, let the buffer inherit the |
837 coding-system used to decode the process output. */ | 820 coding-system used to decode the process output. */ |
838 if (inherit_process_coding_system) | 821 if (inherit_process_coding_system) |
839 call1 (intern ("after-insert-file-set-buffer-file-coding-system"), | 822 call1 (intern ("after-insert-file-set-buffer-file-coding-system"), |
840 make_number (total_read)); | 823 make_number (total_read)); |
841 } | 824 } |
842 | 825 |
843 /* Wait for it to terminate, unless it already has. */ | 826 /* Wait for it to terminate, unless it already has. */ |
844 wait_for_termination (pid); | 827 wait_for_termination (pid); |
845 | 828 |