------------------------------------------------------------ revno: 117641 committer: Paul Eggert branch nick: trunk timestamp: Sun 2014-08-03 23:27:14 -0700 message: * rect.el (rectangle--default-line-number-format): Rename from misspelled rectange--default-line-number-format (Bug#18045). All uses changed. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2014-08-03 15:38:52 +0000 +++ lisp/ChangeLog 2014-08-04 06:27:14 +0000 @@ -1,3 +1,9 @@ +2014-08-04 Paul Eggert + + * rect.el (rectangle--default-line-number-format): Rename + from misspelled rectange--default-line-number-format (Bug#18045). + All uses changed. + 2014-08-03 Paul Eggert Don't mishandle year-9999 dates (Bug#18176). === modified file 'lisp/rect.el' --- lisp/rect.el 2014-07-19 01:43:29 +0000 +++ lisp/rect.el 2014-08-04 06:27:14 +0000 @@ -520,7 +520,7 @@ (setq rectangle-number-line-counter (1+ rectangle-number-line-counter))) -(defun rectange--default-line-number-format (start end start-at) +(defun rectangle--default-line-number-format (start end start-at) (concat "%" (int-to-string (length (int-to-string (+ (count-lines start end) start-at)))) @@ -541,11 +541,11 @@ (start-at (read-number "Number to count from: " 1))) (list start end start-at (read-string "Format string: " - (rectange--default-line-number-format + (rectangle--default-line-number-format start end start-at)))) (list (region-beginning) (region-end) 1 nil))) (unless format - (setq format (rectange--default-line-number-format start end start-at))) + (setq format (rectangle--default-line-number-format start end start-at))) (let ((rectangle-number-line-counter start-at)) (apply-on-rectangle 'rectangle-number-line-callback start end format))) ------------------------------------------------------------ revno: 117640 committer: Dmitry Antipov branch nick: trunk timestamp: Mon 2014-08-04 08:03:31 +0400 message: * keyboard.c (safe_run_hook_funcall): Avoid consing around Vinhibit_quit and prefer internal_condition_case_n to pass args. (safe_run_hooks_error, safe_run_hooks_1): Adjust accordingly. (safe_run_hooks): Remove comment which is not relevant any more. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2014-08-03 23:16:39 +0000 +++ src/ChangeLog 2014-08-04 04:03:31 +0000 @@ -1,3 +1,10 @@ +2014-08-04 Dmitry Antipov + + * keyboard.c (safe_run_hook_funcall): Avoid consing around + Vinhibit_quit and prefer internal_condition_case_n to pass args. + (safe_run_hooks_error, safe_run_hooks_1): Adjust accordingly. + (safe_run_hooks): Remove comment which is not relevant any more. + 2014-08-03 Paul Eggert Don't let big frames overrun the stack. === modified file 'src/keyboard.c' --- src/keyboard.c 2014-08-03 15:38:52 +0000 +++ src/keyboard.c 2014-08-04 04:03:31 +0000 @@ -1852,30 +1852,32 @@ } } -/* Subroutine for safe_run_hooks: run the hook HOOK. */ +/* Subroutine for safe_run_hooks: run the hook, which is ARGS[1]. */ static Lisp_Object -safe_run_hooks_1 (void) +safe_run_hooks_1 (ptrdiff_t nargs, Lisp_Object *args) { - eassert (CONSP (Vinhibit_quit)); - return call0 (XCDR (Vinhibit_quit)); + eassert (nargs == 2); + return call0 (args[1]); } /* Subroutine for safe_run_hooks: handle an error by clearing out the function from the hook. */ static Lisp_Object -safe_run_hooks_error (Lisp_Object error_data) +safe_run_hooks_error (Lisp_Object error, ptrdiff_t nargs, Lisp_Object *args) { - Lisp_Object hook - = CONSP (Vinhibit_quit) ? XCAR (Vinhibit_quit) : Vinhibit_quit; - Lisp_Object fun = CONSP (Vinhibit_quit) ? XCDR (Vinhibit_quit) : Qnil; - Lisp_Object args[4]; - args[0] = build_string ("Error in %s (%S): %S"); - args[1] = hook; - args[2] = fun; - args[3] = error_data; - Fmessage (4, args); + Lisp_Object hook, fun, msgargs[4]; + + eassert (nargs == 2); + hook = args[0]; + fun = args[1]; + msgargs[0] = build_string ("Error in %s (%S): %S"); + msgargs[1] = hook; + msgargs[2] = fun; + msgargs[3] = error; + Fmessage (4, msgargs); + if (SYMBOLP (hook)) { Lisp_Object val; @@ -1907,14 +1909,19 @@ static Lisp_Object safe_run_hook_funcall (ptrdiff_t nargs, Lisp_Object *args) { + Lisp_Object iargs[2]; + struct gcpro gcpro1; + eassert (nargs == 1); - if (CONSP (Vinhibit_quit)) - XSETCDR (Vinhibit_quit, args[0]); - else - Vinhibit_quit = Fcons (Vinhibit_quit, args[0]); - - internal_condition_case (safe_run_hooks_1, Qt, safe_run_hooks_error); - return Qnil; + iargs[0] = Vinhibit_quit; + iargs[1] = args[0]; + + GCPRO1 (*iargs); + gcpro1.nvars = 2; + + internal_condition_case_n (safe_run_hooks_1, 2, iargs, + Qt, safe_run_hooks_error); + RETURN_UNGCPRO (Qnil); } /* If we get an error while running the hook, cause the hook variable @@ -1924,14 +1931,10 @@ void safe_run_hooks (Lisp_Object hook) { - /* FIXME: our `internal_condition_case' does not provide any way to pass data - to its body or to its handlers other than via globals such as - dynamically-bound variables ;-) */ ptrdiff_t count = SPECPDL_INDEX (); + specbind (Qinhibit_quit, hook); - run_hook_with_args (1, &hook, safe_run_hook_funcall); - unbind_to (count, Qnil); } ------------------------------------------------------------ revno: 117639 author: Paul Eggert committer: Paul Eggert branch nick: trunk timestamp: Sun 2014-08-03 16:16:39 -0700 message: Don't let big frames overrun the stack. * dispnew.c (mirrored_line_dance, mirror_line_dance, scrolling): Use SAFE_NALLOCA, not alloca. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2014-08-03 20:34:33 +0000 +++ src/ChangeLog 2014-08-03 23:16:39 +0000 @@ -1,5 +1,9 @@ 2014-08-03 Paul Eggert + Don't let big frames overrun the stack. + * dispnew.c (mirrored_line_dance, mirror_line_dance, scrolling): + Use SAFE_NALLOCA, not alloca. + Fix bug with clang + directory_files_internal + GC (Bug#16986). * dired.c (directory_files_internal): Use a volatile variable to prevent the compiler from optimizing away all copies of a local. === modified file 'src/dispnew.c' --- src/dispnew.c 2014-08-03 12:34:44 +0000 +++ src/dispnew.c 2014-08-03 23:16:39 +0000 @@ -2684,7 +2684,8 @@ int i; /* Make a copy of the original rows. */ - old_rows = alloca (nlines * sizeof *old_rows); + USE_SAFE_ALLOCA; + SAFE_NALLOCA (old_rows, 1, nlines); memcpy (old_rows, new_rows, nlines * sizeof *old_rows); /* Assign new rows, maybe clear lines. */ @@ -2706,6 +2707,8 @@ if (frame_matrix_frame) mirror_line_dance (XWINDOW (frame_matrix_frame->root_window), unchanged_at_top, nlines, copy_from, retained_p); + + SAFE_FREE (); } @@ -2798,7 +2801,8 @@ struct glyph_row *old_rows; /* Make a copy of the original rows of matrix m. */ - old_rows = alloca (m->nrows * sizeof *old_rows); + USE_SAFE_ALLOCA; + SAFE_NALLOCA (old_rows, 1, m->nrows); memcpy (old_rows, m->rows, m->nrows * sizeof *old_rows); for (i = 0; i < nlines; ++i) @@ -2874,6 +2878,8 @@ /* Check that no pointers are lost. */ CHECK_MATRIX (m); + + SAFE_FREE (); } /* Next window on same level. */ @@ -4647,14 +4653,19 @@ int unchanged_at_top, unchanged_at_bottom; int window_size; int changed_lines; - unsigned *old_hash = alloca (FRAME_TOTAL_LINES (frame) * sizeof (int)); - unsigned *new_hash = alloca (FRAME_TOTAL_LINES (frame) * sizeof (int)); - int *draw_cost = alloca (FRAME_TOTAL_LINES (frame) * sizeof (int)); - int *old_draw_cost = alloca (FRAME_TOTAL_LINES (frame) * sizeof (int)); - register int i; - int free_at_end_vpos = FRAME_TOTAL_LINES (frame); + int i; + int height = FRAME_TOTAL_LINES (frame); + int free_at_end_vpos = height; struct glyph_matrix *current_matrix = frame->current_matrix; struct glyph_matrix *desired_matrix = frame->desired_matrix; + verify (sizeof (int) <= sizeof (unsigned)); + verify (alignof (unsigned) % alignof (int) == 0); + unsigned *old_hash; + USE_SAFE_ALLOCA; + SAFE_NALLOCA (old_hash, 4, height); + unsigned *new_hash = old_hash + height; + int *draw_cost = (int *) (new_hash + height); + int *old_draw_cost = draw_cost + height; eassert (current_matrix); @@ -4663,12 +4674,15 @@ number of unchanged lines at the end. */ changed_lines = 0; unchanged_at_top = 0; - unchanged_at_bottom = FRAME_TOTAL_LINES (frame); - for (i = 0; i < FRAME_TOTAL_LINES (frame); i++) + unchanged_at_bottom = height; + for (i = 0; i < height; i++) { /* Give up on this scrolling if some old lines are not enabled. */ if (!MATRIX_ROW_ENABLED_P (current_matrix, i)) - return 0; + { + SAFE_FREE (); + return false; + } old_hash[i] = line_hash_code (frame, MATRIX_ROW (current_matrix, i)); if (! MATRIX_ROW_ENABLED_P (desired_matrix, i)) { @@ -4686,7 +4700,7 @@ if (old_hash[i] != new_hash[i]) { changed_lines++; - unchanged_at_bottom = FRAME_TOTAL_LINES (frame) - i - 1; + unchanged_at_bottom = height - i - 1; } else if (i == unchanged_at_top) unchanged_at_top++; @@ -4696,10 +4710,13 @@ /* If changed lines are few, don't allow preemption, don't scroll. */ if ((!FRAME_SCROLL_REGION_OK (frame) && changed_lines < baud_rate / 2400) - || unchanged_at_bottom == FRAME_TOTAL_LINES (frame)) - return 1; + || unchanged_at_bottom == height) + { + SAFE_FREE (); + return true; + } - window_size = (FRAME_TOTAL_LINES (frame) - unchanged_at_top + window_size = (height - unchanged_at_top - unchanged_at_bottom); if (FRAME_SCROLL_REGION_OK (frame)) @@ -4707,27 +4724,25 @@ else if (FRAME_MEMORY_BELOW_FRAME (frame)) free_at_end_vpos = -1; - /* If large window, fast terminal and few lines in common between - current frame and desired frame, don't bother with i/d calc. */ - if (!FRAME_SCROLL_REGION_OK (frame) - && window_size >= 18 && baud_rate > 2400 - && (window_size >= - 10 * scrolling_max_lines_saved (unchanged_at_top, - FRAME_TOTAL_LINES (frame) - unchanged_at_bottom, - old_hash, new_hash, draw_cost))) - return 0; - - if (window_size < 2) - return 0; - - scrolling_1 (frame, window_size, unchanged_at_top, unchanged_at_bottom, - draw_cost + unchanged_at_top - 1, - old_draw_cost + unchanged_at_top - 1, - old_hash + unchanged_at_top - 1, - new_hash + unchanged_at_top - 1, - free_at_end_vpos - unchanged_at_top); - - return 0; + /* Do id/calc only if small window, or slow terminal, or many lines + in common between current frame and desired frame. But the + window size must be at least 2. */ + if ((FRAME_SCROLL_REGION_OK (frame) + || window_size < 18 || baud_rate <= 2400 + || (window_size + < 10 * scrolling_max_lines_saved (unchanged_at_top, + height - unchanged_at_bottom, + old_hash, new_hash, draw_cost))) + && 2 <= window_size) + scrolling_1 (frame, window_size, unchanged_at_top, unchanged_at_bottom, + draw_cost + unchanged_at_top - 1, + old_draw_cost + unchanged_at_top - 1, + old_hash + unchanged_at_top - 1, + new_hash + unchanged_at_top - 1, + free_at_end_vpos - unchanged_at_top); + + SAFE_FREE (); + return false; } ------------------------------------------------------------ revno: 117638 [merge] committer: Glenn Morris branch nick: trunk timestamp: Sun 2014-08-03 16:34:33 -0400 message: Merge from emacs-24; up to r117423 diff: === modified file 'lisp/calendar/todo-mode.el' --- lisp/calendar/todo-mode.el 2014-07-28 09:39:09 +0000 +++ lisp/calendar/todo-mode.el 2014-08-03 20:34:33 +0000 @@ -5226,7 +5226,7 @@ (defun todo--user-error-if-marked-done-item () "Signal user error on marked done items. -Helper funtion for editing commands that only apply to (possibly +Helper function for editing commands that apply only to (possibly marked) not done todo items." (save-excursion (save-restriction === modified file 'src/ChangeLog' --- src/ChangeLog 2014-08-03 15:38:52 +0000 +++ src/ChangeLog 2014-08-03 20:34:33 +0000 @@ -1,5 +1,16 @@ 2014-08-03 Paul Eggert + Fix bug with clang + directory_files_internal + GC (Bug#16986). + * dired.c (directory_files_internal): Use a volatile variable + to prevent the compiler from optimizing away all copies of a local. + I wonder how many other GC-related bugs like this lurk elsewhere? + + Avoid 100% CPU utilization on ssh session exit (Bug#17691). + * xterm.h (struct x_display_info): New member 'connection'. + * xterm.c (x_term_init, x_delete_terminal): Set and use it, + so that x_delete_terminal has a file descriptor to pass to + delete_keyboard_wait_descriptor. + Don't mishandle year-9999 dates (Bug#18176). * editfns.c (decode_time_components): Store an invalid timespec on overflow, instead of returning false, so that the caller can === modified file 'src/dired.c' --- src/dired.c 2014-04-16 19:43:46 +0000 +++ src/dired.c 2014-08-03 20:34:33 +0000 @@ -150,6 +150,12 @@ Lisp_Object w32_save = Qnil; #endif + /* Don't let the compiler optimize away all copies of DIRECTORY, + which would break GC; see Bug#16986. Although this is required + only in the common case where GC_MARK_STACK == GC_MAKE_GCPROS_NOOPS, + it shouldn't break anything in the other cases. */ + Lisp_Object volatile directory_volatile = directory; + /* Because of file name handlers, these functions might call Ffuncall, and cause a GC. */ list = encoded_directory = dirfilename = Qnil; @@ -325,6 +331,7 @@ list = Fsort (Fnreverse (list), attrs ? Qfile_attributes_lessp : Qstring_lessp); + (void) directory_volatile; RETURN_UNGCPRO (list); } === modified file 'src/xterm.c' --- src/xterm.c 2014-07-30 04:03:45 +0000 +++ src/xterm.c 2014-08-03 20:34:33 +0000 @@ -10815,6 +10815,7 @@ dpyinfo->name_list_element = Fcons (display_name, Qnil); dpyinfo->display = dpy; + dpyinfo->connection = ConnectionNumber (dpyinfo->display); /* Set the name of the terminal. */ terminal->name = xlispstrdup (display_name); @@ -11267,7 +11268,6 @@ x_delete_terminal (struct terminal *terminal) { struct x_display_info *dpyinfo = terminal->display_info.x; - int connection = -1; /* Protect against recursive calls. delete_frame in delete_terminal calls us back when it deletes our last frame. */ @@ -11286,8 +11286,6 @@ and dpyinfo->display was set to 0 to indicate that. */ if (dpyinfo->display) { - connection = ConnectionNumber (dpyinfo->display); - x_destroy_all_bitmaps (dpyinfo); XSetCloseDownMode (dpyinfo->display, DestroyAll); @@ -11329,11 +11327,12 @@ } /* No more input on this descriptor. */ - if (connection != -1) - delete_keyboard_wait_descriptor (connection); + if (0 <= dpyinfo->connection) + delete_keyboard_wait_descriptor (dpyinfo->connection); /* Mark as dead. */ dpyinfo->display = NULL; + dpyinfo->connection = -1; x_delete_display (dpyinfo); unblock_input (); } === modified file 'src/xterm.h' --- src/xterm.h 2014-07-27 13:21:30 +0000 +++ src/xterm.h 2014-08-03 20:34:33 +0000 @@ -138,6 +138,9 @@ /* This says how to access this display in Xlib. */ Display *display; + /* A connection number (file descriptor) for the display. */ + int connection; + /* This is a cons cell of the form (NAME . FONT-LIST-CACHE). */ Lisp_Object name_list_element; ------------------------------------------------------------ revno: 117637 fixes bug: http://debbugs.gnu.org/18176 committer: Paul Eggert branch nick: trunk timestamp: Sun 2014-08-03 08:38:52 -0700 message: Don't mishandle year-9999 dates. * lisp/calendar/parse-time.el (parse-time-rules): Allow years up to most-positive-fixnum. * lisp/calendar/time-date.el (date-to-time): Pass "Specified time is not representable" errors through. * lisp/url/url-cookie.el (url-cookie-expired-p): Treat out-of-range expiration dates as if they were far in the future. * src/editfns.c (decode_time_components): Store an invalid timespec on overflow, instead of returning false, so that the caller can distinguish overflow from other errors. (lisp_time_argument, lisp_seconds_argument): If the time is out of range, signal a time overflow instead of an invalid time spec. * src/keyboard.c (decode_timer): Treat time overflow like other timespec errors. diff: === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2014-08-02 22:52:55 +0000 +++ lisp/ChangeLog 2014-08-03 15:38:52 +0000 @@ -1,3 +1,11 @@ +2014-08-03 Paul Eggert + + Don't mishandle year-9999 dates (Bug#18176). + * calendar/parse-time.el (parse-time-rules): + Allow years up to most-positive-fixnum. + * calendar/time-date.el (date-to-time): + Pass "Specified time is not representable" errors through. + 2014-08-02 Fabián Ezequiel Gallina * progmodes/python.el: Completion code cleanups. === modified file 'lisp/calendar/parse-time.el' --- lisp/calendar/parse-time.el 2014-03-23 23:14:52 +0000 +++ lisp/calendar/parse-time.el 2014-08-03 15:38:52 +0000 @@ -131,7 +131,7 @@ `(((6) parse-time-weekdays) ((3) (1 31)) ((4) parse-time-months) - ((5) (100 4038)) + ((5) (100 ,most-positive-fixnum)) ((2 1 0) ,#'(lambda () (and (stringp parse-time-elt) (= (length parse-time-elt) 8) === modified file 'lisp/calendar/time-date.el' --- lisp/calendar/time-date.el 2014-05-12 23:56:22 +0000 +++ lisp/calendar/time-date.el 2014-08-03 15:38:52 +0000 @@ -119,13 +119,20 @@ (defun date-to-time (date) "Parse a string DATE that represents a date-time and return a time value. If DATE lacks timezone information, GMT is assumed." - (condition-case () + (condition-case err (apply 'encode-time (parse-time-string date)) - (error (condition-case () - (apply 'encode-time - (parse-time-string - (timezone-make-date-arpa-standard date))) - (error (error "Invalid date: %s" date)))))) + (error + (let ((overflow-error '(error "Specified time is not representable"))) + (if (equal err overflow-error) + (apply 'signal err) + (condition-case err + (apply 'encode-time + (parse-time-string + (timezone-make-date-arpa-standard date))) + (error + (if (equal err overflow-error) + (apply 'signal err) + (error "Invalid date: %s" date))))))))) ;; Bit of a mess. Emacs has float-time since at least 21.1. ;; This file is synced to Gnus, and XEmacs packages may have been written === modified file 'lisp/url/ChangeLog' --- lisp/url/ChangeLog 2014-06-26 06:55:15 +0000 +++ lisp/url/ChangeLog 2014-08-03 15:38:52 +0000 @@ -1,3 +1,9 @@ +2014-08-03 Paul Eggert + + Don't mishandle dates in the year 9999 (Bug#18176). + * url-cookie.el (url-cookie-expired-p): Treat out-of-range + expiration dates as if they were far in the future. + 2014-06-26 Leo Liu * url-http.el (url-http-end-of-headers): Remove duplicate defvar. === modified file 'lisp/url/url-cookie.el' --- lisp/url/url-cookie.el 2014-02-05 07:46:40 +0000 +++ lisp/url/url-cookie.el 2014-08-03 15:38:52 +0000 @@ -158,7 +158,9 @@ "Return non-nil if COOKIE is expired." (let ((exp (url-cookie-expires cookie))) (and (> (length exp) 0) - (> (float-time) (float-time (date-to-time exp)))))) + (condition-case () + (> (float-time) (float-time (date-to-time exp))) + (error nil))))) (defun url-cookie-retrieve (host &optional localpart secure) "Retrieve all cookies for a specified HOST and LOCALPART." === modified file 'src/ChangeLog' --- src/ChangeLog 2014-08-03 12:34:44 +0000 +++ src/ChangeLog 2014-08-03 15:38:52 +0000 @@ -1,5 +1,14 @@ 2014-08-03 Paul Eggert + Don't mishandle year-9999 dates (Bug#18176). + * editfns.c (decode_time_components): Store an invalid timespec + on overflow, instead of returning false, so that the caller can + distinguish overflow from other errors. + (lisp_time_argument, lisp_seconds_argument): If the time is out + of range, signal a time overflow instead of an invalid time spec. + * keyboard.c (decode_timer): Treat time overflow like other + timespec errors. + Avoid undefined behavior with signed left shift. Caught by 'gcc -fsanitize=undefined'. * dispextern.h, scroll.c (scrolling_max_lines_saved, scrolling_1): === modified file 'src/editfns.c' --- src/editfns.c 2014-06-23 04:11:29 +0000 +++ src/editfns.c 2014-08-03 15:38:52 +0000 @@ -1516,7 +1516,8 @@ list, generate the corresponding time value. If RESULT is not null, store into *RESULT the converted time; - this can fail if the converted time does not fit into struct timespec. + if the converted time does not fit into struct timespec, + store an invalid timespec to indicate the overflow. If *DRESULT is not null, store into *DRESULT the number of seconds since the start of the POSIX Epoch. @@ -1529,7 +1530,7 @@ EMACS_INT hi, lo, us, ps; if (! (INTEGERP (high) && INTEGERP (low) && INTEGERP (usec) && INTEGERP (psec))) - return 0; + return false; hi = XINT (high); lo = XINT (low); us = XINT (usec); @@ -1555,16 +1556,13 @@ *result = make_timespec ((sec << 16) + lo, us * 1000 + ps / 1000); } else - { - /* Overflow in the highest-order component. */ - return 0; - } + *result = invalid_timespec (); } if (dresult) *dresult = (us * 1e6 + ps) / 1e12 + lo + hi * 65536.0; - return 1; + return true; } /* Decode a Lisp list SPECIFIED_TIME that represents a time. @@ -1576,22 +1574,23 @@ struct timespec lisp_time_argument (Lisp_Object specified_time) { - struct timespec t; if (NILP (specified_time)) - t = current_timespec (); + return current_timespec (); else { Lisp_Object high, low, usec, psec; + struct timespec t; if (! (disassemble_lisp_time (specified_time, &high, &low, &usec, &psec) && decode_time_components (high, low, usec, psec, &t, 0))) error ("Invalid time specification"); + if (! timespec_valid_p (t)) + time_overflow (); + return t; } - return t; } /* Like lisp_time_argument, except decode only the seconds part, - do not allow out-of-range time stamps, do not check the subseconds part, - and always round down. */ + and do not check the subseconds part. */ static time_t lisp_seconds_argument (Lisp_Object specified_time) { @@ -1605,6 +1604,8 @@ && decode_time_components (high, low, make_number (0), make_number (0), &t, 0))) error ("Invalid time specification"); + if (! timespec_valid_p (t)) + time_overflow (); return t.tv_sec; } } === modified file 'src/keyboard.c' --- src/keyboard.c 2014-08-01 15:12:01 +0000 +++ src/keyboard.c 2014-08-03 15:38:52 +0000 @@ -4370,8 +4370,9 @@ if (! NILP (vector[0])) return 0; - return decode_time_components (vector[1], vector[2], vector[3], vector[8], - result, 0); + return (decode_time_components (vector[1], vector[2], vector[3], vector[8], + result, 0) + && timespec_valid_p (*result)); } ------------------------------------------------------------ revno: 117636 committer: Paul Eggert branch nick: trunk timestamp: Sun 2014-08-03 05:34:44 -0700 message: Avoid undefined behavior with signed left shift. Caught by 'gcc -fsanitize=undefined'. * dispextern.h, scroll.c (scrolling_max_lines_saved, scrolling_1): * dispnew.c (line_hash_code, scrolling): * scroll.c (calculate_scrolling, calculate_direct_scrolling): Use 'unsigned', not 'int', for line hashes. (scrolling_max_lines_saved): Avoid mystery constants for hash sizes. diff: === modified file 'src/ChangeLog' --- src/ChangeLog 2014-08-02 17:12:11 +0000 +++ src/ChangeLog 2014-08-03 12:34:44 +0000 @@ -1,3 +1,13 @@ +2014-08-03 Paul Eggert + + Avoid undefined behavior with signed left shift. + Caught by 'gcc -fsanitize=undefined'. + * dispextern.h, scroll.c (scrolling_max_lines_saved, scrolling_1): + * dispnew.c (line_hash_code, scrolling): + * scroll.c (calculate_scrolling, calculate_direct_scrolling): + Use 'unsigned', not 'int', for line hashes. + (scrolling_max_lines_saved): Avoid mystery constants for hash sizes. + 2014-08-02 Paul Eggert Make compare-strings more compatible with old behavior (Bug#17903). === modified file 'src/dispextern.h' --- src/dispextern.h 2014-07-27 13:21:30 +0000 +++ src/dispextern.h 2014-08-03 12:34:44 +0000 @@ -3507,13 +3507,13 @@ /* Defined in scroll.c */ -extern int scrolling_max_lines_saved (int, int, int *, int *, int *); +extern int scrolling_max_lines_saved (int, int, unsigned *, unsigned *, int *); extern void do_line_insertion_deletion_costs (struct frame *, const char *, const char *, const char *, const char *, const char *, const char *, int); -void scrolling_1 (struct frame *, int, int, int, int *, int *, int *, - int *, int); +void scrolling_1 (struct frame *, int, int, int, int *, int *, unsigned *, + unsigned *, int); /* Defined in frame.c */ === modified file 'src/dispnew.c' --- src/dispnew.c 2014-07-28 09:39:09 +0000 +++ src/dispnew.c 2014-08-03 12:34:44 +0000 @@ -1108,10 +1108,10 @@ /* Return a hash code for glyph row ROW, which may be from current or desired matrix of frame F. */ -static int +static unsigned line_hash_code (struct frame *f, struct glyph_row *row) { - int hash = 0; + unsigned hash = 0; if (row->enabled_p) { @@ -4647,8 +4647,8 @@ int unchanged_at_top, unchanged_at_bottom; int window_size; int changed_lines; - int *old_hash = alloca (FRAME_TOTAL_LINES (frame) * sizeof (int)); - int *new_hash = alloca (FRAME_TOTAL_LINES (frame) * sizeof (int)); + unsigned *old_hash = alloca (FRAME_TOTAL_LINES (frame) * sizeof (int)); + unsigned *new_hash = alloca (FRAME_TOTAL_LINES (frame) * sizeof (int)); int *draw_cost = alloca (FRAME_TOTAL_LINES (frame) * sizeof (int)); int *old_draw_cost = alloca (FRAME_TOTAL_LINES (frame) * sizeof (int)); register int i; === modified file 'src/scroll.c' --- src/scroll.c 2014-01-01 07:43:34 +0000 +++ src/scroll.c 2014-08-03 12:34:44 +0000 @@ -90,7 +90,7 @@ /* matrix is of size window_size + 1 on each side. */ struct matrix_elt *matrix, int window_size, int lines_below, - int *draw_cost, int *old_hash, int *new_hash, + int *draw_cost, unsigned *old_hash, unsigned *new_hash, int free_at_end) { register int i, j; @@ -427,7 +427,7 @@ struct matrix_elt *matrix, int window_size, int lines_below, int *draw_cost, int *old_draw_cost, - int *old_hash, int *new_hash, + unsigned *old_hash, unsigned *new_hash, int free_at_end) { register int i, j; @@ -794,7 +794,7 @@ void scrolling_1 (struct frame *frame, int window_size, int unchanged_at_top, int unchanged_at_bottom, int *draw_cost, int *old_draw_cost, - int *old_hash, int *new_hash, int free_at_end) + unsigned *old_hash, unsigned *new_hash, int free_at_end) { struct matrix_elt *matrix = alloca ((window_size + 1) * (window_size + 1) * sizeof *matrix); @@ -829,12 +829,14 @@ int scrolling_max_lines_saved (int start, int end, - int *oldhash, int *newhash, + unsigned *oldhash, unsigned *newhash, int *cost) { - struct { int hash; int count; } lines[01000]; - register int i, h; - register int matchcount = 0; + enum { LOG2_NLINES = 9 }; + enum { NLINES = 1 << LOG2_NLINES }; + struct { unsigned hash; int count; } lines[NLINES]; + int i, h; + int matchcount = 0; int avg_length = 0; int threshold; @@ -855,7 +857,7 @@ { if (cost[i] > threshold) { - h = newhash[i] & 0777; + h = newhash[i] & (NLINES - 1); lines[h].hash = newhash[i]; lines[h].count++; } @@ -865,7 +867,7 @@ matches between old lines and new. */ for (i = start; i < end; i++) { - h = oldhash[i] & 0777; + h = oldhash[i] & (NLINES - 1); if (oldhash[i] == lines[h].hash) { matchcount++; ------------------------------------------------------------ revno: 117635 committer: Glenn Morris branch nick: trunk timestamp: Sat 2014-08-02 23:45:59 -0400 message: * test/automated/Makefile.in (check-tar): New rule. diff: === modified file 'test/ChangeLog' --- test/ChangeLog 2014-08-02 20:22:31 +0000 +++ test/ChangeLog 2014-08-03 03:45:59 +0000 @@ -1,3 +1,7 @@ +2014-08-03 Glenn Morris + + * automated/Makefile.in (check-tar): New rule. + 2014-08-02 Glenn Morris * automated/fns-tests.el (fns-tests-compare-strings): === modified file 'test/automated/Makefile.in' --- test/automated/Makefile.in 2014-06-28 17:18:05 +0000 +++ test/automated/Makefile.in 2014-08-03 03:45:59 +0000 @@ -121,6 +121,11 @@ check-maybe: ${LOGFILES} $(emacs) -l ert -f ert-summarize-tests-batch-and-exit $^ +## Mainly for hydra. +.PHONY: check-tar +check-tar: check + tar -cf logs.tar ${LOGFILES} + .PHONY: mostlyclean clean bootstrap-clean distclean maintainer-clean clean mostlyclean: ------------------------------------------------------------ Use --include-merged or -n0 to see merged revisions.