ChangeLog 287 KB
Newer Older
1 2 3 4
2011-08-27  Juanma Barranquero  <lekktu@gmail.com>

	* makefile.w32-in ($(BLD)/alloc.$(O)): Depend on lib/verify.h.

Paul Eggert's avatar
Paul Eggert committed
5
2011-08-26  Paul Eggert  <eggert@cs.ucla.edu>
6

Paul Eggert's avatar
Paul Eggert committed
7
	Integer and memory overflow issues (Bug#9196).
8

9 10 11 12 13
	* doc.c (get_doc_string): Rework so that
	get_doc_string_buffer_size is the actual buffer size, rather than
	being 1 less than the actual buffer size; this makes xpalloc more
	convenient.

Paul Eggert's avatar
Paul Eggert committed
14 15 16 17
	* image.c (x_allocate_bitmap_record, cache_image):
	* xselect.c (Fx_register_dnd_atom):
	Simplify previous changes by using xpalloc.

18 19 20
	* buffer.c (overlay_str_len): Now ptrdiff_t, not EMACS_INT,
	since either will do and ptrdiff_t is convenient with xpalloc.

21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
	* charset.c (charset_table_size)
	(struct charset_sort_data.priority): Now ptrdiff_t.
	(charset_compare): Don't overflow if priorities differ greatly.
	(Fsort_charsets): Don't assume list length fits in int.
	Check for size-calculation overflow when allocating sort data.
	(syms_of_charset): Allocate an initial charset table that is
	just under 64 KiB, to avoid problems with glibc malloc and mmap.

	* cmds.c (internal_self_insert): Check for size-calculation overflow.

	* composite.h (struct composition.glyph_len): Now int, not unsigned.
	The actual value is always <= INT_MAX, and leaving it unsigned made
	overflow checking harder.

	* dispextern.h (struct glyph_matrix.rows_allocated)
	(struct face_cache.size): Now ptrdiff_t, for convenience in use
	with xpalloc.  The values are still always <= INT_MAX.

	* indent.c (compute_motion): Adjust to region_cache_forward sig change.

	* lisp.h (xnmalloc, xnrealloc, xpalloc): New decls.
	(SAFE_NALLOCA): New macro.

	* region-cache.c (struct boundary.pos, find_cache_boundary)
	(move_cache_gap, insert_cache_boundary, delete_cache_boundaries)
	(set_cache_region, invalidate_region_cache)
	(revalidate_region_cache, know_region_cache, region_cache_forward)
	(region_cache_backward, pp_cache):
	Use ptrdiff_t, not EMACS_INT, since either will do.  This is needed
	so that ptrdiff_t * can be passed to xpalloc.
	(struct region_cache): Similarly, for gap_start, gap_len, cache_len,
	beg_unchanged, end_unchanged, buffer_beg, buffer_end members.
	(pp_cache): Don't assume cache_len fits in int.
	* region-cache.h: Adjust extern decls to match.

	* search.c (scan_buffer, Freplace_match): Use ptrdiff_t, not
	EMACS_INT, since either will do, for xpalloc.

	* alloc.c: Include verify.h, and check that int fits in ptrdiff_t.
	(xnmalloc, xnrealloc, xpalloc): New functions.

62 63 64 65
	* bidi.c (bidi_shelve_header_size): New constant.
	(bidi_cache_ensure_space, bidi_shelve_cache): Use it.
	(bidi_cache_ensure_space): Avoid integer overflow when allocating.

66
	* bidi.c (bidi_cache_shrink):
67 68 69 70
	* buffer.c (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.
71 72 73 74
	(struct sortstrlist.bytes): Now ptrdiff_t, as EMACS_INT doesn't help
	now that we have proper integer overflow checking.
	(record_overlay_string, overlay_strings): Catch overflows when
	calculating size of overlay_str_buf.
75

76 77 78 79 80
	* callproc.c (Fcall_process): Check for size overflow when
	calculating size of args2.
	(child_setup): Avoid overflow by using size_t rather than ptrdiff_t.
	Normally we prefer signed values, but sticking with ptrdiff_t would
	require adding more-complicated checks.
81 82 83 84

	* ccl.c (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.
85
	Add a FIXME comment where memory seems to be over-allocated.
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124

	* character.c (Fstring): Check for size-calculation overflow.

	* coding.c (produce_chars): Redo buffer-overflow calculations to avoid
	unnecessary integer overflow.  Check for size overflow.
	(encode_coding_object): Don't update size until xmalloc succeeds.

	* composite.c (get_composition_id): Check for overflow in glyph
	length calculations.

	Integer and memory overflow fixes for display code.
	* dispextern.h (struct glyph_pool.nglyphs): Now ptrdiff_t, not int.
	* dispnew.c (adjust_glyph_matrix, realloc_glyph_pool)
	(scrolling_window): Check for overflow in size calculations.
	(line_draw_cost, realloc_glyph_pool, add_row_entry):
	Don't assume glyph table len fits in int.
	(struct row_entry.bucket, row_entry_pool_size, row_entry_idx)
	(row_table_size): Now ptrdiff_t, not int.
	(scrolling_window): Avoid overflow in size calculations.
	Don't update size until allocation succeeds.
	* fns.c (concat): Check for overflow in size calculations.
	(next_almost_prime): Verify NEXT_ALMOST_PRIME_LIMIT.
	* lisp.h (RANGED_INTEGERP, TYPE_RANGED_INTEGERP): New macros.
	(NEXT_ALMOST_PRIME_LIMIT): New constant.

	* doc.c (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.

	* editfns.c (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.

125 126 127 128
	* emacs.c (main): Do not reallocate argv, since there is a null at
	the end that can be overwritten, and this way there's no need to
	worry about size-calculation overflow.
	(sort_args): Check for size-calculation overflow.
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167

	* eval.c (init_eval_once, grow_specpdl): Don't update size until
	alloc succeeds.
	(call_debugger, grow_specpdl): Redo calculations to avoid overflow.

	* frame.c (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.

	* frame.h (struct frame): Use int, not EMACS_INT, where int works.
	This is for the members text_lines, text_cols, total_lines, total_cols,
	where the system imposes an 'int' limit.

	* fringe.c (Fdefine_fringe_bitmap):
	Don't update size until alloc works.

	* ftfont.c (ftfont_get_open_type_spec, setup_otf_gstring)
	(ftfont_shape_by_flt): Check for integer overflow in size calculations.

	* gtkutil.c (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.

	* image.c (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):
168
	Check for size calculation overflow.
169 170 171
	(ct_colors_allocated_max): New constant.
	(x_to_xcolors, x_detect_edges): Reorder multiplicands to avoid
	overflow.
172

173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
	* keyboard.c (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.

	* keymap.c (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.

	* lread.c (read1, init_obarray): Don't update size until alloc done.

	* macros.c (Fstart_kbd_macro): Don't update size until alloc done.
	(store_kbd_macro_char): Reorder multiplicands to avoid overflow.

	* nsterm.h (struct ns_color_table.size, struct ns_color_table.avail):
	Now ptrdiff_t, not int.
	* nsterm.m (ns_index_color): Use ptrdiff_t, not int, for table indexes.
	(ns_draw_fringe_bitmap): Rewrite to avoid overflow.

	* process.c (Fnetwork_interface_list): Check for overflow
	in size calculation.

	* region-cache.c (move_cache_gap): Check for size calculation overflow.

	* scroll.c (do_line_insertion_deletion_costs): Check for size calc
	overflow.  Don't bother calling xmalloc when xrealloc will do.

	* search.c (Freplace_match): Check for size calculation overflow.
	(Fset_match_data): Don't assume list lengths fit in 'int'.

	* sysdep.c (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.

	* term.c (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.

	* termcap.c (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.

	* tparam.c (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.
231
	(main) [DEBUG]: Fix typo in invoking tparam1.
232 233 234 235 236

	* xdisp.c (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.

237 238 239 240 241 242
	* xfaces.c (lface_id_to_name_size, Finternal_make_lisp_face):
	Use ptrdiff_t, not int, for sizes.
	(Finternal_make_lisp_face, cache_face):
	Check for size calculation overflow.
	(cache_face): Treat size calculation overflows as if they were
	memory exhaustion (the usual treatment), rather than aborting.
243 244 245 246 247 248

	* xfns.c (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.

249 250
	* xgselect.c (gfds_size): Now ptrdiff_t, for convenience with xpalloc.
	(xg_select): Check for size calculation overflow.
251 252
	Don't update size until alloc done.

253
	* xrdb.c (get_environ_db): Don't assume path length fits in int,
254
	as sprintf is limited to int lengths.
255

256 257
	* xselect.c (X_LONG_SIZE, X_SHRT_MAX, X_SHRT_MIN, X_LONG_MAX)
	(X_LONG_MIN): New macros.
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
	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
276
	X_LONG_MAX rather than relying on wraparound overflow to send
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301
	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.

302
	* xsmfns.c (smc_save_yourself_CB): Check for size calc overflow.
303

304 305
	* xterm.c (x_color_cells, x_send_scrollbar_event, handle_one_xevent)
	(x_term_init): Check for size calculation overflow.
306 307
	(x_color_cells): Don't store size until memory allocation succeeds.
	(handle_one_xevent): Use ptrdiff_t, not int, for byte counts.
308
	Don't assume alloca size is less than MAX_ALLOCA.
309 310
	(x_term_init): Don't assume length fits in int (sprintf is limited
	to int size).
Paul Eggert's avatar
Paul Eggert committed
311

312 313 314 315 316 317 318 319 320 321 322
	Use ptrdiff_t for composition IDs.
	* character.c (lisp_string_width):
	* composite.c (composition_table_size, n_compositions)
	(get_composition_id, composition_gstring_from_id):
	* dispextern.h (struct glyph_string.cmp_id, struct composition_it.id):
	* xdisp.c (BUILD_COMPOSITE_GLYPH_STRING):
	* window.c (Frecenter):
	Use ptrdiff_t, not int, for composition IDs.
	* composite.c (get_composition_id): Check for integer overflow.
	* composite.h: Adjust prototypes to match the above changes.

323 324 325 326 327 328 329 330 331 332 333 334 335 336 337
	Use ptrdiff_t for hash table indexes.
	* category.c (hash_get_category_set):
	* ccl.c (ccl_driver):
	* charset.h (struct charset.hash_index, CHECK_CHARSET_GET_ID):
	* coding.c (coding_system_charset_list, detect_coding_system):
	* coding.h (struct coding_system.id):
	* composite.c (get_composition_id, gstring_lookup_cache):
	* fns.c (hash_lookup, hash_put, Fgethash, Fputhash):
	* image.c (xpm_get_color_table_h):
	* lisp.h (hash_lookup, hash_put):
	* minibuf.c (Ftest_completion):
	Use ptrdiff_t for hash table indexes, not int (which is too
	narrow, on 64-bit hosts) or EMACS_INT (which is too wide, on
	32-bit --with-wide-int hosts).

338 339 340 341
	* charset.c (Fdefine_charset_internal): Check for integer overflow.
	Add a FIXME comment about memory leaks.
	(syms_of_charset): Don't assume xmalloc returns.

342 343 344 345 346 347 348 349 350 351
	Don't assume that stated character widths fit in int.
	* character.c (Fchar_width, c_string_width, lisp_string_width):
	* character.h (CHAR_WIDTH):
	* indent.c (MULTIBYTE_BYTES_WIDTH):
	Use sanitize_char_width to avoid undefined and/or bad behavior
	with outlandish widths.
	* character.h (sanitize_tab_width): Renamed from sanitize_width,
	now that we have two such functions.  All uses changed.
	(sanitize_char_width): New inline function.

352 353 354 355 356 357 358 359
	Don't assume that tab-width fits in int.
	* character.h (sanitize_width): New inline function.
	(SANE_TAB_WIDTH): New macro.
	(ASCII_CHAR_WIDTH): Use it.
	* indent.c (sane_tab_width): Remove.  All uses replaced by
	SANE_TAB_WIDTH (current_buffer).
	* xdisp.c (init_iterator): Use SANE_TAB_WIDTH.

360 361 362
	* fileio.c: Integer overflow issues with file modes.
	(Fset_file_modes, auto_save_1): Don't assume EMACS_INT fits in int.

363 364 365 366
	* charset.c (read_hex): New arg OVERFLOW.  All uses changed.
	Remove unreachable code.
	(read_hex, load_charset_map_from_file): Check for integer overflow.

367 368 369 370 371 372
	* xterm.c: don't go over XClientMessageEvent limit
	(scroll_bar_windows_size): Now ptrdiff_t, as we prefer signed.
	(x_send_scroll_bar_event): Likewise.  Check that the size does not
	exceed limits imposed by XClientMessageEvent, as well as the usual
	ptrdiff_t and size_t limits.

373 374 375 376 377 378 379 380 381 382 383 384 385
	* keyboard.c: Overflow, signedness and related fixes.
	(make_lispy_movement): Use same integer type in forward decl
	that is used in the definition.
	(read_key_sequence, keyremap_step):
	Change bufsize argument back to int, undoing my 2011-03-30 change.
	We prefer signed types, and int is wide enough here.
	(parse_tool_bar_item): Don't assume tool_bar_max_label_size is less
	than TYPE_MAXIMUM (EMACS_INT) / 2.  Don't let the label size grow
	larger than STRING_BYTES_BOUND.  Use ptrdiff_t for Emacs string
	length, not size_t.  Use ptrdiff_t for index, not int.
	(keyremap_step, read_key_sequence): Redo bufsize check to avoid
	possibility of integer overflow.

386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428
	Overflow, signedness and related fixes for images.

	* dispextern.h (struct it.stack[0].u.image.image_id)
	(struct_it.image_id, struct image.id, struct image_cache.size)
	(struct image_cache.used, struct image_cache.ref_count):
	* gtkutil.c (update_frame_tool_bar):
	* image.c (x_reference_bitmap, Fimage_size, Fimage_mask_p)
	(Fimage_metadata, free_image_cache, clear_image_cache, lookup_image)
	(cache_image, mark_image_cache, x_kill_gs_process, Flookup_image):
	* nsmenu.m (update_frame_tool_bar):
	* xdisp.c (calc_pixel_width_or_height):
	* xfns.c (image_cache_refcount):
	Image IDs are now ptrdiff_t, not int, to avoid arbitrary limits
	on typical 64-bit hosts.

	* image.c (RANGED_INTEGERP, TYPE_RANGED_INTEGERP): New macros.
	(x_bitmap_pixmap, x_create_x_image_and_pixmap):
	Omit unnecessary casts to int.
	(parse_image_spec): Check that integers fall into 'int' range
	when the callers expect that.
	(image_ascent): Redo ascent calculation to avoid int overflow.
	(clear_image_cache): Avoid overflow when sqrt (INT_MAX) < nimages.
	(lookup_image): Remove unnecessary tests.
	(xbm_image_p): Locals are now of int, not EMACS_INT,
	since parse_image_check makes sure they fit into int.
	(png_load, gif_load, svg_load_image):
	Prefer int to unsigned where either will do.
	(tiff_handler): New function, combining the cores of the
	old tiff_error_handler and tiff_warning_handler.  This
	function is rewritten to use vsnprintf and thereby avoid
	stack buffer overflows.  It uses only the features of vsnprintf
	that are common to both POSIX and native Microsoft.
	(tiff_error_handler, tiff_warning_handler): Use it.
	(tiff_load, gif_load, imagemagick_load_image):
	Don't assume :index value fits in 'int'.
	(gif_load): Omit unnecessary cast to double, and avoid double-rounding.
	(imagemagick_load_image): Check that crop parameters fit into
	the integer types that MagickCropImage accepts.  Don't assume
	Vimagemagick_render_type has a nonnegative value.  Don't assume
	size_t fits in 'long'.
	(gs_load): Use printmax_t to print the widest integers possible.
	Check for integer overflow when computing image height and width.

429 430 431 432 433
2011-08-26  Eli Zaretskii  <eliz@gnu.org>

	* xdisp.c (redisplay_window): Don't force window start if point
	will be invisible in the resulting window.  (Bug#9324)

434 435 436 437 438 439 440 441 442
2011-08-25  Eli Zaretskii  <eliz@gnu.org>

	* xdisp.c (compute_display_string_pos): Return 2 in DISP_PROP when
	the display spec is of the form `(space ...)'.
	(handle_display_spec): Return the value returned by
	handle_single_display_spec, not just 1 or zero.
	(handle_single_display_spec): If the display spec is of the form
	`(space ...)', and specifies display in the text area, return 2
	rather than 1.
443
	(try_cursor_movement): Check for the need to scroll more
444 445
	accurately, and prefer exact match for point under bidi.  Don't
	advance `row' beyond the last row of the window.
446 447 448 449 450 451 452 453

	* dispextern.h (struct bidi_it): Rename the disp_prop_p member
	into disp_prop; all users changed.

	* bidi.c (bidi_fetch_char): If compute_display_string_pos returns
	DISP_PROP = 2, substitute the u+2029 PARAGRAPH SEPARATOR character
	for the text covered by the display property.

454 455 456 457 458 459
2011-08-25  Chong Yidong  <cyd@stupidchicken.com>

	* buffer.c (Fbury_buffer_internal): Rename from Funrecord_buffer.
	Change return value to nil.
	(Frecord_buffer): Delete unused function.

Eli Zaretskii's avatar
Eli Zaretskii committed
460 461
2011-08-24  Eli Zaretskii  <eliz@gnu.org>

462 463
	* xdisp.c (Fcurrent_bidi_paragraph_direction): For unibyte
	buffers, return left-to-right.
464 465 466 467 468 469 470 471 472 473 474 475 476
	(set_cursor_from_row): Consider candidate row a win if its glyph
	represents a newline and point is on that newline.  Fixes cursor
	positioning on the newline at EOL of R2L text within L2R
	paragraph, and vice versa.
	(try_cursor_movement): Check continued rows, in addition to
	continuation rows.  Fixes unwarranted scroll when point enters a
	continued line of R2L text within an L2R paragraph, or vice versa.
	(cursor_row_p): Consider the case of point being equal to
	MATRIX_ROW_END_CHARPOS.  Prevents cursor being stuck when moving
	from the end of a short line to the beginning of a continued line
	of R2L text within L2R paragraph.
	(RECORD_MAX_MIN_POS): For max_pos, use IT_CHARPOS even for
	composed characters.
477

Eli Zaretskii's avatar
Eli Zaretskii committed
478 479 480 481
	* bidi.c (bidi_check_type): Use xassert.
	(bidi_cache_iterator_state): Update the disp_pos and disp_prop_p
	members.

482 483 484 485 486
2011-08-23  Eli Zaretskii  <eliz@gnu.org>

	* bidi.c (bidi_get_type): Abort if we get zero as the bidi type of
	a character.

487 488 489 490
2011-08-23  Chong Yidong  <cyd@stupidchicken.com>

	* nsfont.m (ns_otf_to_script): Fix typo.

491 492 493 494 495
2011-08-22  Kenichi Handa  <handa@m17n.org>

	* chartab.c (Fset_char_table_extra_slot): Do not inhibit setting a
	extra slot even if the purpose is char-code-property-table.

496 497
2011-08-23  Eli Zaretskii  <eliz@gnu.org>

498 499 500
	* xdisp.c (redisplay_window): When computing centering_position,
	account for the height of the header line.  (Bug#8874)

501 502 503 504 505
	* dispnew.c (buffer_posn_from_coords): Use buf_charpos_to_bytepos
	instead of CHAR_TO_BYTE.  Fixes a crash when a completion
	candidate is selected by the mouse, and that candidate has a
	composed character under the mouse.

506 507 508 509
	* xdisp.c (x_produce_glyphs): Set it->nglyphs to 1.  Fixes pixel
	coordinates reported by pos-visible-in-window-p for a composed
	character in column zero.

510 511 512 513
2011-08-23  Stefan Monnier  <monnier@iro.umontreal.ca>

	* cmds.c (Fself_insert_command): Mention post-self-insert-hook.

514 515 516 517 518 519
2011-08-22  Eli Zaretskii  <eliz@gnu.org>

	* xdisp.c (BUFFER_POS_REACHED_P): If this is a composition,
	consider it a hit if to_charpos is anywhere in the range of the
	composed buffer positions.

520 521 522 523 524 525
2011-08-22  Chong Yidong  <cyd@stupidchicken.com>

	* image.c (gif_load): Don't assume that each subimage has the same
	dimensions as the base image.  Handle disposal method that is
	"undefined" by the gif spec (Bug#9335).

526 527 528
2011-08-20  Chong Yidong  <cyd@stupidchicken.com>

	* eval.c (Fsignal): Handle `debug' symbol in error handler (Bug#9329).
529
	(Fcondition_case): Document `debug' symbol in error handler.
530

531 532
2011-08-19  Eli Zaretskii  <eliz@gnu.org>

533 534 535 536
	* xfaces.c (face_at_buffer_position): Avoid repeated evaluation of
	face ID by FACE_FROM_ID, and avoid a crash when mouse is moved
	from an Org mode buffer to a Speedbar frame.

537 538 539 540 541
	* xdisp.c (RECORD_MAX_MIN_POS): If the display element comes from
	a composition, take its buffer position from IT->cmp_it.charpos.
	Fixes cursor positioning at the beginning of a line that begins
	with a composed character.

542 543
2011-08-18  Eli Zaretskii  <eliz@gnu.org>

544 545 546 547
	* bidi.c (bidi_get_type): If bidi_type_table reports zero as the
	character bidirectional type, use STRONG_L instead.  Fixes crashes
	in a buffer produced by `describe-categories'.

548 549 550 551 552
	* dispextern.h (struct bidi_it): Move disp_pos and disp_prop_p
	members before the level stack, so they would be saved and
	restored when copying iterator state.  Fixes incorrect reordering
	around TABs covered by display properties.

553 554 555 556 557
2011-08-18  Andreas Schwab  <schwab@linux-m68k.org>

	* process.c (Fnetwork_interface_list): Correctly determine buffer
	size.

558 559 560
2011-08-17  Chong Yidong  <cyd@stupidchicken.com>

	* eval.c (internal_condition_case, internal_condition_case_1)
561 562
	(internal_condition_case_2, internal_condition_case_n):
	Remove unnecessary aborts (Bug#9081).
563

564 565 566 567 568
2011-08-17  Eli Zaretskii  <eliz@gnu.org>

	* lread.c (Fload) [DOS_NT]: If `openp' returns -2, but the file
	has no `load' handler, try opening the file locally.  (Bug#9311)

Ken Brown's avatar
Ken Brown committed
569 570 571 572
2011-08-16  Ken Brown  <kbrown@cornell.edu>

	* gmalloc.c: Expand comment.

573 574 575 576 577
2011-08-16  Eli Zaretskii  <eliz@gnu.org>

	* xdisp.c (set_cursor_from_row): Don't accept a previous candidate
	if it fails the cursor_row_p test.  Fixes cursor positioning at ZV.

578 579 580 581 582 583 584
2011-08-16  Ken Brown  <kbrown@cornell.edu>

	Fix memory allocation problems in Cygwin build (Bug#9273).

	* unexcw.c ( __malloc_initialized): Declare external variable.
	(fixup_executable): Force the dumped emacs to reinitialize malloc.

585 586
	* gmalloc.c [CYGWIN] (bss_sbrk_heapbase, bss_sbrk_heapinfo):
	New variables.
587 588 589 590 591 592 593 594
	(malloc_initialize_1) [CYGWIN]: Prepare for reinitializing the
	dumped emacs.
	(_free_internal_nolock) [CYGWIN]: Ignore requests to free storage
	in the static heap.
	[CYGWIN] (special_realloc): New function.
	(_realloc_internal_nolock) [CYGWIN]: Use the new function on
	requests to realloc storage in the static heap.

595 596 597 598
2011-08-15  Paul Eggert  <eggert@cs.ucla.edu>

	* bidi.c (bidi_initialize): Remove unused local.

599 600
2011-08-15  Eli Zaretskii  <eliz@gnu.org>

601 602 603 604 605 606 607 608 609 610 611 612 613 614
	* biditype.h: File removed.

	* bidimirror.h: File removed.

	* deps.mk (bidi.o): Remove biditype.h and
	bidimirror.h.

	* makefile.w32-in ($(BLD)/bidi.$(O)): Remove biditype.h and
	bidimirror.h.

	* dispextern.h: Fix a typo in the comment to bidi_type_t.

	* chartab.c: Improve commentary for the uniprop_table API.

615 616
	* bidi.c (bidi_paragraph_init): Support zero value of
	bidi_ignore_explicit_marks_for_paragraph_level.
617 618
	(bidi_initialize): Use uniprop_table instead of including
	biditype.h and bidimirror.h.
619

620 621 622 623
	* xdisp.c (move_it_in_display_line_to): Don't reset pixel
	coordinates of the iterator when restoring from ppos_it.
	(Bug#9296)

624 625 626
2011-08-14  Kenichi Handa  <handa@m17n.org>

	* process.c (create_process): Call setup_process_coding_systems
627
	after the pid of the process is set to -1 (Bug#8162).
628

629 630 631 632 633 634 635
2011-08-14  Eli Zaretskii  <eliz@gnu.org>

	* xdisp.c (move_it_in_display_line_to): Don't invoke
	IT_RESET_X_ASCENT_DESCENT when iterator position was restored from
	ppos_it.  Fixes vertical cursor motion when line beginning is
	covered by an image.  (Bug#9296)

636 637 638 639 640 641 642 643 644 645 646 647 648 649 650
2011-08-14  Jan Djärv  <jan.h.d@swipnet.se>

	* nsterm.h (ns_run_ascript): Declare.
	(NSAPP_DATA2_RUNASSCRIPT): Define.

	* nsfns.m (as_script, as_result, as_status): New static variables.
	(ns_run_ascript): New function.
	(Fns_do_applescript): Set variables as_*. Make an NSApplicationDefined
	event with data2 set to NSAPP_DATA2_RUNASSCRIPT, post it and then start
	the event loop.  Get status from as_status (Bug#7276).

	* nsterm.m (sendEvent): If event is NSApplicationDefined and
	data2 is NSAPP_DATA2_RUNASSCRIPT, call ns_run_ascript and then exit
	the event loop (Bug#7276).

651 652 653 654 655 656 657 658 659 660 661 662 663 664
2011-08-14  Andreas Schwab  <schwab@linux-m68k.org>

	* gnutls.c (QCgnutls_bootprop_priority)
	(QCgnutls_bootprop_trustfiles, QCgnutls_bootprop_keylist)
	(QCgnutls_bootprop_crlfiles, QCgnutls_bootprop_callbacks)
	(QCgnutls_bootprop_loglevel, QCgnutls_bootprop_hostname)
	(QCgnutls_bootprop_min_prime_bits, QCgnutls_bootprop_verify_flags)
	(QCgnutls_bootprop_verify_hostname_error)
	(QCgnutls_bootprop_callbacks_verify): Rename from
	Qgnutls_bootprop_..., all uses changed.

	* xfaces.c (QCignore_defface): Rename from Qignore_defface, all
	uses changed.

665 666
2011-08-14  Paul Eggert  <eggert@cs.ucla.edu>

667 668 669
	* xfaces.c (Qframe_set_background_mode): Now static.
	* dispextern.h (Qframe_set_background_mode): Remove decl.

670 671
	* process.c (Fnetwork_interface_info): Declare local only if needed.

672 673 674 675 676 677 678 679 680 681 682
2011-08-13  Jan Djärv  <jan.h.d@swipnet.se>

	* process.c: Include ifaddrs.h and net/if_dl.h if available (Bug#8477).
	(Fnetwork_interface_list): Allocate in increments of bytes instead
	of sizeof (struct ifreq).  Iterate over ifconf.ifc_req by counting
	bytes (Bug#8477).  Count bytes correctly when ifr_addr is a struct
	sockaddr.
	(struct ifflag_def): notrailers is smart on OSX.
	(Fnetwork_interface_info): Handle case when ifr_flags is negative.
	Get hardware address with getifaddrs if available.

683 684 685 686 687
2011-08-12  Eli Zaretskii  <eliz@gnu.org>

	* xdisp.c (iterate_out_of_display_property): xassert that
	IT->position is set to within IT->object's boundaries.  Break from
	the loop as soon as EOB is reached; avoids infloops in redisplay
688 689
	when IT->position is set up wrongly due to some bug.
	Set IT->current to match the bidi iterator unconditionally.
690 691 692 693 694 695 696
	(push_display_prop): Allow GET_FROM_STRING as IT->method on
	entry.  Force push_it to save on the stack the current
	buffer/string position, to be restored by pop_it.  Fix flags in
	the iterator structure wrt the object coming from a display
	property, as `line-prefix' and `wrap-prefix' are not ``replacing''
	properties.  (Bug#9284)

Chong Yidong's avatar
Chong Yidong committed
697
2011-08-09  Andreas Schwab  <schwab@linux-m68k.org>
698

Chong Yidong's avatar
Chong Yidong committed
699 700
	* fontset.c (fontset_get_font_group): Add proper type checks.
	(Bug#9172)
701

Chong Yidong's avatar
Chong Yidong committed
702
2011-08-09  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
703

Chong Yidong's avatar
Chong Yidong committed
704 705 706 707
	* unexmacosx.c (print_load_command_name): Add cases LC_FUNCTION_STARTS
	and LC_VERSION_MIN_MACOSX.
	(copy_linkedit_data) [LC_FUNCTION_STARTS]: New function.
	(dump_it) [LC_FUNCTION_STARTS]: Use it.
708

709 710 711
2011-08-08  Eli Zaretskii  <eliz@gnu.org>

	* xdisp.c (forward_to_next_line_start): Allow to use the
712 713
	no-display-properties-and-no-overlays under bidi display.
	Set disp_pos in the bidi iterator to avoid searches for display
714
	properties and overlays.
715

716 717
2011-08-08  Chong Yidong  <cyd@stupidchicken.com>

718 719 720
	* editfns.c (Fset_time_zone_rule): Document relationship with the
	setenv function.

721 722 723
	* ftfont.c (ftfont_pattern_entity): Copy the extras argument to
	the font entity extracted from the cache (Bug#8109).

724 725 726 727 728
2011-08-07  Chong Yidong  <cyd@stupidchicken.com>

	* composite.c (autocmp_chars): Don't reset point.  That is done by
	restore_point_unwind (Bug#5984).

729 730 731 732 733
2011-08-07  Juri Linkov  <juri@jurta.org>

	* editfns.c (Fformat_time_string): Doc fix, add tag `usage:'
	to show the arg `TIME' instead of `TIMEVAL'.

734 735 736 737 738
2011-08-06  Eli Zaretskii  <eliz@gnu.org>

	* xdisp.c (set_cursor_from_row): Fix cursor positioning when a
	display property strides EOL and includes a newline, as in
	longlines-mode.  (Bug#9254)
739 740
	(move_it_in_display_line_to): Fix vertical-motion in a buffer with
	word-wrap under bidirectional display.  (Bug#9224)
741 742 743 744 745

	* bidi.c (bidi_unshelve_cache): Don't reset the cache if JUST_FREE
	is non-zero, even if the data buffer is NULL.  Fixes a crash in
	vertical-motion with longlines-mode.  (Bug#9254)

746 747
2011-08-05  Eli Zaretskii  <eliz@gnu.org>

748 749 750
	* bidi.c <bidi_cache_total_alloc>: Now static.
	(bidi_initialize): Initialize bidi_cache_total_alloc.

751
	* xdisp.c (display_line): Release buffer allocated for shelved bidi
752 753 754 755 756 757 758 759 760 761 762 763 764 765 766
	cache.  (Bug#9221)

	* 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.

	* dispextern.h (bidi_unshelve_cache): Update prototype.

	* 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
767
	MOVE_POS_MATCH_OR_ZV in the bidi case.  (Bug#9224)
768

769 770 771 772 773
2011-08-05  Eli Zaretskii  <eliz@gnu.org>

	* xdisp.c (set_cursor_from_row): Prefer the candidate glyph that
	came from a string character with a `cursor' property.  (Bug#9229)

774 775 776 777 778 779 780 781
2011-08-04  Jan Djärv  <jan.h.d@swipnet.se>

	* Makefile.in (LIB_PTHREAD): New variable.
	(LIBES): Add LIB_PTHREAD (Bug#9216).

	* alloc.c, emacs.c, gmalloc.c, gtkutil.c, keyboard.c, syssignal.h:
	Rename HAVE_GTK_AND_PTHREAD to HAVE_PTHREAD (Bug#9216).

782 783 784 785 786
2011-08-04  Andreas Schwab  <schwab@linux-m68k.org>

	* regex.c (re_iswctype): Remove some redundant boolean
	conversions.

787 788 789 790 791 792 793
2011-08-04  Jan Djärv  <jan.h.d@swipnet.se>

	* 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 (bug#9181).
	(handle_one_xevent): Call x_set_frame_alpha on ReparentNotify.

794 795 796 797 798
2011-08-04  Paul Eggert  <eggert@cs.ucla.edu>

	* callproc.c (Fcall_process): Avoid vfork clobbering
	the local vars buffer, coding_systems, current_dir.

799 800 801 802
2011-08-03  Stefan Monnier  <monnier@iro.umontreal.ca>

	* keymap.c (Fmake_composed_keymap): Move to subr.el.

803 804
2011-08-03  Paul Eggert  <eggert@cs.ucla.edu>

805 806 807
	* fontset.c (dump_fontset) [FONTSET_DEBUG]: Declare EXTERNALLY_VISIBLE
	so that it is not optimized away.

808 809
	* xdisp.c (compute_display_string_pos): Remove unused local.

810 811 812 813 814 815 816 817 818 819 820 821 822 823
2011-08-02  Eli Zaretskii  <eliz@gnu.org>

	Fix slow cursor motion and scrolling in large buffers with
	selective display, like Org Mode buffers.  (Bug#9218)

	* dispextern.h (struct bidi_it): New member disp_prop_p.

	* 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.

	* bidi.c (bidi_fetch_char): Accept an additional argument
824 825
	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
826 827
	non-zero.  All callers of bidi_fetch_char changed.

828 829 830 831
2011-08-02  Stefan Monnier  <monnier@iro.umontreal.ca>

	* keymap.c (Fdefine_key): Fix Lisp_Object/int mixup; apply some CSE.

832 833 834 835 836
2010-12-03  Don March  <don@ohspite.net>

	* keymap.c (Fdefine_key): Fix non-prefix key error message when
	last character M-[char] is translated to ESC [char] (bug#7541).

Kenichi Handa's avatar
Kenichi Handa committed
837 838
2011-08-02  Kenichi Handa  <handa@m17n.org>

Kenichi Handa's avatar
Kenichi Handa committed
839
	* lisp.h (uniprop_table): Extern it.
Kenichi Handa's avatar
Kenichi Handa committed
840 841 842

	* chartab.c (uniprop_table): Make it non-static.

843 844 845 846 847 848 849 850 851
2011-08-01  Eli Zaretskii  <eliz@gnu.org>

	* 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)

852 853 854 855 856 857
2011-07-30  Andreas Schwab  <schwab@linux-m68k.org>

	* regex.c (re_comp): Protoize.
	(re_exec): Fix return type.
	(regexec): Fix type of `ret'.  (Bug#9203)

858 859 860 861 862
2011-07-29  Paul Eggert  <eggert@cs.ucla.edu>

	* image.c (check_image_size): Use 1024x1024 if unknown frame (Bug#9189).
	This is needed if max-image-size is a floating-point number.

Andreas Schwab's avatar
Andreas Schwab committed
863 864 865 866 867 868
2011-07-28  Andreas Schwab  <schwab@linux-m68k.org>

	* print.c (print_object): Print empty symbol as ##.

	* lread.c (read1): Read ## as empty symbol.

869 870 871 872 873 874
2011-07-28  Alp Aker  <alp.tekin.aker@gmail.com>

	* nsfns.m (x_set_foreground_color): Set f->foreground_pixel when
	setting frame foreground color (Bug#9175).
	(x_set_background_color): Likewise.

875 876 877 878 879
	* nsmenu.m (-setText): Size tooltip dimensions precisely to
	contents (Bug#9176).
	(EmacsTooltip -init): Remove bezels and add shadows to
	tooltip windows.

880 881 882
	* nsterm.m (ns_dumpglyphs_stretch): Avoid overwriting left fringe
	or scroll bar (Bug#8470).

883 884 885 886 887 888
	* 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 (Bug#8913).

	* nsterm.h (nsfont_info): Remove voffset field.

889
2011-07-28  Alp Aker  <alp.tekin.aker@gmail.com>
890 891 892 893 894 895 896 897 898 899 900 901 902 903 904

	Implement strike-through and overline on NextStep (Bug#8863).

	* 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.

	* nsterm.h: Add declaration for ns_draw_text_decoration.

	* 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.

905 906
2011-07-28  Eli Zaretskii  <eliz@gnu.org>

Eli Zaretskii's avatar
Eli Zaretskii committed
907 908
	* buffer.c (init_buffer_once): Set bidi-display-reordering to t by
	default.
909

910 911
2011-07-28  Paul Eggert  <eggert@cs.ucla.edu>

912 913 914 915
	* alloc.c (memory_full) [!SYNC_INPUT]: Fix signal-related race.
	Without this fix, if a signal arrives just after memory fills up,
	'malloc' might be invoked reentrantly.

916 917 918 919
	* image.c (x_check_image_size) [!HAVE_X_WINDOWS]: Return 1.
	In other words, assume that every image size is allowed, on non-X
	hosts.  This assumption is probably wrong, but it lets Emacs compile.

920 921 922 923
2011-07-28  Andreas Schwab  <schwab@linux-m68k.org>

	* regex.c (re_iswctype): Convert return values to boolean.

924 925 926 927 928 929
2011-07-28  Eli Zaretskii  <eliz@fencepost.gnu.org>

	* xdisp.c (compute_display_string_pos): Don't use cached display
	string position if the buffer had its restriction changed.
	(Bug#9184)

930 931 932 933
2011-07-28  Paul Eggert  <eggert@cs.ucla.edu>

	* callproc.c (Fcall_process): Use 'volatile' to avoid vfork clobbering.

Paul Eggert's avatar
Paul Eggert committed
934
2011-07-28  Paul Eggert  <eggert@cs.ucla.edu>
935

Paul Eggert's avatar
Paul Eggert committed
936
	Integer signedness and overflow and related fixes.  (Bug#9079)
Paul Eggert's avatar
Paul Eggert committed
937

938 939 940 941 942 943 944 945 946 947 948 949 950
	* bidi.c: Integer size and overflow fixes.
	(bidi_cache_size, bidi_cache_idx, bidi_cache_last_idx)
	(bidi_cache_start, bidi_cache_fetch_state, bidi_cache_search)
	(bidi_cache_find_level_change, bidi_cache_ensure_space)
	(bidi_cache_iterator_state, bidi_cache_find, bidi_cache_start_stack)
	(bidi_find_other_level_edge):
	Use ptrdiff_t instead of EMACS_INT where either will do.
	This works better on 32-bit hosts configured --with-wide-int.
	(bidi_cache_ensure_space): Check for size-calculation overflow.
	Use % rather than repeated addition, for better worst-case speed.
	Don't set bidi_cache_size until after xrealloc returns, because it
	might not return.
	(bidi_dump_cached_states): Use ptrdiff_t, not int, to avoid overflow.
951 952 953
	(bidi_cache_ensure_space): Also check that the bidi cache size
	does not exceed that of the largest Lisp string or buffer.  See Eli
	Zaretskii in <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9079#29>.
954

955 956 957 958
	* alloc.c (__malloc_size_t): Remove.
	All uses replaced by size_t.  See Andreas Schwab's note
	<http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9079#8>.

959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977
	* image.c: Improve checking for integer overflow.
	(check_image_size): Assume that f is nonnull, since
	it is always nonnull in practice.  This is one less thing to
	worry about when checking for integer overflow later.
	(x_check_image_size): New function, which checks for integer
	overflow issues inside X.
	(x_create_x_image_and_pixmap, xbm_read_bitmap_data): Use it.
	This removes the need for a memory_full check.
	(xbm_image_p): Rewrite to avoid integer multiplication overflow.
	(Create_Pixmap_From_Bitmap_Data, xbm_load): Use x_check_image_size.
	(xbm_read_bitmap_data): Change locals back to 'int', since
	their values must fit in 'int'.
	(xpm_load_image, png_load, tiff_load):
	Invoke x_create_x_image_and_pixmap earlier,
	to avoid much needless work if the image is too large.
	(tiff_load): Treat overly large images as if
	x_create_x_image_and_pixmap failed, not as malloc failures.
	(gs_load): Use x_check_image_size.

Paul Eggert's avatar
Paul Eggert committed
978 979 980 981
	* gtkutil.c: Omit integer casts.
	(xg_get_pixbuf_from_pixmap): Remove unnecessary cast.
	(xg_set_toolkit_scroll_bar_thumb): Rewrite to avoid need for cast.

982 983
	* image.c (png_load): Don't assume height * row_bytes fits in 'int'.

984 985 986 987
	* xfaces.c (Fbitmap_spec_p): Fix integer overflow bug.
	Without this fix, (bitmap-spec-p '(34359738368 1 "x"))
	would wrongly return t on a 64-bit host.

988 989 990 991 992
	* dispnew.c (init_display): Use *_RANGE_OVERFLOW macros.
	The plain *_OVERFLOW macros run afoul of GCC bug 49705
	<http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49705>
	and therefore cause GCC to emit a bogus diagnostic in some cases.

993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019
	* image.c: Integer signedness and overflow and related fixes.
	This is not an exhaustive set of fixes, but it's time to
	record what I've got.
	(lookup_pixel_color, check_image_size): Remove redundant decls.
	(check_image_size): Don't assume that arbitrary EMACS_INT values
	fit in 'int', or that arbitrary 'double' values fit in 'int'.
	(x_alloc_image_color, x_create_x_image_and_pixmap, png_load)
	(tiff_load, imagemagick_load_image):
	Check for overflow in size calculations.
	(x_create_x_image_and_pixmap): Remove unnecessary test for
	xmalloc returning NULL; that can't happen.
	(xbm_read_bitmap_data): Don't assume sizes fit into 'int'.
	(xpm_color_bucket): Use better integer hashing function.
	(xpm_cache_color): Don't possibly over-allocate memory.
	(struct png_memory_storage, tiff_memory_source, tiff_seek_in_memory)
	(gif_memory_source):
	Use ptrdiff_t, not int or size_t, to record sizes.
	(png_load): Don't assume values greater than 2**31 fit in 'int'.
	(our_stdio_fill_input_buffer): Prefer ptrdiff_t to size_t when
	either works, as we prefer signed integers.
	(tiff_read_from_memory, tiff_write_from_memory):
	Return tsize_t, not size_t, since that's what the TIFF API wants.
	(tiff_read_from_memory): Don't fail simply because the read would
	go past EOF; instead, return a short read.
	(tiff_load): Omit no-longer-needed casts.
	(Fimagemagick_types): Don't assume size fits into 'int'.

1020 1021 1022 1023 1024 1025 1026 1027 1028 1029
	Improve hashing quality when configured --with-wide-int.
	* fns.c (hash_string): New function, taken from sxhash_string.
	Do not discard information about ASCII character case; this
	discarding is no longer needed.
	(sxhash-string): Use it.  Change sig to match it.  Caller changed.
	* lisp.h: Declare it.
	* lread.c (hash_string): Remove, since we now use fns.c's version.
	The fns.c version returns a wider integer if --with-wide-int is
	specified, so this should help the quality of the hashing a bit.

1030 1031 1032 1033 1034
	* emacs.c: Integer overflow minor fix.
	(heap_bss_diff): Now uprintmax_t, not unsigned long.  All used changed.
	Define only if GNU_LINUX.
	(main, Fdump_emacs): Set and use heap_bss_diff only if GNU_LINUX.

1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047
	* dispnew.c: Integer signedness and overflow fixes.
	Remove unnecessary forward decls, that were a maintenance hassle.
	(history_tick): Now uprintmax_t, so it's more likely to avoid overflow.
	All uses changed.
	(adjust_glyph_matrix, realloc_glyph_pool, adjust_frame_message_buffer)
	(scrolling_window): Use ptrdiff_t, not int, for byte count.
	(prepare_desired_row, line_draw_cost):
	Use int, not unsigned, where either works.
	(save_current_matrix, restore_current_matrix):
	Use ptrdiff_t, not size_t, where either works.
	(init_display): Check for overflow more accurately, and without
	relying on undefined behavior.

1048 1049 1050 1051 1052 1053 1054 1055 1056 1057
	* editfns.c (pWIDE, pWIDElen, signed_wide, unsigned_wide):
	Remove, replacing with the new symbols in lisp.h.  All uses changed.
	* fileio.c (make_temp_name):
	* filelock.c (lock_file_1, lock_file):
	* xdisp.c (message_dolog):
	Don't assume PRIdMAX etc. works; this isn't portable to pre-C99 hosts.
	Use pMd etc. instead.
	* lisp.h (printmax_t, uprintmax_t, pMd, pMu): New types and macros,
	replacing the pWIDE etc. symbols removed from editfns.c.

1058 1059 1060 1061
	* keyboard.h (num_input_events): Now uintmax_t.
	This is (very slightly) less likely to mess up due to wraparound.
	All uses changed.

1062 1063 1064 1065 1066
	* buffer.c: Integer signedness fixes.
	(alloc_buffer_text, enlarge_buffer_text):
	Use ptrdiff_t rather than size_t when either will do, as we prefer
	signed integers.

1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090
	* alloc.c: Integer signedness and overflow fixes.
	Do not impose an arbitrary 32-bit limit on malloc sizes when debugging.
	(__malloc_size_t): Default to size_t, not to int.
	(pure_size, pure_bytes_used_before_overflow, stack_copy_size)
	(Fgarbage_collect, mark_object_loop_halt, mark_object):
	Prefer ptrdiff_t to size_t when either would do, as we prefer
	signed integers.
	(XMALLOC_OVERRUN_CHECK_OVERHEAD): New macro.
	(xmalloc_overrun_check_header, xmalloc_overrun_check_trailer):
	Now const.  Initialize with values that are in range even if char
	is signed.
	(XMALLOC_PUT_SIZE, XMALLOC_GET_SIZE): Remove, replacing with ...
	(xmalloc_put_size, xmalloc_get_size): New functions.  All uses changed.
	These functions do the right thing with sizes > 2**32.
	(check_depth): Now ptrdiff_t, not int.
	(overrun_check_malloc, overrun_check_realloc, overrun_check_free):
	Adjust to new way of storing sizes.  Check for size overflow bugs
	in rest of code.
	(STRING_BYTES_MAX): Adjust to new overheads.  The old code was
	slightly wrong anyway, as it missed one instance of
	XMALLOC_OVERRUN_CHECK_OVERHEAD.
	(refill_memory_reserve): Omit needless cast to size_t.
	(mark_object_loop_halt): Mark as externally visible.

1091 1092 1093 1094 1095 1096 1097
	* xselect.c: Integer signedness and overflow fixes.
	(Fx_register_dnd_atom, x_handle_dnd_message):
	Use ptrdiff_t, not size_t, since we prefer signed.
	(Fx_register_dnd_atom): Check for ptrdiff_t (and size_t) overflow.
	* xterm.h (struct x_display_info): Use ptrdiff_t, not size_t, for
	x_dnd_atoms_size and x_dnd_atoms_length.

1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108
	* doprnt.c: Prefer signed to unsigned when either works.
	* eval.c (verror):
	* doprnt.c (doprnt):
	* lisp.h (doprnt):
	* xdisp.c (vmessage):
	Use ptrdiff_t, not size_t, when using or implementing doprnt,
	since the sizes cannot exceed ptrdiff_t bounds anyway, and we
	prefer signed arithmetic to avoid comparison confusion.
	* doprnt.c (doprnt): Avoid a "+ 1" that can't overflow,
	but is a bit tricky.

1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120
	Assume freestanding C89 headers, string.h, stdlib.h.
	* data.c, doprnt.c, floatfns.c, print.c:
	Include float.h unconditionally.
	* gmalloc.c: Assume C89-at-least behavior for preprocessor,
	limits.h, stddef.h, string.h.  Use memset instead of 'flood'.
	* regex.c: Likewise for stddef.h, string.h.
	(ISASCII): Remove; can assume it returns 1 now.  All uses removed.
	* s/aix4-2.h (HAVE_STRING_H): Remove obsolete undef.
	* s/ms-w32.h (HAVE_LIMITS_H, HAVE_STRING_H, HAVE_STDLIB_H)
	(STDC_HEADERS): Remove obsolete defines.
	* sysdep.c: Include limits.h unconditionally.

Paul Eggert's avatar
Paul Eggert committed
1121 1122 1123 1124 1125 1126 1127 1128
	Assume support for memcmp, memcpy, memmove, memset.
	* lisp.h, sysdep.c (memcmp, memcpy, memmove, memset):
	* regex.c (memcmp, memcpy):
	Remove; we assume C89 now.

	* gmalloc.c (memcpy, memset, memmove): Remove; we assume C89 now.
	(__malloc_safe_bcopy): Remove; no longer needed.

Paul Eggert's avatar
Paul Eggert committed
1129
	* lisp.h (struct vectorlike_header, struct Lisp_Subr): Signed sizes.
1130 1131 1132
	Use EMACS_INT, not EMACS_UINT, for sizes.  The code works equally
	well either way, and we prefer signed to unsigned.

1133 1134 1135 1136 1137
2011-07-27  Lars Magne Ingebrigtsen  <larsi@gnus.org>

	* gnutls.c (emacs_gnutls_read): Don't message anything if the peer
	closes the connection while we're reading (bug#9182).

1138 1139 1140 1141 1142
2011-07-25  Jan Djärv  <jan.h.d@swipnet.se>

	* nsmenu.m (ns_popup_dialog): Add an "ok" button if no buttons
	are specified (Bug#9168).

1143 1144 1145 1146 1147
2011-07-25  Paul Eggert  <eggert@cs.ucla.edu>

	* bidi.c (bidi_dump_cached_states): Fix printf format mismatch.
	Found by GCC static checking and --with-wide-int on a 32-bit host.

1148
2011-07-25  Eli Zaretskii  <eliz@gnu.org>
1149 1150 1151 1152 1153

	* 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.

1154 1155 1156 1157 1158
2011-07-24  Eli Zaretskii  <eliz@gnu.org>

	* xfaces.c (check_lface_attrs) [HAVE_WINDOW_SYSTEM]: Allow `nil'
	for attrs[LFACE_FONTSET_INDEX].

1159 1160 1161 1162 1163
2011-07-23  Paul Eggert  <eggert@cs.ucla.edu>

	* xml.c (parse_region): Remove unused local
	that was recently introduced.

1164 1165
2011-07-23  Eli Zaretskii  <eliz@gnu.org>

1166 1167 1168
	* xfns.c (unwind_create_frame) [GLYPH_DEBUG]: Adapt to changes in
	2008-02-22T17:42:09Z!monnier@iro.umontreal.ca.

1169 1170
	* xdisp.c (move_it_in_display_line_to): Record the best matching
	position for TO_CHARPOS while scanning the line, and restore it on
1171 1172
	exit if none of the characters scanned was an exact match.
	Fixes vertical-motion and pos-visible-in-window-p under bidi redisplay
1173 1174 1175
	when exact match is impossible due to invisible text, and the
	lines are truncated.

1176 1177 1178 1179 1180
2011-07-23  Jan Djärv  <jan.h.d@swipnet.se>

	* nsterm.m (initFrameFromEmacs): Set NSTitledWindowMask in styleMask
	for OSX >= 10.7.

1181 1182
2011-07-22  Eli Zaretskii  <eliz@gnu.org>

1183 1184 1185
	Fix a significant slow-down of cursor motion with C-n, C-p,
	C-f/C-b, and C-v/M-v that couldn't keep up with keyboard
	auto-repeat under bidi redisplay in fontified buffers.
1186 1187 1188
	* 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
1189 1190 1191 1192 1193 1194
	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.
1195
	(compute_display_string_pos): Return the cached position if asked
1196 1197 1198
	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.
1199

1200 1201 1202 1203 1204
2011-07-22  Eli Zaretskii  <eliz@gnu.org>

	* xdisp.c (rows_from_pos_range): Don't ignore glyphs whose object
	is an integer, which is important for empty lines.  (Bug#9149)

Chong Yidong's avatar
Chong Yidong committed
1205 1206 1207 1208 1209
2011-07-22  Chong Yidong  <cyd@stupidchicken.com>

	* frame.c (Fmodify_frame_parameters): In tty case, update the
	default face if necessary (Bug#4238).

1210 1211 1212 1213 1214
2011-07-21  Chong Yidong  <cyd@stupidchicken.com>

	* editfns.c (Fstring_to_char): No need to explain what a character
	is in the docstring (Bug#6576).

1215 1216 1217 1218
2011-07-20  Lars Magne Ingebrigtsen  <larsi@gnus.org>

	* xml.c (parse_region): Make sure we always return a tree.

1219 1220 1221 1222 1223
2011-07-20  HAMANO Kiyoto  <khiker.mail@gmail.com>

	* xml.c (parse_region): If a document contains only comments,
	return that, too.

1224 1225 1226 1227
2011-07-20  Lars Magne Ingebrigtsen  <larsi@gnus.org>

	* xml.c (make_dom): Return comments, too.

Paul Eggert's avatar
Paul Eggert committed
1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240
2011-07-19  Paul Eggert  <eggert@cs.ucla.edu>

	Port to OpenBSD.
	See http://lists.gnu.org/archive/html/emacs-devel/2011-07/msg00688.html
	and the surrounding thread.
	* minibuf.c (read_minibuf_noninteractive): Rewrite to use getchar
	rather than fgets, and retry after EINTR.  Otherwise, 'emacs
	--batch -f byte-compile-file' fails on OpenBSD if an inactivity
	timer goes off.
	* s/openbsd.h (BROKEN_SIGIO): Define.
	* unexelf.c (unexec) [__OpenBSD__]:
	Don't update the .mdebug section of the Alpha COFF symbol table.

1241 1242 1243 1244 1245
2011-07-19  Lars Magne Ingebrigtsen  <larsi@gnus.org>

	* lread.c (syms_of_lread): Clarify when `lexical-binding' is used
	(bug#8460).

1246 1247
2011-07-18  Paul Eggert  <eggert@cs.ucla.edu>

1248 1249 1250 1251
	* fileio.c (Fcopy_file) [!MSDOS]: Tighten created file's mask.
	This fixes some race conditions on the permissions of any newly
	created file.

1252 1253 1254
	* alloc.c (valid_pointer_p): Use pipe, not open.
	This fixes some permissions issues when debugging.

1255 1256 1257 1258 1259
	* fileio.c (Fcopy_file): Adjust mode if fchown fails.  (Bug#9002)
	If fchown fails to set both uid and gid, try to set just gid,
	as that is sometimes allowed.  Adjust the file's mode to eliminate
	setuid or setgid bits that are inappropriate if fchown fails.

1260 1261 1262 1263 1264 1265 1266 1267
2011-07-18  Stefan Monnier  <monnier@iro.umontreal.ca>

	* xdisp.c (next_element_from_string, next_element_from_buffer): Use EQ
	to compare Lisp_Objects.
	* gnutls.c (syms_of_gnutls): Rename Vgnutls_log_level to
	global_gnutls_log_level, don't mistake it for a Lisp_Object.
	(init_gnutls_functions, emacs_gnutls_handle_error): Fix up uses.

1268 1269
2011-07-17  Andreas Schwab  <schwab@linux-m68k.org>

1270 1271 1272
	* lread.c (read_integer): Unread even EOF character.
	(read1): Likewise.  Properly record start position of symbol.

1273 1274 1275
	* lread.c (read1): Read `#:' as empty uninterned symbol if no
	symbol character follows.

1276 1277 1278 1279 1280 1281 1282 1283
2011-07-17  Paul Eggert  <eggert@cs.ucla.edu>

	* fileio.c (Fcopy_file): Pacify gcc re fchown.  (Bug#9002)
	This works around a problem with the previous change to Fcopy_file.
	Recent glibc declares fchown with __attribute__((warn_unused_result)),
	and without this change, GCC might complain about discarding
	fchown's return value.

1284 1285 1286 1287
2011-07-16  Juanma Barranquero  <lekktu@gmail.com>

	* makefile.w32-in (GLOBAL_SOURCES): Add gnutls.c (followup to bug#9059).

1288 1289 1290 1291
2011-07-16  Paul Eggert  <eggert@cs.ucla.edu>

	* fileio.c (Fcopy_file): Don't diagnose fchown failures.  (Bug#9002)

1292 1293
2011-07-16  Lars Magne Ingebrigtsen  <larsi@gnus.org>

1294 1295 1296
	* gnutls.c (syms_of_gnutls): Define `gnutls-log-level' here, since
	it's used from the C level.

1297 1298 1299
	* process.c: Use the same condition for POLL_FOR_INPUT in both
	keyboard.c and process.c (bug#1858).

1300 1301 1302 1303 1304
2011-07-09  Lawrence Mitchell  <wence@gmx.li>

	* gnutls.c (Qgnutls_bootprop_min_prime_bits): New variable.
	(Fgnutls_boot): Use it.

1305 1306 1307 1308
2011-07-15  Andreas Schwab  <schwab@linux-m68k.org>

	* doc.c (Fsubstitute_command_keys): Revert last change.

1309 1310
2011-07-15  Lars Magne Ingebrigtsen  <larsi@gnus.org>

1311 1312 1313 1314
	* doc.c (Fsubstitute_command_keys): Clarify that \= really only
	quotes the next character, and doesn't affect other longer
	sequences (bug#8935).

1315 1316 1317 1318
	* lread.c (syms_of_lread): Clarify that is isn't only
	`eval-buffer' and `eval-defun' that's affected by
	`lexical-binding' (bug#8460).

1319 1320 1321 1322 1323 1324
2011-07-15  Eli Zaretskii  <eliz@gnu.org>

	* xdisp.c (move_it_in_display_line_to): Fix vertical motion with
	bidi redisplay when a line includes both an image and is
	truncated.

1325 1326
2011-07-14  Paul Eggert  <eggert@cs.ucla.edu>

1327 1328 1329 1330 1331 1332 1333
	Fix minor problems found by static checking.
	* bidi.c (bidi_cache_size): Now EMACS_INT, not size_t.
	(elsz): Now a signed constant, not a size_t var.  We prefer signed
	types to unsigned, to avoid integer comparison confusion.  Without
	this change, GCC 4.6.1 with -Wunsafe-loop-optimizations complains
	"cannot optimize loop, the loop counter may overflow", a symptom
	of the confusion.
1334
	* indent.c (Fvertical_motion): Mark locals as initialized.
1335 1336
	* xdisp.c (reseat_to_string): Fix pointer signedness issue.

1337 1338
2011-07-14  Lars Magne Ingebrigtsen  <larsi@gnus.org>

1339 1340 1341
	* search.c (Fre_search_backward): Mention `case-fold-search' in
	all the re_search_* functions (bug#8138).

1342 1343 1344
	* keyboard.c (Fopen_dribble_file): Document when the file is
	closed (bug#8056).

1345 1346
2011-07-14  Eli Zaretskii  <eliz@gnu.org>

1347 1348 1349
	* bidi.c (bidi_dump_cached_states): Fix format of displaying
	bidi_cache_idx.

1350 1351 1352 1353 1354 1355 1356
	Support bidi reordering of display and overlay strings.
	* xdisp.c (compute_display_string_pos)
	(compute_display_string_end): Accept additional argument STRING.
	(init_iterator, reseat_1): Initialize bidi_it->string.s to NULL.
	(reseat_to_string): Initialize bidi_it->string.s and
	bidi_it->string.schars.
	(Fcurrent_bidi_paragraph_direction): Initialize itb.string.s to
1357 1358
	NULL (avoids a crash in bidi_paragraph_init).
	Initialize itb.string.lstring.
1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373
	(init_iterator): Call bidi_init_it only of a valid
	buffer position was specified.  Initialize paragraph_embedding to
	L2R.
	(reseat_to_string): Initialize the bidi iterator.
	(display_string): If we need to ignore text properties of
	LISP_STRING, set IT->stop_charpos to IT->end_charpos.  (The
	original value of -1 will not work with bidi.)
	(compute_display_string_pos): First arg is now struct
	`text_pos *'; all callers changed.  Support display properties on
	Lisp strings.
	(compute_display_string_end): Support display properties on Lisp
	strings.
	(init_iterator, reseat_1, reseat_to_string): Initialize the
	string.bufpos member to 0 (zero, for compatibility with IT_CHARPOS
	when iterating on a string not from display properties).
1374 1375
	(compute_display_string_pos, compute_display_string_end):
	Fix calculation of the object to scan.  Fixes an error when using
1376 1377
	arrow keys.
	(next_element_from_buffer): Don't abort when IT_CHARPOS is before
1378 1379
	base_level_stop; instead, set base_level_stop to BEGV.
	Fixes crashes in vertical-motion.
1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391
	(next_element_from_buffer): Improve commentary for when
	the iterator is before prev_stop.
	(init_iterator): Initialize bidi_p from the default value of
	bidi-display-reordering, not from buffer-local value.  Use the
	buffer-local value only if initializing for buffer iteration.
	(handle_invisible_prop): Support invisible properties on strings
	that are being bidi-reordered.
	(set_iterator_to_next): Support bidi reordering of C strings and
	Lisp strings.
	(next_element_from_string): Support bidi reordering of Lisp
	strings.
	(handle_stop_backwards): Support Lisp strings as well.
1392 1393
	(display_string): Support display of R2L glyph rows.
	Use IT_STRING_CHARPOS when displaying from a Lisp string.
1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474
	(init_iterator): Don't initialize it->bidi_p for strings
	here.
	(reseat_to_string): Initialize it->bidi_p for strings here.
	(next_element_from_string, next_element_from_c_string)
	(next_element_from_buffer): Add xassert's for correspondence
	between IT's object being iterated and it->bidi_it.string
	structure.
	(face_before_or_after_it_pos): Support bidi iteration.
	(next_element_from_c_string): Handle the case of the first string
	character that is not the first one in the visual order.
	(get_visually_first_element): New function, refactored from common
	parts of next_element_from_buffer, next_element_from_string, and
	next_element_from_c_string.
	(tool_bar_lines_needed, redisplay_tool_bar)
	(display_menu_bar): Force left-to-right direction.  Add a FIXME
	comment for making that be controlled by a user option.
	(push_it, pop_it): Save and restore the state of the
	bidi iterator.  Save and restore the bidi_p flag.
	(pop_it): Iterate out of display property for string iteration as
	well.
	(iterate_out_of_display_property): Support iteration over strings.
	(handle_single_display_spec): Set up it->bidi_it for iteration
	over a display string, and call bidi_init_it.
	(handle_single_display_spec, next_overlay_string)
	(get_overlay_strings_1, push_display_prop): Set up the bidi
	iterator for displaying display or overlay strings.
	(forward_to_next_line_start): Don't use the shortcut if
	bidi-iterating.
	(back_to_previous_visible_line_start): If handle_display_prop
	pushed the iterator stack, restore the internal state of the bidi
	iterator by calling bidi_pop_it same number of times.
	(reseat_at_next_visible_line_start): If ON_NEWLINE_P is non-zero,
	and we are bidi-iterating, don't decrement the iterator position;
	instead, set the first_elt flag in the bidi iterator, to produce
	the same effect.
	(reseat_1): Remove redundant setting of string_from_display_prop_p.
	(push_display_prop): xassert that we are iterating a buffer.
	(push_it, pop_it): Save and restore paragraph_embedding member.
	(handle_single_display_spec, next_overlay_string)
	(get_overlay_strings_1, reseat_1, reseat_to_string)
	(push_display_prop): Set up the `unibyte' member of bidi_it.string
	correctly.  Don't assume unibyte strings are not bidi-reordered.
	(compute_display_string_pos)
	(compute_display_string_end): Fix handling the case of C string.
	(push_it, pop_it): Save and restore from_disp_prop_p.
	(handle_single_display_spec, push_display_prop): Set the
	from_disp_prop_p flag.
	(get_overlay_strings_1): Reset the from_disp_prop_p flag.
	(pop_it): Call iterate_out_of_display_property only if we are
	popping after iteration over a string that came from a display
	property.  Fix a typo in popping stretch info.  Add an assertion
	for verifying that the iterator position is in sync with the bidi
	iterator.
	(handle_single_display_spec, get_overlay_strings_1)
	(push_display_prop): Fix initialization of paragraph direction for
	string when that of the parent object is not yet determined.
	(reseat_1): Call bidi_init_it to resync the bidi
	iterator with IT's position.  (Bug#7616)
	(find_row_edges): If ROW->start.pos gives position
	smaller than min_pos, use it as ROW->minpos.  (Bug#7616)
	(handle_stop, back_to_previous_visible_line_start, reseat_1):
	Reset the from_disp_prop_p flag.
	(SAVE_IT, RESTORE_IT): New macros.
	(pos_visible_p, face_before_or_after_it_pos)
	(back_to_previous_visible_line_start)
	(move_it_in_display_line_to, move_it_in_display_line)
	(move_it_to, move_it_vertically_backward, move_it_by_lines)
	(try_scrolling, redisplay_window, display_line): Use them when
	saving a temporary copy of the iterator and restoring it back.
	(back_to_previous_visible_line_start, reseat_1)
	(init_iterator): Empty the bidi cache "stack".
	(move_it_in_display_line_to): If iterator ended up at
	EOL, but we never saw any buffer positions smaller than
	to_charpos, return MOVE_POS_MATCH_OR_ZV.  Fixes vertical cursor
	motion in bidi-reordered lines.
	(move_it_in_display_line_to): Record prev_method and prev_pos
	immediately before the call to set_iterator_to_next.  Fixes cursor
	motion in bidi-reordered lines with stretch glyphs and strings
	displayed in margins.  (Bug#8133) (Bug#8867)
	Return MOVE_POS_MATCH_OR_ZV only if iterator position is past
	TO_CHARPOS.
1475 1476
	(pos_visible_p): Support positions in bidi-reordered lines.
	Save and restore bidi cache.
1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495

	* bidi.c (bidi_level_of_next_char): clen should be EMACS_NT, not int.
	(bidi_paragraph_info): Delete unused struct.
	(bidi_cache_idx, bidi_cache_last_idx): Declare EMACS_INT.
	(bidi_cache_start): New variable.
	(bidi_cache_reset): Reset bidi_cache_idx to bidi_cache_start, not
	to zero.
	(bidi_cache_fetch_state, bidi_cache_search)
	(bidi_cache_find_level_change, bidi_cache_iterator_state)
	(bidi_cache_find, bidi_peek_at_next_level)
	(bidi_level_of_next_char, bidi_find_other_level_edge)
	(bidi_move_to_visually_next): Compare cache index with
	bidi_cache_start rather than with zero.
	(bidi_fetch_char): Accept new argument STRING; all callers
	changed.  Support iteration over a string.  Support strings with
	display properties.  Support unibyte strings.  Fix the type of
	`len' according to what STRING_CHAR_AND_LENGTH expects.
	(bidi_paragraph_init, bidi_resolve_explicit_1)
	(bidi_resolve_explicit, bidi_resolve_weak)
1496 1497
	(bidi_level_of_next_char, bidi_move_to_visually_next):
	Support iteration over a string.
1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517