diff options
| author | Kim F. Storm | 2006-03-22 22:33:35 +0000 |
|---|---|---|
| committer | Kim F. Storm | 2006-03-22 22:33:35 +0000 |
| commit | 5088da42b6a59e95c53ec4a70810b97cce0adf5d (patch) | |
| tree | c12d06c604232ac0c504912e5c079663412e368a /src/process.c | |
| parent | 5a32a2f2ff6cffe93b9722971a71ec711082d696 (diff) | |
| download | emacs-5088da42b6a59e95c53ec4a70810b97cce0adf5d.tar.gz emacs-5088da42b6a59e95c53ec4a70810b97cce0adf5d.zip | |
(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.
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 cf0845fd7af..66cb227bb0a 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -3838,62 +3838,60 @@ DEFUN ("accept-process-output", Faccept_process_output, Saccept_process_output, | |||
| 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--; |
| 3881 | } | 3883 | usecs += 1000000; |
| 3882 | else | 3884 | } |
| 3883 | useconds = 0; | 3885 | } |
| 3884 | 3886 | ||
| 3885 | if (! NILP (timeout)) | 3887 | if (secs < 0 || (secs == 0 && usecs == 0)) |
| 3886 | { | 3888 | secs = -1, usecs = 0; |
| 3887 | CHECK_NUMBER (timeout); | ||
| 3888 | seconds = XINT (timeout); | ||
| 3889 | if (seconds < 0 || (seconds == 0 && useconds == 0)) | ||
| 3890 | seconds = -1; | ||
| 3891 | } | 3889 | } |
| 3892 | else | 3890 | else |
| 3893 | seconds = NILP (process) ? -1 : 0; | 3891 | secs = 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 : |