* term.c (term_mouse_position): Don't assume time_t wraparound.
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 12 May 2011 20:30:05 +0000 (13:30 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 12 May 2011 20:30:05 +0000 (13:30 -0700)
src/ChangeLog
src/term.c

index a772106..21c03ba 100644 (file)
@@ -1,5 +1,7 @@
 2011-05-12  Paul Eggert  <eggert@cs.ucla.edu>
 
+       * term.c (term_mouse_position): Don't assume time_t wraparound.
+
        Be more systematic about user-interface timestamps.
        Before, the code sometimes used 'Time', sometimes 'unsigned long',
        and sometimes 'EMACS_UINT', to represent these timestamps.  This
@@ -14,6 +16,7 @@
        * menu.c (Fx_popup_menu) [!HAVE_X_WINDOWS]: Likewise.
        * menu.h (xmenu_show): Likewise.
        * term.c (term_mouse_position): Likewise.
+
        * termhooks.h (struct input_event.timestamp): Likewise.
        (struct terminal.mouse_position_hook): Likewise.
        * xmenu.c (create_and_show_popup_menu, xmenu_show): Likewise.
index 34320a1..5fe258c 100644 (file)
@@ -2701,6 +2701,7 @@ term_mouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window,
                     Lisp_Object *y, Time *timeptr)
 {
   struct timeval now;
+  Time sec, usec;
 
   *fp = SELECTED_FRAME ();
   (*fp)->mouse_moved = 0;
@@ -2711,7 +2712,9 @@ term_mouse_position (FRAME_PTR *fp, int insist, Lisp_Object *bar_window,
   XSETINT (*x, last_mouse_x);
   XSETINT (*y, last_mouse_y);
   gettimeofday(&now, 0);
-  *timeptr = (now.tv_sec * 1000) + (now.tv_usec / 1000);
+  sec = now.tv_sec;
+  usec = now.tv_usec;
+  *timeptr = (sec * 1000) + (usec / 1000);
 }
 
 /* Prepare a mouse-event in *RESULT for placement in the input queue.