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.
Paul Eggert [Thu, 28 Jul 2011 20:29:44 +0000 (13:29 -0700)]
* ccl.c: Integer and memory overflow fixes.
(Fccl_execute_on_string): Check for memory overflow.
Use ptrdiff_t rather than EMACS_INT where ptrdiff_t will do.
Redo buffer-overflow calculations to avoid integer overflow.
Paul Eggert [Thu, 28 Jul 2011 20:28:33 +0000 (13:28 -0700)]
* buffer.c: Memory overflow fixes.
(overlays_at, overlays_in, record_overlay_string, overlay_strings):
Don't update size of array until after memory allocation succeeds,
because xmalloc/xrealloc may not return.
Paul Eggert [Thu, 28 Jul 2011 20:27:41 +0000 (13:27 -0700)]
* bidi.c: Integer overflow fix.
(bidi_shelve_header_size): New constant.
(bidi_cache_ensure_space, bidi_shelve_cache): Use it.
(bidi_cache_ensure_space): Avoid integer overflow when allocating.
Alp Aker [Thu, 28 Jul 2011 18:50:05 +0000 (14:50 -0400)]
Fix for raise display property on NS (Bug#8913).
* src/nsfont.m (nsfont_open): Remove assignment to voffset and
unnecessary vars hshink, expand, hd, full_height, min_height.
(nsfont_draw): Use s->ybase as baseline for glyph drawing.
Alp Aker [Thu, 28 Jul 2011 18:26:29 +0000 (14:26 -0400)]
Implement strike-through and overline on NextStep (Bug#8863).
* src/nsfont.m (nsfont_open): Use underline position provided by font,
instead of hard-coded value of 2.
(nsfont_draw): Call ns_draw_text_decoration instead.
* src/nsterm.h: Add declaration for ns_draw_text_decoration.
* src/nsterm.m (ns_draw_text_decoration): New function for drawing
underline, overline, and strike-through.
(ns_dumpglyphs_image, ns_dumpglyphs_stretch): Add call to
ns_draw_text_decoration. Change treatment of cursor drawing to
accomodate underlining, etc.
Eli Zaretskii [Thu, 28 Jul 2011 17:18:25 +0000 (20:18 +0300)]
Turn on bidi-display-reordering by default.
src/buffer.c (init_buffer_once, syms_of_buffer): Set
bidi-display-reordering to t by default.
doc/emacs/mule.texi (Bidirectional Editing): Document the fact that
bidi-display-reordering is t by default.
lispref/display.texi (Bidirectional Display): Document the fact that
bidi-display-reordering is t by default.
Alan Mackenzie [Tue, 26 Jul 2011 19:18:40 +0000 (19:18 +0000)]
Fontify bitfield declarations properly.
cc-langs.el (c-has-bitfields): New lang variable.
(c-symbol-chars): Now exported as a lang variable.
(c-not-primitive-type-keywords): New lang variable.
cc-fonts.el (c-font-lock-declarations): Jump over the QT keyword "more"
to prevent "more slots: ...." being spuriously parsed as a bitfield
declaraion.
cc-engine.el (c-beginning-of-statement-1): Refactor and enhance to handle
bitfield declarations.
(c-punctuation-in): New function.
(c-forward-decl-or-cast-1): Enhance CASE 3 to handle bitfield
declarations properly.
icalendar: Take care of multiple vcalendars in a single file.
lisp/ChangeLog:
* calendar/icalendar.el (icalendar--all-events): Take care of
multiple vcalendars in a single file.
(icalendar--convert-float-to-ical): checkdoc fixes.
* automated/icalendar-tests.el (icalendar-tests--compare-strings):
Removed, simply use string=.
(icalendar--diarytime-to-isotime)
(icalendar--datetime-to-diary-date)
(icalendar--datestring-to-isodate)
(icalendar--format-ical-event)
(icalendar--parse-summary-and-rest)
(icalendar-tests--do-test-import)
(icalendar-tests--do-test-cycle) : Changed argument order of
string= to EXPECTED ACTUAL.
(icalendar--import-format-sample)
(icalendar--format-ical-event)
(icalendar-import-non-recurring)
(icalendar-import-rrule)
(icalendar-import-duration)
(icalendar-import-bug-6766)
(icalendar-real-world): Adjusted to string= instead of
icalendar-tests--compare-strings.
(icalendar-import-multiple-vcalendars): New.
Eli Zaretskii [Mon, 25 Jul 2011 15:36:47 +0000 (18:36 +0300)]
Fix logic of caching display string positions for bidi display.
src/xdisp.c (compute_display_string_pos): Fix logic of caching
previous display string position. Initialize cached_prev_pos to -1.
Fixes slow-down at the beginning of a buffer.
Michael Albinus [Sun, 24 Jul 2011 09:56:26 +0000 (11:56 +0200)]
* net/tramp-sh.el (tramp-barf-unless-okay): Return the value of
`tramp-send-command-and-check' if there is no error.
(tramp-send-command-and-read): Suppress *all* errors if NOERROR.
Andrew Cohen [Sun, 24 Jul 2011 00:19:29 +0000 (00:19 +0000)]
Merge changes made in Gnus trunk.
nnir.el (nnir-search-thread): New function to make an nnir group based on a thread query.
gnus-sum.el (gnus-refer-thread-use-nnir): New variable to control use of nnir in thread referral.
(gnus-summary-refer-thread): Use it.
nnimap.el (nnimap-request-thread): Use it.
Eli Zaretskii [Sat, 23 Jul 2011 10:46:21 +0000 (13:46 +0300)]
Fix pos-visible-in-window-p under bidi redisplay.
src/xdisp.c (move_it_in_display_line_to): Record the best matching
position for TO_CHARPOS while scanning the line, and restore it on
exit if none of the characters scanned was an exact match. Fixes
vertical-motion and pos-visible-in-window-p under bidi redisplay
when exact match is impossible due to invisible text, and the
lines are truncated.
Eli Zaretskii [Sat, 23 Jul 2011 10:42:24 +0000 (13:42 +0300)]
Fix pos-visible-in-window-p under bidi redisplay when lines are truncated.
src/xdisp.c (move_it_in_display_line_to): Record the best matching
position for TO_CHARPOS while scanning the line, and restore it on
exit if none of the characters scanned was an exact match. Fixes
vertical-motion and pos-visible-in-window-p when exact match is
impossible due to invisible text, and the lines are truncated.
Eli Zaretskii [Sat, 23 Jul 2011 07:42:56 +0000 (10:42 +0300)]
Speed up keyboard auto-repeat cursor motion under bidi redisplay.
src/xdisp.c (compute_stop_pos_backwards): New function.
(next_element_from_buffer): Call compute_stop_pos_backwards to
find a suitable prev_stop when we find ourselves before
base_level_stop.
(reseat): Don't look for prev_stop, as that could mean a very long
run.
<cached_disp_pos, cached_disp_buffer, cached_disp_modiff>
<cached_disp_overlay_modiff>: Cache for last found display string
position.
(compute_display_string_pos): Return the cached position if asked
about the same buffer in the same area of character positions, and
the buffer wasn't changed since the time the display string
position was cached.
Eli Zaretskii [Fri, 22 Jul 2011 14:09:51 +0000 (17:09 +0300)]
Fix previous change that broke faces in bidirectional text.
src/xdisp.c (compute_stop_pos_backwards): New function.
(handle_stop_backwards): Revert last change.
(next_element_from_buffer): Call compute_stop_pos_backwards to
find a suitable prev_stop when we find ourselves before
base_level_stop. Remove the funky search for 1000 character
positions back.
Martin Rudalics [Thu, 21 Jul 2011 08:27:44 +0000 (10:27 +0200)]
Fix size adjustment calls in display-buffer subroutines.
* window.el (display-buffer-pop-up-window)
(display-buffer-pop-up-side-window)
(display-buffer-in-side-window): Call display-buffer-set-height
and display-buffer-set-width after setting the new window's
buffer so `fit-window-to-buffer' and friends work on the right
buffer.