aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Schwab2011-05-01 11:02:01 +0200
committerAndreas Schwab2011-05-01 11:02:01 +0200
commit19ed11badb10b4470ae03de4c7fffdd0abf5800d (patch)
treec986c37a1b9965ed9972c5fff7db0a9aa49e6ccd /src
parente7a6747fd320eebb898353dae1829d3b4e1d4bfa (diff)
downloademacs-19ed11badb10b4470ae03de4c7fffdd0abf5800d.tar.gz
emacs-19ed11badb10b4470ae03de4c7fffdd0abf5800d.zip
* src/callproc.c: Indentation fixup.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog2
-rw-r--r--src/callproc.c298
2 files changed, 151 insertions, 149 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index a88419f0b11..625dfb07621 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,7 @@
12011-05-01 Andreas Schwab <schwab@linux-m68k.org> 12011-05-01 Andreas Schwab <schwab@linux-m68k.org>
2 2
3 * callproc.c: Indentation fixup.
4
3 * sysdep.c (wait_for_termination_1): Make static. 5 * sysdep.c (wait_for_termination_1): Make static.
4 (wait_for_termination, interruptible_wait_for_termination): Move 6 (wait_for_termination, interruptible_wait_for_termination): Move
5 after wait_for_termination_1. 7 after wait_for_termination_1.
diff --git a/src/callproc.c b/src/callproc.c
index 84b463d2f3d..4a29e95b356 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -1,6 +1,6 @@
1/* Synchronous subprocess invocation for GNU Emacs. 1/* Synchronous subprocess invocation for GNU Emacs.
2 Copyright (C) 1985-1988, 1993-1995, 1999-2011 2 Copyright (C) 1985-1988, 1993-1995, 1999-2011
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
6 6
@@ -280,9 +280,9 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
280 /* If BUFFER is a list, its meaning is (BUFFER-FOR-STDOUT 280 /* If BUFFER is a list, its meaning is (BUFFER-FOR-STDOUT
281 FILE-FOR-STDERR), unless the first element is :file, in which case see 281 FILE-FOR-STDERR), unless the first element is :file, in which case see
282 the next paragraph. */ 282 the next paragraph. */
283 if (CONSP (buffer) && 283 if (CONSP (buffer)
284 (! SYMBOLP (XCAR (buffer)) || 284 && (! SYMBOLP (XCAR (buffer))
285 strcmp (SSDATA (SYMBOL_NAME (XCAR (buffer))), ":file"))) 285 || strcmp (SSDATA (SYMBOL_NAME (XCAR (buffer))), ":file")))
286 { 286 {
287 if (CONSP (XCDR (buffer))) 287 if (CONSP (XCDR (buffer)))
288 { 288 {
@@ -299,9 +299,9 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
299 } 299 }
300 300
301 /* If the buffer is (still) a list, it might be a (:file "file") spec. */ 301 /* If the buffer is (still) a list, it might be a (:file "file") spec. */
302 if (CONSP (buffer) && 302 if (CONSP (buffer)
303 SYMBOLP (XCAR (buffer)) && 303 && SYMBOLP (XCAR (buffer))
304 ! strcmp (SSDATA (SYMBOL_NAME (XCAR (buffer))), ":file")) 304 && ! strcmp (SSDATA (SYMBOL_NAME (XCAR (buffer))), ":file"))
305 { 305 {
306 output_file = Fexpand_file_name (XCAR (XCDR (buffer)), 306 output_file = Fexpand_file_name (XCAR (XCDR (buffer)),
307 BVAR (current_buffer, directory)); 307 BVAR (current_buffer, directory));
@@ -388,9 +388,9 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
388 output_file = DECODE_FILE (output_file); 388 output_file = DECODE_FILE (output_file);
389 report_file_error ("Opening process output file", 389 report_file_error ("Opening process output file",
390 Fcons (output_file, Qnil)); 390 Fcons (output_file, Qnil));
391 } 391 }
392 if (STRINGP (error_file) || NILP (error_file)) 392 if (STRINGP (error_file) || NILP (error_file))
393 output_to_buffer = 0; 393 output_to_buffer = 0;
394 } 394 }
395 395
396 /* Search for program; barf if not found. */ 396 /* Search for program; barf if not found. */
@@ -599,12 +599,12 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
599 if (fd[0] >= 0) 599 if (fd[0] >= 0)
600 emacs_close (fd[0]); 600 emacs_close (fd[0]);
601#ifdef HAVE_SETSID 601#ifdef HAVE_SETSID
602 setsid (); 602 setsid ();
603#endif 603#endif
604#if defined (USG) 604#if defined (USG)
605 setpgrp (); 605 setpgrp ();
606#else 606#else
607 setpgrp (pid, pid); 607 setpgrp (pid, pid);
608#endif /* USG */ 608#endif /* USG */
609 609
610 /* GConf causes us to ignore SIGPIPE, make sure it is restored 610 /* GConf causes us to ignore SIGPIPE, make sure it is restored
@@ -723,132 +723,132 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
723 QUIT; 723 QUIT;
724 724
725 if (output_to_buffer) 725 if (output_to_buffer)
726 { 726 {
727 register EMACS_INT nread; 727 register EMACS_INT nread;
728 int first = 1; 728 int first = 1;
729 EMACS_INT total_read = 0; 729 EMACS_INT total_read = 0;
730 int carryover = 0; 730 int carryover = 0;
731 int display_p = display_p_volatile; 731 int display_p = display_p_volatile;
732 int display_on_the_fly = display_p; 732 int display_on_the_fly = display_p;
733 struct coding_system saved_coding; 733 struct coding_system saved_coding;
734 734
735 saved_coding = process_coding; 735 saved_coding = process_coding;
736 while (1) 736 while (1)
737 { 737 {
738 /* Repeatedly read until we've filled as much as possible 738 /* Repeatedly read until we've filled as much as possible
739 of the buffer size we have. But don't read 739 of the buffer size we have. But don't read
740 less than 1024--save that for the next bufferful. */ 740 less than 1024--save that for the next bufferful. */
741 nread = carryover; 741 nread = carryover;
742 while (nread < bufsize - 1024) 742 while (nread < bufsize - 1024)
743 { 743 {
744 int this_read = emacs_read (fd[0], buf + nread, 744 int this_read = emacs_read (fd[0], buf + nread,
745 bufsize - nread); 745 bufsize - nread);
746 746
747 if (this_read < 0) 747 if (this_read < 0)
748 goto give_up; 748 goto give_up;
749 749
750 if (this_read == 0) 750 if (this_read == 0)
751 { 751 {
752 process_coding.mode |= CODING_MODE_LAST_BLOCK; 752 process_coding.mode |= CODING_MODE_LAST_BLOCK;
753 break; 753 break;
754 } 754 }
755 755
756 nread += this_read; 756 nread += this_read;
757 total_read += this_read; 757 total_read += this_read;
758 758
759 if (display_on_the_fly) 759 if (display_on_the_fly)
760 break; 760 break;
761 } 761 }
762 762
763 /* Now NREAD is the total amount of data in the buffer. */ 763 /* Now NREAD is the total amount of data in the buffer. */
764 immediate_quit = 0; 764 immediate_quit = 0;
765 765
766 if (!NILP (buffer)) 766 if (!NILP (buffer))
767 { 767 {
768 if (NILP (BVAR (current_buffer, enable_multibyte_characters)) 768 if (NILP (BVAR (current_buffer, enable_multibyte_characters))
769 && ! CODING_MAY_REQUIRE_DECODING (&process_coding)) 769 && ! CODING_MAY_REQUIRE_DECODING (&process_coding))
770 insert_1_both (buf, nread, nread, 0, 1, 0); 770 insert_1_both (buf, nread, nread, 0, 1, 0);
771 else 771 else
772 { /* We have to decode the input. */ 772 { /* We have to decode the input. */
773 Lisp_Object curbuf; 773 Lisp_Object curbuf;
774 int count1 = SPECPDL_INDEX (); 774 int count1 = SPECPDL_INDEX ();
775 775
776 XSETBUFFER (curbuf, current_buffer); 776 XSETBUFFER (curbuf, current_buffer);
777 /* We cannot allow after-change-functions be run 777 /* We cannot allow after-change-functions be run
778 during decoding, because that might modify the 778 during decoding, because that might modify the
779 buffer, while we rely on process_coding.produced to 779 buffer, while we rely on process_coding.produced to
780 faithfully reflect inserted text until we 780 faithfully reflect inserted text until we
781 TEMP_SET_PT_BOTH below. */ 781 TEMP_SET_PT_BOTH below. */
782 specbind (Qinhibit_modification_hooks, Qt); 782 specbind (Qinhibit_modification_hooks, Qt);
783 decode_coding_c_string (&process_coding, (unsigned char *) buf, 783 decode_coding_c_string (&process_coding,
784 nread, curbuf); 784 (unsigned char *) buf, nread, curbuf);
785 unbind_to (count1, Qnil); 785 unbind_to (count1, Qnil);
786 if (display_on_the_fly 786 if (display_on_the_fly
787 && CODING_REQUIRE_DETECTION (&saved_coding) 787 && CODING_REQUIRE_DETECTION (&saved_coding)
788 && ! CODING_REQUIRE_DETECTION (&process_coding)) 788 && ! CODING_REQUIRE_DETECTION (&process_coding))
789 { 789 {
790 /* We have detected some coding system. But, 790 /* We have detected some coding system. But,
791 there's a possibility that the detection was 791 there's a possibility that the detection was
792 done by insufficient data. So, we give up 792 done by insufficient data. So, we give up
793 displaying on the fly. */ 793 displaying on the fly. */
794 if (process_coding.produced > 0) 794 if (process_coding.produced > 0)
795 del_range_2 (process_coding.dst_pos, 795 del_range_2 (process_coding.dst_pos,
796 process_coding.dst_pos_byte, 796 process_coding.dst_pos_byte,
797 process_coding.dst_pos 797 process_coding.dst_pos
798 + process_coding.produced_char, 798 + process_coding.produced_char,
799 process_coding.dst_pos_byte 799 process_coding.dst_pos_byte
800 + process_coding.produced, 0); 800 + process_coding.produced, 0);
801 display_on_the_fly = 0; 801 display_on_the_fly = 0;
802 process_coding = saved_coding; 802 process_coding = saved_coding;
803 carryover = nread; 803 carryover = nread;
804 /* This is to make the above condition always 804 /* This is to make the above condition always
805 fails in the future. */ 805 fails in the future. */
806 saved_coding.common_flags 806 saved_coding.common_flags
807 &= ~CODING_REQUIRE_DETECTION_MASK; 807 &= ~CODING_REQUIRE_DETECTION_MASK;
808 continue; 808 continue;
809 } 809 }
810 810
811 TEMP_SET_PT_BOTH (PT + process_coding.produced_char, 811 TEMP_SET_PT_BOTH (PT + process_coding.produced_char,
812 PT_BYTE + process_coding.produced); 812 PT_BYTE + process_coding.produced);
813 carryover = process_coding.carryover_bytes; 813 carryover = process_coding.carryover_bytes;
814 if (carryover > 0) 814 if (carryover > 0)
815 memcpy (buf, process_coding.carryover, 815 memcpy (buf, process_coding.carryover,
816 process_coding.carryover_bytes); 816 process_coding.carryover_bytes);
817 } 817 }
818 } 818 }
819 819
820 if (process_coding.mode & CODING_MODE_LAST_BLOCK) 820 if (process_coding.mode & CODING_MODE_LAST_BLOCK)
821 break; 821 break;
822 822
823 /* Make the buffer bigger as we continue to read more data, 823 /* Make the buffer bigger as we continue to read more data,
824 but not past CALLPROC_BUFFER_SIZE_MAX. */ 824 but not past CALLPROC_BUFFER_SIZE_MAX. */
825 if (bufsize < CALLPROC_BUFFER_SIZE_MAX && total_read > 32 * bufsize) 825 if (bufsize < CALLPROC_BUFFER_SIZE_MAX && total_read > 32 * bufsize)
826 if ((bufsize *= 2) > CALLPROC_BUFFER_SIZE_MAX) 826 if ((bufsize *= 2) > CALLPROC_BUFFER_SIZE_MAX)
827 bufsize = CALLPROC_BUFFER_SIZE_MAX; 827 bufsize = CALLPROC_BUFFER_SIZE_MAX;
828 828
829 if (display_p) 829 if (display_p)
830 { 830 {
831 if (first) 831 if (first)
832 prepare_menu_bars (); 832 prepare_menu_bars ();
833 first = 0; 833 first = 0;
834 redisplay_preserve_echo_area (1); 834 redisplay_preserve_echo_area (1);
835 /* This variable might have been set to 0 for code 835 /* This variable might have been set to 0 for code
836 detection. In that case, we set it back to 1 because 836 detection. In that case, we set it back to 1 because
837 we should have already detected a coding system. */ 837 we should have already detected a coding system. */
838 display_on_the_fly = 1; 838 display_on_the_fly = 1;
839 } 839 }
840 immediate_quit = 1; 840 immediate_quit = 1;
841 QUIT; 841 QUIT;
842 } 842 }
843 give_up: ; 843 give_up: ;
844 844
845 Vlast_coding_system_used = CODING_ID_NAME (process_coding.id); 845 Vlast_coding_system_used = CODING_ID_NAME (process_coding.id);
846 /* If the caller required, let the buffer inherit the 846 /* If the caller required, let the buffer inherit the
847 coding-system used to decode the process output. */ 847 coding-system used to decode the process output. */
848 if (inherit_process_coding_system) 848 if (inherit_process_coding_system)
849 call1 (intern ("after-insert-file-set-buffer-file-coding-system"), 849 call1 (intern ("after-insert-file-set-buffer-file-coding-system"),
850 make_number (total_read)); 850 make_number (total_read));
851 } 851 }
852 852
853#ifndef MSDOS 853#ifndef MSDOS
854 /* Wait for it to terminate, unless it already has. */ 854 /* Wait for it to terminate, unless it already has. */
@@ -875,7 +875,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
875 signame = strsignal (synch_process_termsig); 875 signame = strsignal (synch_process_termsig);
876 876
877 if (signame == 0) 877 if (signame == 0)
878 signame = "unknown"; 878 signame = "unknown";
879 879
880 synch_process_death = signame; 880 synch_process_death = signame;
881 } 881 }
@@ -1058,18 +1058,18 @@ add_env (char **env, char **new_env, char *string)
1058 { 1058 {
1059 char *p = *ep, *q = string; 1059 char *p = *ep, *q = string;
1060 while (ok) 1060 while (ok)
1061 { 1061 {
1062 if (*q != *p) 1062 if (*q != *p)
1063 break; 1063 break;
1064 if (*q == 0) 1064 if (*q == 0)
1065 /* The string is a lone variable name; keep it for now, we 1065 /* The string is a lone variable name; keep it for now, we
1066 will remove it later. It is a placeholder for a 1066 will remove it later. It is a placeholder for a
1067 variable that is not to be included in the environment. */ 1067 variable that is not to be included in the environment. */
1068 break; 1068 break;
1069 if (*q == '=') 1069 if (*q == '=')
1070 ok = 0; 1070 ok = 0;
1071 p++, q++; 1071 p++, q++;
1072 } 1072 }
1073 } 1073 }
1074 if (ok) 1074 if (ok)
1075 *new_env++ = string; 1075 *new_env++ = string;
@@ -1173,8 +1173,8 @@ child_setup (int in, int out, int err, register char **new_argv, int set_pgrp, L
1173 new_length = 0; 1173 new_length = 0;
1174 1174
1175 for (tem = Vprocess_environment; 1175 for (tem = Vprocess_environment;
1176 CONSP (tem) && STRINGP (XCAR (tem)); 1176 CONSP (tem) && STRINGP (XCAR (tem));
1177 tem = XCDR (tem)) 1177 tem = XCDR (tem))
1178 { 1178 {
1179 if (strncmp (SSDATA (XCAR (tem)), "DISPLAY", 7) == 0 1179 if (strncmp (SSDATA (XCAR (tem)), "DISPLAY", 7) == 0
1180 && (SDATA (XCAR (tem)) [7] == '\0' 1180 && (SDATA (XCAR (tem)) [7] == '\0'
@@ -1227,11 +1227,11 @@ child_setup (int in, int out, int err, register char **new_argv, int set_pgrp, L
1227 p = q = env; 1227 p = q = env;
1228 while (*p != 0) 1228 while (*p != 0)
1229 { 1229 {
1230 while (*q != 0 && strchr (*q, '=') == NULL) 1230 while (*q != 0 && strchr (*q, '=') == NULL)
1231 q++; 1231 q++;
1232 *p = *q++; 1232 *p = *q++;
1233 if (*p != 0) 1233 if (*p != 0)
1234 p++; 1234 p++;
1235 } 1235 }
1236 } 1236 }
1237 1237