Mercurial > emacs
changeset 2291:bee5c1693cac
* dispnew.c (Fsleep_for): Make this take two arguments SECONDS and
MILLISECONDS, which add, rather than a second argument which says
"treat the first argument as milliseconds."
(Fsit_for): Same thing.
(Fsleep_for_milliseconds): Deleted; this can be done with Fsleep_for.
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Sat, 20 Mar 1993 23:03:35 +0000 |
parents | be6c70bd6e33 |
children | 4759343bbaad |
files | src/dispnew.c |
diffstat | 1 files changed, 52 insertions(+), 54 deletions(-) [+] |
line wrap: on
line diff
--- a/src/dispnew.c Sat Mar 20 22:58:54 1993 +0000 +++ b/src/dispnew.c Sat Mar 20 23:03:35 1993 +0000 @@ -1793,30 +1793,44 @@ } DEFUN ("sleep-for", Fsleep_for, Ssleep_for, 1, 2, 0, - "Pause, without updating display, for ARG seconds.\n\ -Optional second arg non-nil means ARG is measured in milliseconds.\n\ + "Pause, without updating display, for SECONDS seconds.\n\ +Optional second arg MILLISECONDS specifies an additional wait period,\n\ +in milliseconds.\n\ \(Not all operating systems support milliseconds.)") - (arg, millisec) - Lisp_Object arg, millisec; + (seconds, milliseconds) + Lisp_Object seconds, milliseconds; { - int usec = 0; - int sec; + int sec, usec; + + CHECK_NUMBER (seconds, 0); + sec = XINT (seconds); + + if (NILP (milliseconds)) + XSET (milliseconds, Lisp_Int, 0); + else + CHECK_NUMBER (milliseconds, 1); + usec = XINT (milliseconds); - CHECK_NUMBER (arg, 0); - sec = XINT (arg); +#ifndef EMACS_HAS_USECS + if (sec == 0 && usec != 0) + error ("millisecond `sleep-for' not supported on %s", SYSTEM_TYPE); +#endif + + /* Assure that 0 <= usec < 1000000. */ + if (usec < 0) + { + /* We can't rely on the rounding being correct if user is negative. */ + if (-1000000 < usec) + sec--, usec += 1000000; + else + sec -= -usec / 1000000, usec = 1000000 - (-usec % 1000000); + } + else + sec += usec / 1000000, usec %= 1000000; + if (sec <= 0) return Qnil; - if (!NILP (millisec)) - { -#ifndef EMACS_HAS_USECS - error ("millisecond `sleep-for' not supported on %s", SYSTEM_TYPE); -#else - usec = sec % 1000 * 1000; - sec /= 1000; -#endif - } - { Lisp_Object zero; @@ -1824,7 +1838,10 @@ wait_reading_process_input (sec, usec, zero, 0); } -#if 0 /* No wait_reading_process_input */ + /* We should always have wait_reading_process_input; we have a dummy + implementation for systems which don't support subprocesses. */ +#if 0 + /* No wait_reading_process_input */ immediate_quit = 1; QUIT; @@ -1916,53 +1933,34 @@ } DEFUN ("sit-for", Fsit_for, Ssit_for, 1, 3, 0, - "Perform redisplay, then wait for ARG seconds or until input is available.\n\ -Optional second arg non-nil means ARG counts in milliseconds.\n\ + "Perform redisplay, then wait for SECONDS seconds or until input is available.\n\ +Optional second arg MILLISECONDS specifies an additional wait period, in\n\ +milliseconds.\n\ Optional third arg non-nil means don't redisplay, just wait for input.\n\ Redisplay is preempted as always if input arrives, and does not happen\n\ if input is available before it starts.\n\ Value is t if waited the full time with no input arriving.") - (arg, millisec, nodisp) - Lisp_Object arg, millisec, nodisp; + (seconds, milliseconds, nodisp) + Lisp_Object seconds, milliseconds, nodisp; { - int usec = 0; - int sec; + int sec, usec; - CHECK_NUMBER (arg, 0); - sec = XINT (arg); + CHECK_NUMBER (seconds, 0); + sec = XINT (seconds); - if (!NILP (millisec)) - { + if (NILP (milliseconds)) + XSET (milliseconds, Lisp_Int, 0); + else + CHECK_NUMBER (milliseconds, 1); + usec = XINT (milliseconds); + #ifndef EMACS_HAS_USECS - error ("millisecond `sit-for' not supported on %s", SYSTEM_TYPE); -#else - usec = (sec % 1000) * 1000; - sec /= 1000; + if (usec != 0 && sec == 0) + error ("millisecond `sit-for' not supported on %s", SYSTEM_TYPE); #endif - } return sit_for (sec, usec, 0, NILP (nodisp)); } - -DEFUN ("sleep-for-millisecs", Fsleep_for_millisecs, Ssleep_for_millisecs, - 1, 1, 0, - "Pause, without updating display, for ARG milliseconds.") - (arg) - Lisp_Object arg; -{ - Lisp_Object zero; - -#ifndef EMACS_HAS_USECS - error ("sleep-for-millisecs not supported on %s", SYSTEM_TYPE); -#else - CHECK_NUMBER (arg, 0); - - XFASTINT (zero) = 0; - wait_reading_process_input (XINT (arg) / 1000, XINT (arg) % 1000 * 1000, - zero, 0); - return Qnil; -#endif /* EMACS_HAS_USECS */ -} char *terminal_type;