emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/src/mac.c,v


From: YAMAMOTO Mitsuharu
Subject: [Emacs-diffs] Changes to emacs/src/mac.c,v
Date: Sun, 10 Sep 2006 05:51:30 +0000

CVSROOT:        /cvsroot/emacs
Module name:    emacs
Changes by:     YAMAMOTO Mitsuharu <mituharu>   06/09/10 05:51:29

Index: mac.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/mac.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -b -r1.66 -r1.67
--- mac.c       8 Sep 2006 08:17:58 -0000       1.66
+++ mac.c       10 Sep 2006 05:51:29 -0000      1.67
@@ -4910,7 +4910,7 @@
   HICommand command;
 
   bzero (&command, sizeof (HICommand));
-  command.commandID = mac_get_code_from_arg (command_id , 0);
+  command.commandID = mac_get_code_from_arg (command_id, 0);
 
   BLOCK_INPUT;
   err = ProcessHICommand (&command);
@@ -5055,10 +5055,10 @@
   OSStatus err = noErr;
   int r;
   EMACS_TIME select_timeout;
-  SELECT_TYPE ofds[3];
+  static SELECT_TYPE ofds[3];
 
   if (inhibit_window_system || noninteractive
-      || rfds == NULL || !FD_ISSET (0, rfds))
+      || nfds < 1 || rfds == NULL || !FD_ISSET (0, rfds))
     return select (nfds, rfds, wfds, efds, timeout);
 
   FD_CLR (0, rfds);
@@ -5073,18 +5073,22 @@
     ofds[2] = *efds;
   else
     {
-      int maxfd;
       EventTimeout timeoutval =
        (timeout
         ? (EMACS_SECS (*timeout) * kEventDurationSecond
            + EMACS_USECS (*timeout) * kEventDurationMicrosecond)
         : kEventDurationForever);
 
-      for (maxfd = nfds - 1; maxfd > 0; maxfd--)
-       if (FD_ISSET (maxfd, rfds) || (wfds && FD_ISSET (maxfd, wfds)))
-         break;
+      FD_SET (0, rfds);                /* sentinel */
+      do
+       {
+         nfds--;
+       }
+      while (!(FD_ISSET (nfds, rfds) || (wfds && FD_ISSET (nfds, wfds))));
+      nfds++;
+      FD_CLR (0, rfds);
 
-      if (maxfd == 0)
+      if (nfds == 1)
        return select_and_poll_event (nfds, rfds, wfds, efds, timeout);
 
       /* Avoid initial overhead of RunLoop setup for the case that
@@ -5111,20 +5115,19 @@
          int minfd, fd;
          CFRunLoopRef runloop =
            (CFRunLoopRef) GetCFRunLoopFromEventLoop (GetCurrentEventLoop ());
-         static CFSocketContext context;
+         static CFSocketContext context = {0, &ofds, NULL, NULL, NULL};
          static CFMutableDictionaryRef sources;
 
-         context.info = ofds;
          if (sources == NULL)
            sources =
              CFDictionaryCreateMutable (NULL, 0, NULL,
                                         &kCFTypeDictionaryValueCallBacks);
 
-         for (minfd = 1; minfd < maxfd; minfd++)
+         for (minfd = 1; ; minfd++) /* nfds-1 works as a sentinel.  */
            if (FD_ISSET (minfd, rfds) || (wfds && FD_ISSET (minfd, wfds)))
              break;
 
-         for (fd = minfd; fd <= maxfd; fd++)
+         for (fd = minfd; fd < nfds; fd++)
            if (FD_ISSET (fd, rfds) || (wfds && FD_ISSET (fd, wfds)))
              {
                void *key = (void *) fd;
@@ -5157,7 +5160,7 @@
          err = ReceiveNextEvent (0, NULL, timeoutval,
                                  kEventLeaveInQueue, NULL);
 
-         for (fd = minfd; fd <= maxfd; fd++)
+         for (fd = minfd; fd < nfds; fd++)
            if (FD_ISSET (fd, rfds) || (wfds && FD_ISSET (fd, wfds)))
              {
                void *key = (void *) fd;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]