Eli Zaretskii [Fri, 5 Aug 2011 11:04:44 +0000 (14:04 +0300)]
Fix bug #9221 with memory leak in bidi display.
Add code to monitor memory allocation for bidi cache shelving.
src/xdisp.c (display_line): Release buffer allocated for shelved bidi
cache.
src/bidi.c (bidi_shelve_cache, bidi_unshelve_cache): Track total
amount allocated this far in `bidi_cache_total_alloc'.
(bidi_unshelve_cache): Accept an additional argument JUST_FREE; if
non-zero, only free the data buffer without restoring the cache
contents. All callers changed.
src/dispextern.h (bidi_unshelve_cache): Update prototype.
src/xdisp.c (SAVE_IT, pos_visible_p, move_it_in_display_line_to)
(move_it_in_display_line, move_it_to)
(move_it_vertically_backward, move_it_by_lines): Replace the call
to xfree to an equivalent call to bidi_unshelve_cache.
(move_it_in_display_line_to): Fix logic of returning
MOVE_POS_MATCH_OR_ZV in the bidi case.
Eli Zaretskii [Fri, 5 Aug 2011 10:48:37 +0000 (13:48 +0300)]
Fix bug #9221 with resource allocation under word-wrap.
Add diagnostic facility for monitoring memory allocated for cache shelving.
src/xdisp.c (display_line): Release buffer allocated for shelved bidi
cache. (Bug#9221)
src/bidi.c (bidi_shelve_cache, bidi_unshelve_cache): Track total
amount allocated this far in `bidi_cache_total_alloc'.
(bidi_unshelve_cache): Accept an additional argument JUST_FREE; if
non-zero, only free the data buffer without restoring the cache
contents. All callers changed.
src/dispextern.h (bidi_unshelve_cache): Update prototype.
src/xdisp.c (SAVE_IT, pos_visible_p, move_it_in_display_line_to)
(move_it_in_display_line, move_it_to)
(move_it_vertically_backward, move_it_by_lines): Replace the call
to xfree to an equivalent call to bidi_unshelve_cache.
(move_it_in_display_line_to): Fix logic of returning
MOVE_POS_MATCH_OR_ZV in the bidi case.
Martin Rudalics [Fri, 5 Aug 2011 06:23:23 +0000 (08:23 +0200)]
Turn some defsubsts into defuns and revert part of last switch-to-buffer fix.
* window.el (display-buffer-same-window)
(display-buffer-same-frame, display-buffer-other-window)
(pop-to-buffer-same-window, pop-to-buffer-same-frame)
(pop-to-buffer-other-window)
(pop-to-buffer-same-frame-other-window)
(pop-to-buffer-other-frame): Make them defuns.
(switch-to-buffer): Don't set LABEL argument of pop-to-buffer.
Jan Djärv [Thu, 4 Aug 2011 11:06:22 +0000 (13:06 +0200)]
Set _NET_WM_WINDOW_OPACITY on outer window manager window also.
* xterm.c (x_find_topmost_parent): New function.
(x_set_frame_alpha): Find topmost parent window with
x_find_topmost_parent and set the property there also.
(handle_one_xevent): Call x_set_frame_alpha on ReparentNotify.
Daiki Ueno [Thu, 4 Aug 2011 06:55:53 +0000 (15:55 +0900)]
Make sure GPG keys are usable when composing non-MIME messages (bug#8955).
* mml1991.el (mml1991-epg-find-usable-key)
(mml1991-epg-find-usable-secret-key): New function.
(mml1991-epg-sign): Check if signing key is usable.
(mml1991-epg-encrypt): Check if encrypting key is usable (bug#8955).
Andrew Cohen [Wed, 3 Aug 2011 22:09:04 +0000 (22:09 +0000)]
nnir.el (nnir-read-server-parm): Add an argument to restrict to server-variables only. This should fix a bug introduced with commit e1889675b7f4adf057833c5513c9374134c4e053.
(nnir-run-query): 'nnir-search-engine should not be set from the global environment.
Stefan Monnier [Wed, 3 Aug 2011 21:40:06 +0000 (17:40 -0400)]
* src/keymap.c (Fmake_composed_keymap): Move to subr.el.
* lisp/subr.el (make-composed-keymap): Move from C. Change calling
convention, and improve docstring to bring attention to a subtle point.
* lisp/minibuffer.el (completing-read-default): Adjust accordingly.
Eli Zaretskii [Tue, 2 Aug 2011 19:16:32 +0000 (22:16 +0300)]
Fix bug #9218 with slow cursor motion and scrolling Org Mode buffers.
src/dispextern.h (struct bidi_it): New member disp_prop_p.
src/xdisp.c: Remove one-slot cache of display string positions.
(compute_display_string_pos): Accept an additional argument
DISP_PROP_P; callers changed. Scan at most 5K characters forward
for a display string or property. If found, set DISP_PROP_P
non-zero.
src/bidi.c (bidi_fetch_char): Accept an additional argument
DISP_PROP_P, and pass it to compute_display_string_pos. Only
handle text covered by a display string if DISP_PROP_P is returned
non-zero. All callers of bidi_fetch_char changed.
Martin Rudalics [Mon, 1 Aug 2011 18:10:58 +0000 (20:10 +0200)]
Don't set dedicated status for reused normal windows (Bug#9215).
* window.el (display-buffer-in-window): Don't set dedicated status
of window here (Bug#9215).
(display-buffer-pop-up-window, display-buffer-pop-up-frame)
(display-buffer-pop-up-side-window)
(display-buffer-in-side-window): Set dedicated status of window
here.
Eli Zaretskii [Mon, 1 Aug 2011 17:34:04 +0000 (20:34 +0300)]
Fix bug #9212 with selective-display under bidi.
src/xdisp.c (forward_to_next_line_start): Accept additional argument
BIDI_IT_PREV, and store into it the state of the bidi iterator had
on the newline.
(reseat_at_next_visible_line_start): Use the bidi iterator state
returned by forward_to_next_line_start to restore the state of
it->bidi_it after backing up to previous newline. (Bug#9212)
nnmaildir.el (nnmaildir-request-accept-article): Don't call `unix-sync' unless it's defined.
gnus-art.el (gnus-article-stop-animations): Use `elt' instead of `aref' for XEmacs compatibiltiy.
spam.el (spam-fetch-field-fast): Rewrite slightly for clarity.
gnus-sum.el (gnus-summary-refer-thread): Since lambdas aren't closures, quote the form properly (bug#9194).
gnus-sum.el (gnus-summary-insert-new-articles): Clean up slightly.
(gnus-summary-insert-new-articles): Protect against servers that are down.
Fix copyrights for javascript and python grammars.
Since these grammars were transcribed from the ECMAScript spec (BSD
licensed) and Python sources (PSL) respectively, the copyright and
license notices must be included in these files.
Juri Linkov [Sat, 30 Jul 2011 09:14:58 +0000 (12:14 +0300)]
* lisp/dired-aux.el (dired-touch-initial): Remove function.
(dired-do-chxxx): For op-symbol `touch', set `initial' to the
current time, and `default' to the last modification time of the
current marked file.
Paul Eggert [Fri, 29 Jul 2011 05:12:49 +0000 (22:12 -0700)]
* xterm.c: Integer and memory overflow issues.
(x_color_cells, handle_one_xevent, x_term_init):
Check for size calculation overflow.
(x_color_cells): Don't store size until memory allocation succeeds.
(handle_one_xevent): Use ptrdiff_t, not int, for byte counts.
(x_term_init): Don't assume length fits in int (sprintf is limited
to int size).
Paul Eggert [Fri, 29 Jul 2011 05:08:30 +0000 (22:08 -0700)]
* xselect.c: Integer and memory overflow issues.
(X_LONG_SIZE, X_USHRT_MAX, X_ULONG_MAX): New macros.
Use them to make the following changes clearer.
(MAX_SELECTION_QUANTUM): Make the other bounds on this value clearer.
This change doesn't affect the value now, but it may help remind
future maintainers not to raise the value too much later.
(SELECTION_QUANTUM): Remove, replacing with ...
(selection_quantum): ... new function, which avoids overflow.
All uses changed.
(struct selection_data.size): Now ptrdiff_t, not int, to avoid
assumption that selection length fits in 'int'.
(x_reply_selection_request, x_handle_selection_request)
(x_get_window_property, receive_incremental_selection)
(x_get_window_property_as_lisp_data, selection_data_to_lisp_data)
(lisp_data_to_selection_data, clean_local_selection_data):
Use ptrdiff_t, not int, to record length of selection.
(x_reply_selection_request, x_get_window_property)
(receive_incremental_selection, x_property_data_to_lisp):
Redo calculations to avoid overflow.
(x_reply_selection_request): When sending hint, ceiling it at
X_ULONG_MAX rather than relying on wraparound overflow to send
something.
(x_get_window_property, receive_incremental_selection)
(lisp_data_to_selection_data, x_property_data_to_lisp):
Check for size-calculation overflow.
(x_get_window_property, receive_incremental_selection)
(lisp_data_to_selection_data, Fx_register_dnd_atom):
Don't store size until memory allocation succeeds.
(x_get_window_property): Plug memory leak on memory exhaustion.
Don't double-block input; malloc is safe here. Don't assume 2**34
- 4 fits in unsigned long. Add an xassert to check
XGetWindowProperty overflow. Be more careful about overflow
calculations, and distinguish size from memory overflow better.
(receive_incremental_selection): When tracing, don't assume
unsigned int is less than INT_MAX.
(x_selection_data_to_lisp_data): Remove unnecessary (and in theory
harmful) conversions of unsigned short to int.
(lisp_data_to_selection_data): Don't assume that integers
in the range -65535 through -1 fit in an X unsigned short.
Don't assume that ULONG_MAX == X_ULONG_MAX. Don't store into
result parameters unless successful. Rely on cons_to_unsigned
to report problems with elements; the old code wasn't right anyway.
(x_check_property_data): Check for int overflow; we cannot use
a wider type due to X limits.
(x_handle_dnd_message): Use unsigned int, to avoid int overflow.
Paul Eggert [Fri, 29 Jul 2011 01:55:31 +0000 (18:55 -0700)]
* xfns.c: Integer and memory overflow fixes.
(x_encode_text, x_set_name_internal, Fx_change_window_property):
Use ptrdiff_t, not int, to count sizes, since they can exceed
INT_MAX in size. Check for size calculation overflow.
Paul Eggert [Fri, 29 Jul 2011 01:50:56 +0000 (18:50 -0700)]
* xdisp.c: Integer and memory overflow fixes.
(store_mode_line_noprop_char, x_consider_frame_title):
Use ptrdiff_t, not int, for sizes.
(store_mode_line_noprop_char): Don't update size until alloc done.
Paul Eggert [Fri, 29 Jul 2011 01:49:31 +0000 (18:49 -0700)]
* tparam.c: Integer and memory overflow fixes.
(tparam1): Use ptrdiff_t, not int, for sizes.
Don't update size until alloc done.
Redo size calculations to avoid overflow.
Check for size calculation overflow.
Paul Eggert [Fri, 29 Jul 2011 01:24:19 +0000 (18:24 -0700)]
* termcap.c: Integer and memory overflow issues.
(tgetent): Use ptrdiff_t, not int, to record results of
subtracting pointers.
(gobble_line): Check for overflow more carefully. Don't update size
until alloc done.
Paul Eggert [Fri, 29 Jul 2011 01:22:19 +0000 (18:22 -0700)]
* term.c: Integer and memory overflow issues.
(max_frame_lines): Remove; unused.
(encode_terminal_src_size, encode_terminal_dst_size): Now ptrdiff_t,
not int.
(encode_terminal_code, calculate_costs): Check for size
calculation overflow.
(encode_terminal_code): Use ptrdiff_t, not int, to record glyph
table lengths and related sizes. Don't update size until alloc
done. Redo calculations to avoid overflow.
(calculate_costs): Don't bother calling xmalloc when xrealloc will do.
Paul Eggert [Fri, 29 Jul 2011 01:16:54 +0000 (18:16 -0700)]
* sysdep.c: Integer and memory overflow issues.
(system_process_attributes): Use ptrdiff_t, not int, for command
line length. Do not attempt to address one before the beginning
of an array, as that's not portable.
Paul Eggert [Fri, 29 Jul 2011 00:32:09 +0000 (17:32 -0700)]
* keymap.c: Integer overflow fixes.
(cmm_size, current_minor_maps): Use ptrdiff_t, not int, to count maps.
(current_minor_maps): Check for size calculation overflow.
* keymap.h: Change prototypes to match the above.
Paul Eggert [Fri, 29 Jul 2011 00:30:00 +0000 (17:30 -0700)]
* keyboard.c: Integer and memory overflow fixes.
(read_char, menu_bar_items, tool_bar_items, read_char_x_menu_prompt)
(read_char_minibuf_menu_width, read_char_minibuf_menu_prompt)
(follow_key, read_key_sequence): Use ptrdiff_t, not int, to count maps.
(read_char_minibuf_menu_prompt): Check for overflow in size
calculations. Don't update size until allocation succeeds. Redo
calculations to avoid overflow.
* keyboard.h: Change prototypes to match the above.
Paul Eggert [Fri, 29 Jul 2011 00:23:08 +0000 (17:23 -0700)]
* image.c: Integer and memory overflow fixes.
(RANGED_INTEGERP, TYPE_RANGED_INTEGERP): Remove; these are duplicate
now that they've been promoted to lisp.h.
(x_allocate_bitmap_record, x_alloc_image_color)
(make_image_cache, cache_image, xpm_load):
Don't update size until alloc is done.
(xpm_load, lookup_rgb_color, lookup_pixel_color, x_to_xcolors)
(x_detect_edges):
Check for size calculation overflow.
(ct_colors_allocated_max): New constant.
(x_to_xcolors, x_detect_edges): Reorder multiplicands to avoid
overflow.
Paul Eggert [Thu, 28 Jul 2011 23:58:05 +0000 (16:58 -0700)]
* gtkutil.c: Integer overflow fixes.
(get_utf8_string, xg_store_widget_in_map):
Check for size-calculation overflow.
(get_utf8_string): Use ptrdiff_t, not size_t, where either will
do, as we prefer signed integers.
(id_to_widget.max_size, id_to_widget.used)
(xg_store_widget_in_map, xg_remove_widget_from_map)
(xg_get_widget_from_map, xg_get_scroll_id_for_window)
(xg_remove_scroll_bar, xg_update_scrollbar_pos):
Use and return ptrdiff_t, not int.
(xg_gtk_scroll_destroy): Don't assume ptrdiff_t fits in int.
* gtkutil.h: Change prototypes to match the above.
Paul Eggert [Thu, 28 Jul 2011 21:49:16 +0000 (14:49 -0700)]
* frame.c: Integer overflow fixes.
(set_menu_bar_lines, x_set_frame_parameters, x_set_scroll_bar_width)
(x_figure_window_size): Check for integer overflow.
(x_set_alpha): Do not assume XINT fits in int.
Paul Eggert [Thu, 28 Jul 2011 21:37:15 +0000 (14:37 -0700)]
* editfns.c: Integer and memory overflow fixes.
(set_time_zone_rule): Don't assume environment length fits in int.
(message_length): Now ptrdiff_t, not int.
(Fmessage_box): Don't update size until allocation succeeds.
Don't assume message length fits in int.
(Fformat): Use ptrdiff_t, not EMACS_INT, where ptrdiff_t will do.
Paul Eggert [Thu, 28 Jul 2011 21:34:39 +0000 (14:34 -0700)]
* doc.c: Integer and memory overflow fixes.
(get_doc_string_buffer_size): Now ptrdiff_t, not int.
(get_doc_string): Check for size calculation overflow.
Don't update size until allocation succeeds.
(get_doc_string, Fsubstitute_command_keys): Use ptrdiff_t, not
EMACS_INT, where ptrdiff_t will do.
(Fsubstitute_command_keys): Check for string overflow.