Yann Dirson writes:
> 
> FWIW - restricted the duration after which the beep occurs:
> 
> - more than 11days 00:26:40 (15866min)
> - less than 11days 17:50:22 (16910min)

If you keep measuring, you'll end up at 11 days 13:46:40 (exactly 1 million
seconds). The magic value 1000000 is used for an "infinite" sleep after
displaying the final time (see "next_sec=1000000;" around line 698 of
xjig.C). Nobody expected you to admire your work that long.

I think the exact time will be 1 million seconds after you started, not 1
million seconds after you finished.

Up the magic number to a billion and you will have to try really hard to hit
it again.

But here's something even better: a patch to eliminate the magic number by
adding an explicit flag for the end phase when the clock is no longer
ticking. Besides fixing the weird behavior at the megasecond mark, this also
makes it stop waking up once per second after the puzzle is finished.

diff -u xjig-2.4/xjig.C xjig-2.4/xjig.C
--- xjig-2.4/xjig.C
+++ xjig-2.4/xjig.C
@@ -669,6 +669,7 @@
                                struct timeval timeout;
                                /*struct*/ fd_set readfds;
                                int             nfds;
+                               static int end_phase;
        
                                FD_ZERO( &readfds );
                                FD_SET(  ConnectionNumber(dpy), &readfds  );
@@ -677,7 +678,7 @@
                                timeout.tv_sec  = 0;
                                double current_time=GetCurrentTime();
                                timeout.tv_usec = (long)(1000000 * 
(1.0-(current_time-floor(current_time))));
-                               select( nfds, FDS_TYPE &readfds, 0, 0, &timeout 
);
+                               select( nfds, FDS_TYPE &readfds, 0, 0, 
end_phase?NULL:&timeout );
        
                                current_time = GetCurrentTime();
                                //      printf( "%g\n", current_time );
@@ -689,13 +690,13 @@
                                                        next_sec / 60, next_sec 
% 60 );
                                                if (!shapes)    
XStoreName(dpy,win,buffer);
                                        }
-                                       else {
+                                       else if(!end_phase) {
                                                sprintf( buffer, "no more tiles 
left at:  %02ld:%02ld",
                                                        next_sec / 60, next_sec 
% 60 );
                                                if (!shapes)    
XStoreName(dpy,win,buffer);
                                                XBell(dpy,100);
                                                XFlush(dpy);
-                                               next_sec=1000000;
+                                               end_phase=1;
                                        }
                                }
                        }

-- 
Alan Curry



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to