comparison src/process.c @ 90375:e6bf73e43cf4

Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-49 Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 164-184) - Update from CVS - Merge from gnus--rel--5.10 - Update from CVS: man/mh-e.texi (Folders): Various edits. - Update from erc--emacs--0 * gnus--rel--5.10 (patch 62-70) - Merge from emacs--devo--0 - Update from CVS
author Miles Bader <miles@gnu.org>
date Tue, 28 Mar 2006 23:08:20 +0000
parents a802c5505156 5633a1931272
children 65ca8fb66a0d
comparison
equal deleted inserted replaced
90374:cf65b3d033bb 90375:e6bf73e43cf4
3837 0, 4, 0, 3837 0, 4, 0,
3838 doc: /* Allow any pending output from subprocesses to be read by Emacs. 3838 doc: /* Allow any pending output from subprocesses to be read by Emacs.
3839 It is read into the process' buffers or given to their filter functions. 3839 It is read into the process' buffers or given to their filter functions.
3840 Non-nil arg PROCESS means do not return until some output has been received 3840 Non-nil arg PROCESS means do not return until some output has been received
3841 from PROCESS. 3841 from PROCESS.
3842 Non-nil second arg TIMEOUT and third arg TIMEOUT-MSECS are number of 3842
3843 seconds and microseconds to wait; return after that much time whether 3843 Non-nil second arg SECONDS and third arg MILLISEC are number of
3844 or not there is input. 3844 seconds and milliseconds to wait; return after that much time whether
3845 or not there is input. If SECONDS is a floating point number,
3846 it specifies a fractional number of seconds to wait.
3847
3845 If optional fourth arg JUST-THIS-ONE is non-nil, only accept output 3848 If optional fourth arg JUST-THIS-ONE is non-nil, only accept output
3846 from PROCESS, suspending reading output from other processes. 3849 from PROCESS, suspending reading output from other processes.
3847 If JUST-THIS-ONE is an integer, don't run any timers either. 3850 If JUST-THIS-ONE is an integer, don't run any timers either.
3848 Return non-nil iff we received any output before the timeout expired. */) 3851 Return non-nil iff we received any output before the timeout expired. */)
3849 (process, timeout, timeout_msecs, just_this_one) 3852 (process, seconds, millisec, just_this_one)
3850 register Lisp_Object process, timeout, timeout_msecs, just_this_one; 3853 register Lisp_Object process, seconds, millisec, just_this_one;
3851 { 3854 {
3852 int seconds; 3855 int secs, usecs = 0;
3853 int useconds;
3854 3856
3855 if (! NILP (process)) 3857 if (! NILP (process))
3856 CHECK_PROCESS (process); 3858 CHECK_PROCESS (process);
3857 else 3859 else
3858 just_this_one = Qnil; 3860 just_this_one = Qnil;
3859 3861
3860 if (! NILP (timeout_msecs)) 3862 if (!NILP (seconds))
3861 { 3863 {
3862 CHECK_NUMBER (timeout_msecs); 3864 if (INTEGERP (seconds))
3863 useconds = XINT (timeout_msecs); 3865 secs = XINT (seconds);
3864 if (!INTEGERP (timeout)) 3866 else if (FLOATP (seconds))
3865 XSETINT (timeout, 0); 3867 {
3866 3868 double timeout = XFLOAT_DATA (seconds);
3867 { 3869 secs = (int) timeout;
3868 int carry = useconds / 1000000; 3870 usecs = (int) ((timeout - (double) secs) * 1000000);
3869 3871 }
3870 XSETINT (timeout, XINT (timeout) + carry); 3872 else
3871 useconds -= carry * 1000000; 3873 wrong_type_argument (Qnumberp, seconds);
3872 3874
3873 /* I think this clause is necessary because C doesn't 3875 if (INTEGERP (millisec))
3874 guarantee a particular rounding direction for negative 3876 {
3875 integers. */ 3877 int carry;
3876 if (useconds < 0) 3878 usecs += XINT (millisec) * 1000;
3877 { 3879 carry = usecs / 1000000;
3878 XSETINT (timeout, XINT (timeout) - 1); 3880 secs += carry;
3879 useconds += 1000000; 3881 if ((usecs -= carry * 1000000) < 0)
3880 } 3882 {
3881 } 3883 secs--;
3884 usecs += 1000000;
3885 }
3886 }
3887
3888 if (secs < 0 || (secs == 0 && usecs == 0))
3889 secs = -1, usecs = 0;
3882 } 3890 }
3883 else 3891 else
3884 useconds = 0; 3892 secs = NILP (process) ? -1 : 0;
3885
3886 if (! NILP (timeout))
3887 {
3888 CHECK_NUMBER (timeout);
3889 seconds = XINT (timeout);
3890 if (seconds < 0 || (seconds == 0 && useconds == 0))
3891 seconds = -1;
3892 }
3893 else
3894 seconds = NILP (process) ? -1 : 0;
3895 3893
3896 return 3894 return
3897 (wait_reading_process_output (seconds, useconds, 0, 0, 3895 (wait_reading_process_output (secs, usecs, 0, 0,
3898 Qnil, 3896 Qnil,
3899 !NILP (process) ? XPROCESS (process) : NULL, 3897 !NILP (process) ? XPROCESS (process) : NULL,
3900 NILP (just_this_one) ? 0 : 3898 NILP (just_this_one) ? 0 :
3901 !INTEGERP (just_this_one) ? 1 : -1) 3899 !INTEGERP (just_this_one) ? 1 : -1)
3902 ? Qt : Qnil); 3900 ? Qt : Qnil);