Subject: Re: bug#332: accept-process-output hangs (incompatibility)

From: Stefan Monnier <[email-masked]>
Date: Thu, 29 May 2008 12:57:57 -0400

>> which previous versions accepted this form?
> GNU Emacs 21.3.50.1 (i686-pc-linux-gnu, X toolkit) of 2003-11-26 on gupu.complang.tuwien.ac.at
> GNU Emacs 21.2.50.2 (i686-pc-linux-gnu, X toolkit) of 2002-04-07 on gupu.complang.tuwien.ac.at
> GNU Emacs 20.7.1 (i386-redhat-linux-gnu, X toolkit) of Fri Mar 16 2001 on porky.devel.redhat.com
 
I've installed the patch below, which should fix your problem (note
that the interpretation of the `millisec' argument has changed since
Emacs-21 where it was a microseconds count).

        Stefan

--- process.c.~1.542.~	2008-05-22 17:12:27.000000000 -0400
+++ process.c	2008-05-29 12:52:17.000000000 -0400
@@ -3896,6 +3896,7 @@
 seconds and milliseconds to wait; return after that much time whether
 or not there is input.  If SECONDS is a floating point number,
 it specifies a fractional number of seconds to wait.
+The MILLISEC argument is obsolete and should be avoided.
 
 If optional fourth arg JUST-THIS-ONE is non-nil, only accept output
 from PROCESS, suspending reading output from other processes.
@@ -3911,6 +3912,18 @@
   else
     just_this_one = Qnil;
 
+  if (!NILP (millisec))
+    { /* Obsolete calling convention using integers rather than floats.  */
+      CHECK_NUMBER (millisec);
+      if (NILP (seconds))
+	seconds = make_float (XINT (millisec) / 1000.0);
+      else
+	{
+	  CHECK_NUMBER (seconds);
+	  seconds = make_float (XINT (millisec) / 1000.0 + XINT (seconds));
+	}
+    }
+
   if (!NILP (seconds))
     {
       if (INTEGERP (seconds))
@@ -3924,19 +3937,6 @@
       else
 	wrong_type_argument (Qnumberp, seconds);
 
-      if (INTEGERP (millisec))
-	{
-	  int carry;
-	  usecs += XINT (millisec) * 1000;
-	  carry = usecs / 1000000;
-	  secs += carry;
-	  if ((usecs -= carry * 1000000) < 0)
-	    {
-	      secs--;
-	      usecs += 1000000;
-	    }
-	}
-
       if (secs < 0 || (secs == 0 && usecs == 0))
 	secs = -1, usecs = 0;
     }