diff options
Diffstat (limited to 'src/process.c')
| -rw-r--r-- | src/process.c | 74 |
1 files changed, 36 insertions, 38 deletions
diff --git a/src/process.c b/src/process.c index 159f8001bbc..9b47f1cae31 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -3839,62 +3839,60 @@ DEFUN ("accept-process-output", Faccept_process_output, Saccept_process_output, | |||
| 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--; |
| 3882 | } | 3884 | usecs += 1000000; |
| 3883 | else | 3885 | } |
| 3884 | useconds = 0; | 3886 | } |
| 3885 | 3887 | ||
| 3886 | if (! NILP (timeout)) | 3888 | if (secs < 0 || (secs == 0 && usecs == 0)) |
| 3887 | { | 3889 | secs = -1, usecs = 0; |
| 3888 | CHECK_NUMBER (timeout); | ||
| 3889 | seconds = XINT (timeout); | ||
| 3890 | if (seconds < 0 || (seconds == 0 && useconds == 0)) | ||
| 3891 | seconds = -1; | ||
| 3892 | } | 3890 | } |
| 3893 | else | 3891 | else |
| 3894 | seconds = NILP (process) ? -1 : 0; | 3892 | secs = 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 : |