Mercurial > emacs
comparison src/process.c @ 69634:5633a1931272
(Faccept_process_output): Fix to comply with lisp reference.
Change arg "timeout" to "seconds" and allow both integer and float value.
Change arg "timeout-msec" to "millisec" and interpret" as milliseconds
rather than microseconds. Fix doc string accordingly.
author | Kim F. Storm <storm@cua.dk> |
---|---|
date | Wed, 22 Mar 2006 22:33:35 +0000 |
parents | 921341a03d5b |
children | 2d844bbbccd4 c1e013e3dc0e e6bf73e43cf4 |
comparison
equal
deleted
inserted
replaced
69633:e432caf2ad0f | 69634:5633a1931272 |
---|---|
3836 0, 4, 0, | 3836 0, 4, 0, |
3837 doc: /* Allow any pending output from subprocesses to be read by Emacs. | 3837 doc: /* Allow any pending output from subprocesses to be read by Emacs. |
3838 It is read into the process' buffers or given to their filter functions. | 3838 It is read into the process' buffers or given to their filter functions. |
3839 Non-nil arg PROCESS means do not return until some output has been received | 3839 Non-nil arg PROCESS means do not return until some output has been received |
3840 from PROCESS. | 3840 from PROCESS. |
3841 Non-nil second arg TIMEOUT and third arg TIMEOUT-MSECS are number of | 3841 |
3842 seconds and microseconds to wait; return after that much time whether | 3842 Non-nil second arg SECONDS and third arg MILLISEC are number of |
3843 or not there is input. | 3843 seconds and milliseconds to wait; return after that much time whether |
3844 or not there is input. If SECONDS is a floating point number, | |
3845 it specifies a fractional number of seconds to wait. | |
3846 | |
3844 If optional fourth arg JUST-THIS-ONE is non-nil, only accept output | 3847 If optional fourth arg JUST-THIS-ONE is non-nil, only accept output |
3845 from PROCESS, suspending reading output from other processes. | 3848 from PROCESS, suspending reading output from other processes. |
3846 If JUST-THIS-ONE is an integer, don't run any timers either. | 3849 If JUST-THIS-ONE is an integer, don't run any timers either. |
3847 Return non-nil iff we received any output before the timeout expired. */) | 3850 Return non-nil iff we received any output before the timeout expired. */) |
3848 (process, timeout, timeout_msecs, just_this_one) | 3851 (process, seconds, millisec, just_this_one) |
3849 register Lisp_Object process, timeout, timeout_msecs, just_this_one; | 3852 register Lisp_Object process, seconds, millisec, just_this_one; |
3850 { | 3853 { |
3851 int seconds; | 3854 int secs, usecs = 0; |
3852 int useconds; | |
3853 | 3855 |
3854 if (! NILP (process)) | 3856 if (! NILP (process)) |
3855 CHECK_PROCESS (process); | 3857 CHECK_PROCESS (process); |
3856 else | 3858 else |
3857 just_this_one = Qnil; | 3859 just_this_one = Qnil; |
3858 | 3860 |
3859 if (! NILP (timeout_msecs)) | 3861 if (!NILP (seconds)) |
3860 { | 3862 { |
3861 CHECK_NUMBER (timeout_msecs); | 3863 if (INTEGERP (seconds)) |
3862 useconds = XINT (timeout_msecs); | 3864 secs = XINT (seconds); |
3863 if (!INTEGERP (timeout)) | 3865 else if (FLOATP (seconds)) |
3864 XSETINT (timeout, 0); | 3866 { |
3865 | 3867 double timeout = XFLOAT_DATA (seconds); |
3866 { | 3868 secs = (int) timeout; |
3867 int carry = useconds / 1000000; | 3869 usecs = (int) ((timeout - (double) secs) * 1000000); |
3868 | 3870 } |
3869 XSETINT (timeout, XINT (timeout) + carry); | 3871 else |
3870 useconds -= carry * 1000000; | 3872 wrong_type_argument (Qnumberp, seconds); |
3871 | 3873 |
3872 /* I think this clause is necessary because C doesn't | 3874 if (INTEGERP (millisec)) |
3873 guarantee a particular rounding direction for negative | 3875 { |
3874 integers. */ | 3876 int carry; |
3875 if (useconds < 0) | 3877 usecs += XINT (millisec) * 1000; |
3876 { | 3878 carry = usecs / 1000000; |
3877 XSETINT (timeout, XINT (timeout) - 1); | 3879 secs += carry; |
3878 useconds += 1000000; | 3880 if ((usecs -= carry * 1000000) < 0) |
3879 } | 3881 { |
3880 } | 3882 secs--; |
3883 usecs += 1000000; | |
3884 } | |
3885 } | |
3886 | |
3887 if (secs < 0 || (secs == 0 && usecs == 0)) | |
3888 secs = -1, usecs = 0; | |
3881 } | 3889 } |
3882 else | 3890 else |
3883 useconds = 0; | 3891 secs = NILP (process) ? -1 : 0; |
3884 | |
3885 if (! NILP (timeout)) | |
3886 { | |
3887 CHECK_NUMBER (timeout); | |
3888 seconds = XINT (timeout); | |
3889 if (seconds < 0 || (seconds == 0 && useconds == 0)) | |
3890 seconds = -1; | |
3891 } | |
3892 else | |
3893 seconds = NILP (process) ? -1 : 0; | |
3894 | 3892 |
3895 return | 3893 return |
3896 (wait_reading_process_output (seconds, useconds, 0, 0, | 3894 (wait_reading_process_output (secs, usecs, 0, 0, |
3897 Qnil, | 3895 Qnil, |
3898 !NILP (process) ? XPROCESS (process) : NULL, | 3896 !NILP (process) ? XPROCESS (process) : NULL, |
3899 NILP (just_this_one) ? 0 : | 3897 NILP (just_this_one) ? 0 : |
3900 !INTEGERP (just_this_one) ? 1 : -1) | 3898 !INTEGERP (just_this_one) ? 1 : -1) |
3901 ? Qt : Qnil); | 3899 ? Qt : Qnil); |