Avoid character to byte conversions in motion subroutines.
[bpt/emacs.git] / src / ChangeLog
index 6ff25ed..bc106df 100644 (file)
@@ -1,3 +1,440 @@
+2013-03-07  Dmitry Antipov  <dmantipov@yandex.ru>
+
+       Avoid character to byte conversions in motion subroutines.
+       * indent.h (compute_motion, vmotion): Add byte position argument.
+       * indent.c (compute_motion): Use it and avoid CHAR_TO_BYTE.
+       Add eassert.
+       (Fcompute_motion): Break long line.  Adjust call to compute_motion.
+       Use list5 for return value.
+       (vmotion): Use byte position argument and avoid call to CHAR_TO_BYTE.
+       Adjust comments, style and calls to compute_motion.
+       (Fvertical_motion): Adjust call to vmotion.
+       * window.c (Fdelete_other_windows_internal): Record window start
+       byte position and adjust call to vmotion.
+       (window_scroll_line_based): Likewise with call to compute_motion.
+       Use SET_PT_BOTH.
+       (Frecenter): Adjust calls to vmotion.
+
+2013-03-07  Dmitry Antipov  <dmantipov@yandex.ru>
+
+       * lisp.h (list2i, list3i): New functions.
+       (list4i): Move from window.c and make LISP_INLINE.
+       * editfns.c (make_lisp_time):
+       * fns.c (Flocale_info):
+       * keyboard.c (parse_modifiers):
+       * xterm.c (x_ewmh_activate_frame): Use list2i.
+       * instel.c (signal_after_change):
+       * nsfns.m (Fx_server_version, Fxw_color_values):
+       * w32fns.c (Fxw_color_values, Fx_server_version):
+       * xfns.c (Fxw_color_values, Fx_server_version): Use list3i.
+       * fileio.c (Fvisited_file_modtime):
+       * nsfns.m (Fns_display_usable_bounds):
+       * w32.c (ltime): Use list4i.
+
+2013-03-06  Eli Zaretskii  <eliz@gnu.org>
+
+       * search.c (find_newline_no_quit): Rename from find_next_newline.
+       Add commentary.
+
+       * lisp.h (find_newline_no_quit): Rename prototype.
+
+       * xdisp.c (back_to_previous_line_start)
+       (forward_to_next_line_start, get_visually_first_element)
+       (move_it_vertically_backward): Callers of find_newline_no_quit changed.
+       * indent.c (vmotion): Callers of find_newline_no_quit changed.
+       * bidi.c (bidi_find_paragraph_start): Callers of
+       find_newline_no_quit changed.
+
+       * msdos.c: Change encoding to cp850.  (Bug#13879)
+       (fr_keyboard, it_keyboard, dk_keyboard): Update keyboard layouts.
+
+2013-03-06  Dmitry Antipov  <dmantipov@yandex.ru>
+
+       Coding system support cleanup and minor refactoring.
+       * coding.h (enum coding_result_code): Remove
+       CODING_RESULT_INCONSISTENT_EOL and CODING_RESULT_INSUFFICIENT_MEM.
+       (toplevel): Remove unused CODING_MODE_INHIBIT_INCONSISTENT_EOL.
+       (CODING_MODE_LAST_BLOCK, CODING_MODE_SELECTIVE_DISPLAY)
+       (CODING_MODE_DIRECTION, CODING_MODE_FIXED_DESTINATION)
+       (CODING_MODE_SAFE_ENCODING): Rearrange bit values.
+       (decode_coding_region, encode_coding_region, decode_coding_string):
+       Remove unused compatibility macros.
+       * coding.c (Qinconsistent_eol, Qinsufficient_memory): Remove.
+       (record_conversion_result): Adjust user.
+       (syms_of_coding): Likewise.
+       (ALLOC_CONVERSION_WORK_AREA): Use SAFE_ALLOCA.
+       (decode_coding, encode_coding): Add USE_SAFE_ALLOCA and SAFE_FREE.
+       (decode_coding_object): Simplify since xrealloc never returns NULL.
+       Add eassert.
+
+2013-03-06  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Fix a build failure on OpenBSD 4.x and MirBSD (Bug#13881).
+       * sysdep.c (list_system_processes)
+       [BSD_SYSTEM && !DARWIN_OS && !__FreeBSD__]:
+       Make it a stub in this case; otherwise the build might fail,
+       and this code hasn't been tested on such hosts anyway.
+       Problem reported by Nelson H. F. Beebe in
+       <http://lists.gnu.org/archive/html/emacs-devel/2013-03/msg00021.html>
+       and analyzed by Jérémie Courrèges-Anglas in
+       <http://lists.gnu.org/archive/html/emacs-devel/2013-03/msg00062.html>.
+
+2013-03-06  Dmitry Antipov  <dmantipov@yandex.ru>
+
+       * lisp.h (find_next_newline_no_quit): Rename to find_next_newline.
+       * xdisp.c (back_to_previous_line_start, forward_to_next_line_start)
+       (get_visually_first_element, move_it_vertically_backward): Ajust users.
+       * bidi.c (bidi_find_paragraph_start): Likewise.
+       * indent.c (vmotion): Likewise.
+
+2013-03-05  Paul Eggert  <eggert@cs.ucla.edu>
+
+       FILE's lock is now always .#FILE and may be a regular file (Bug#13807).
+       * filelock.c: Include <c-ctype.h>.
+       (MAX_LFINFO): New top-level constant.
+       (lock_info_type): Remove members pid, boot_time.  Add members at,
+       dot, colon.  Change user member to be the entire buffer, not a
+       pointer.  This allows us to handle the case where a foreign
+       pid or boot time exceeds the local range.  All uses changed.
+       (LINKS_MIGHT_NOT_WORK): New constant.
+       (FREE_LOCK_INFO): Remove, as the pieces no longer need freeing.
+       (defined_WINDOWSNT): Remove.
+       (MAKE_LOCK_NAME, file_in_lock_file_name):
+       Always use .#FILE (not .#-FILE) for the file lock,
+       even if it is a regular file.
+       (rename_lock_file): New function.
+       (create_lock_file): Use it.
+       (create_lock_file, read_lock_data):
+       Prefer a symbolic link for the lock file, falling back on a
+       regular file if symlinks don't work.  Do not try to create
+       symlinks on MS-Windows, due to security hassles.  Stick with
+       POSIXish functions (open, read, write, close, fchmod, readlink, symlink,
+       link, rename, unlink, mkstemp) when creating locks, as a GNUish
+       host may be using a Windowsish file system, and cannot use
+       MS-Windows-only system calls.  Fall back on mktemp if mkstemp
+       doesn't work.  Don't fail merely because of a symlink-contents
+       length limit in the current file system; fall back on regular
+       files.  Increase the symlink contents length limit to 8 KiB, this
+       should be big enough for any real use and doesn't crunch the
+       stack.
+       (create_lock_file, lock_file_1, read_lock_data):
+       Simplify allocation of lock file buffers now that they fit in 8 KiB.
+       (lock_file_1): Return error number, not bool.  All callers changed.
+       (ELOOP): New macro, if not already defined.
+       (read_lock_data): Return size of lock file contents, not Lisp object.
+       All callers changed.  Handle a race condition if some other process
+       replaces a regular-file lock with a symlink lock or vice versa,
+       while we're trying to read the lock.
+       (current_lock_owner): Parse contents more carefully, to help avoid
+       confusing a regular-file lock with some other application's use
+       of the file.  Check for lock file contents being too long, or
+       not parsing correctly.
+       (current_lock_owner, lock_file):
+       Allow foreign pid and boot times that exceed the local range.
+       (current_lock_owner, lock_if_free, lock_file):
+       Simplify allocation of lock file contents.
+       * w32.c (sys_rename_replace): New function, containing most of
+       the contents of the old sys_rename.
+       (sys_rename): Use it.
+       (fchmod): New dummy function.
+       * w32.h (sys_rename_replace, fchmod): New decls.
+
+2013-03-05  Eli Zaretskii  <eliz@gnu.org>
+
+       * bidi.c (bidi_resolve_explicit_1): Don't call CHAR_TO_BYTE or
+       bidi_count_bytes, as the callers now arrange for bidi_it->charpos
+       to be in sync with bidi_it->bytepos.  Suggested by Dmitry Antipov
+       <dmantipov@yandex.ru>.
+
+2013-03-05  Dmitry Antipov  <dmantipov@yandex.ru>
+
+       * composite.c (get_composition_id, fill_gstring_header):
+       Use make_uninit_vector where appropriate.
+       * font.c (Ffont_get_glyphs, build_style_table): Likewise.
+       * xselect.c (clean_local_selection_data): Likewise.
+
+2013-03-04  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Fix misuse of ImageMagick that caused core dump (Bug#13846).
+       * image.c (imagemagick_load_image): Calculate height and width
+       after flattening the image, not before.
+
+2013-03-04  Dmitry Antipov  <dmantipov@yandex.ru>
+
+       * font.c (Ffont_get_glyphs): Use convenient LGLYPH_NEW.
+       * ftfont.c (ftfont_shape_by_flt): Likewise.
+       * w32uniscribe.c (uniscribe_shape): Likewise.
+
+2013-03-02  Paul Eggert  <eggert@cs.ucla.edu>
+
+       The lock for FILE is now .#FILE or .#-FILE (Bug#13807).
+       The old approach, which fell back on DIR/.#FILE.0 through
+       DIR/.#FILE.9, had race conditions that could not be easily fixed.
+       If DIR/.#FILE is a non-symlink file, Emacs now does not create a
+       lock file for DIR/FILE; that is, DIR/FILE is no longer partly
+       protected by a lock if DIR/.#FILE is a non-symlink file ("partly"
+       because the locking mechanism was never reliable in that case).
+       This patch fixes this and other bugs discovered by a code
+       inspection that was prompted by
+       <http://lists.gnu.org/archive/html/emacs-devel/2013-02/msg00531.html>.
+       Also, this patch switches to .#-FILE (not .#FILE) on MS-Windows,
+       to avoid interoperability problems between the MS-Windows and
+       non-MS-Windows implementations.  MS-Windows and non-MS-Windows
+       instances of Emacs now ignore each others' locks.
+       * filelock.c (defined_WINDOWSNT): New constant.
+       (MAKE_LOCK_NAME, fill_in_lock_file_name):
+       Don't create DIR/.#FILE.0 through DIR/.#FILE.9.  Instead, create
+       DIR/.#FILE symlinks on non-MS-Windows hosts, and DIR/.#-FILE
+       regular files on MS-Windows hosts.
+       (MAKE_LOCK_NAME, unlock_file, Ffile_locked_p):
+       Use SAFE_ALLOCA to avoid problems with long file names.
+       (MAX_LFINFO): Now a local constant, not a global macro.
+       (IS_LOCK_FILE): Remove.
+       (lock_file_1): Don't inspect errno if symlink call succeeds;
+       that's not portable.
+       (lock_file): Document that this function can return if lock
+       creation fails.
+       (lock_file): Don't access freed storage.
+
+2013-03-02  Andreas Schwab  <schwab@linux-m68k.org>
+
+       * lisp.h (XPNTR) [!USE_LSB_TAG]: Remove extra paren.  (Bug#13734)
+
+2013-03-02  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * textprop.c: Use bool for booleans.
+       (validate_interval_range, Fadd_text_properties)
+       (Fremove_text_properties): Prefer bool to int when either works.
+
+2013-03-02  Eli Zaretskii  <eliz@gnu.org>
+
+       * textprop.c (Fadd_text_properties, Fremove_text_properties): If
+       the interval tree changes as a side effect of calling
+       modify_region, re-do processing starting from the call to
+       validate_interval_range.  (Bug#13743)
+
+2013-02-28  Eli Zaretskii  <eliz@gnu.org>
+
+       * w32.c (sys_open): Don't reset the flags for FD in fd_info[].
+       (Bug#13546).
+
+2013-02-27  Eli Zaretskii  <eliz@gnu.org>
+
+       * filelock.c (create_lock_file) [WINDOWSNT]: Use _sopen with
+       _SH_DENYRW flag, instead of emacs_open, to deny any other process
+       access to the lock file until it is written and closed.
+       (Bug#13807)
+
+2013-02-27  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * callint.c (Qcall_interactively):
+       * macros.c (Qexecute_kbd_macro):
+       Now static.
+
+2013-02-26  Bastien Guerry  <bzg@gnu.org>
+
+       * window.c (Frecenter): Tiny docstring enhancement.
+
+2013-02-26  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Minor textprop integer cleanup.
+       * intervals.h, textprop.c (add_text_properties_from_list):
+       Return void, not int, since nobody uses the return value.
+       * textprop.c (validate_plist, add_properties, remove_properties)
+       (Fadd_text_properties):
+       Don't assume list length fits in int.
+       (interval_has_all_properties, interval_has_some_properties)
+       (interval_has_some_properties_list, add_properties, remove_properties)
+       (Fadd_text_properties, Fremove_text_properties)
+       (Fremove_list_of_text_properties, text_property_stickiness):
+       Use bool for booleans.
+       (Fadd_text_properties, Fremove_text_properties):
+       (Fremove_list_of_text_properties):
+       Reindent do-while as per GNU style.
+
+2013-02-25  Eli Zaretskii  <eliz@gnu.org>
+
+       Implement CLASH_DETECTION for MS-Windows.
+
+       * filelock.c [WINDOWSNT]: Include w32.h.
+       (MAKE_LOCK_NAME): Don't use 'lock', it clashes with MS runtime
+       function of that name.  Up-case the macro arguments.
+       (IS_LOCK_FILE): New macro.
+       (fill_in_lock_file_name): Use IS_LOCK_FILE instead of S_ISLNK.
+       (create_lock_file): New function, with body extracted from
+       lock_file_1.
+       [WINDOWSNT]: Implement lock files by writing a regular file with
+       the lock information as its contents.
+       (read_lock_data): New function, on Posix platforms just calls
+       emacs_readlinkat.
+       [WINDOWSNT]: Read the lock info from the file.
+       (current_lock_owner): Call read_lock_data instead of calling
+       emacs_readlinkat directly.
+       (lock_file) [WINDOWSNT]: Run the file name through
+       dostounix_filename.
+
+       * w32proc.c (sys_kill): Support the case of SIG = 0, in which case
+       just check if the process by that PID exists.
+
+       * w32.c (sys_open): Don't reset the _O_CREAT flag if _O_EXCL is
+       also present, as doing so will fail to error out if the file
+       already exists.
+
+       * makefile.w32-in ($(BLD)/filelock.$(O)): Depend on src/w32.h.
+
+       * textprop.c (Fadd_text_properties, Fremove_text_properties)
+       (Fremove_list_of_text_properties): Skip all of the intervals in
+       the region between START and END that already have resp. don't
+       have the requested properties, not just the first one.  Add
+       assertions that the loop afterwards always modifies the
+       properties.  (Bug#13743)
+
+2013-02-25  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * callint.c (Fcall_interactively): Use the right lexical environment
+       for `interactive' specs (bug#13811).
+       * eval.c (Feval): Accept a lexical environment.
+
+2013-02-25  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Simplify data_start configuration (Bug#13783).
+       This is a followon simplification to the fix for Bug#13650.
+       * Makefile.in (LD_FIRSTFLAG, LIB_GCC, CRT_DIR, LIB_STANDARD)
+       (START_FILES): Remove.  All uses removed.
+       (otherobj): Remove $(VMLIMIT_OBJ), as it's now first.
+       (ALLOBJS): Move here from autodeps.mk, and with VMLIMITS_OBJ first.
+       (buildobj.h): Use it.
+       ($(ALLOBJS)): Depend on globals.h.
+       (temacs$(EXEEXT)): Use $(ALLOBJS).
+       * autodeps.mk (ALLOBJS): Move to Makefile.in.
+       * deps.mk (vm-limit.o):
+       * makefile.w32-in ($(BLD)/vm-limit.$(O)):
+       Do not depend on mem-limits.h.
+       * emacs.c (__do_global_ctors, __do_global_ctors_aux)
+       (__do_global_dtors, __CTOR_LIST__, __DTOR_LIST__)
+       [__GNUC__ && !ORDINARY_LINK]: Remove.
+       * mem-limits.h, pre-crt0.c: Remove.
+       * unexaix.c, unexcoff.c: Don't include mem-limits.h.
+       * unexcoff.c (etext): New decl.
+       (make_hdr): Use DATA_START instead of start_of_data.
+       * vm-limit.c: Move most of mem-limits.h's contents here.
+       (data_start): New decl.  It's OK if this is approximate,
+       so simplify-away some unnecessary exactness.
+       (POINTER): Remove; all uses removed.
+       (data_space_start): Now char *, to avoid casts.
+       (exceeds_lisp_ptr): New function, replacing the old
+       EXCEEDS_LISP_PTR macro.  All uses changed.
+       (check_memory_limits): Simplify and remove casts.
+       (start_of_data) [!CANNOT_DUMP || !SYSTEM_MALLOC]: Remove.
+       (memory_warnings): Use data_start instead of start_of_data.
+
+2013-02-24  Andreas Schwab  <schwab@linux-m68k.org>
+
+       * xdisp.c (set_message): Only check for debug-on-message if STRING
+       is a string.  (Bug#13797)
+
+2013-02-24  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Fix regression introduced by July 10 filelock.c patch.
+       * filelock.c (fill_in_lock_file_name): Fix crash caused by the
+       2012-07-10 patch to this file.  Reported by Eli Zaretskii in
+       <http://lists.gnu.org/archive/html/emacs-devel/2013-02/msg00533.html>
+       and diagnosed by Andreas Schwab in
+       <http://lists.gnu.org/archive/html/emacs-devel/2013-02/msg00534.html>.
+
+2013-02-22  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Assume C89 or better.
+       * ralloc.c (SIZE, POINTER, NIL):
+       * vm-limit.c (POINTER):
+       Remove, replacing all uses with C89 equivalents.  These old
+       symbols were present only for porting to pre-C89 platforms.
+
+2013-02-22  Claudio Bley  <claudio.bley@gmail.com>
+
+       * w32.c (emacs_gnutls_pull): Don't call 'select', and don't loop.
+       This avoids warning messages reported as part of Bug#13546.
+
+2013-02-21  Ken Brown  <kbrown@cornell.edu>
+
+       * sheap.c (report_sheap_usage): Fix arguments of message1_no_log.
+
+2013-02-20  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * sheap.c (report_sheap_usage): Prefer message1_nolog.
+
+       * keyboard.c (Qcommand_execute): New var.
+       (command_loop_1, read_char): Use it.
+       (Fcommand_execute): Remove, replace by an Elisp implementation.
+       (syms_of_keyboard): Adjust accordingly.
+
+2013-02-19  Daniel Colascione <dancol@dancol.org>
+
+       * sheap.c (report_sheap_usage): Use message, not message1, so
+       that we don't try to create a buffer while we're in the middle
+       of dumping Emacs.  Explain why.
+
+2013-02-20  Dmitry Antipov  <dmantipov@yandex.ru>
+
+       * search.c (find_newline): Return byte position in bytepos.
+       Adjust comment.
+       (find_next_newline_no_quit, find_before_next_newline):
+       Add bytepos argument.
+       * lisp.h (find_newline, find_next_newline_no_quit)
+       (find_before_next_newline): Adjust prototypes.
+       * bidi.c (bidi_find_paragraph_start):
+       * editfns.c (Fconstrain_to_field, Fline_end_position):
+       * indent.c (compute_motion, vmotion):
+       * xdisp.c (back_to_previous_line_start, forward_to_next_line_start):
+       (get_visually_first_element, move_it_vertically_backward):
+       Adjust users and avoid calls to CHAR_TO_BYTE where appropriate.
+
+2013-02-19  Eli Zaretskii  <eliz@gnu.org>
+
+       * w32proc.c (new_child): Avoid leaking handles if the subprocess
+       resources were not orderly released.
+
+2013-02-17  Eli Zaretskii  <eliz@gnu.org>
+
+       * xdisp.c (x_draw_vertical_border): For a window that is neither
+       the leftmost nor the rightmost, redraw both the left and the right
+       vertical borders.  (Bug#13723)
+
+2013-02-17  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * xml.c (init_libxml2_functions):
+       * sound.c (sound_warning):
+       * sheap.c (report_sheap_usage):
+       * process.c (wait_reading_process_output):
+       * msdos.c (XMenuActivate):
+       * macros.c (Fstart_kbd_macro, Fend_kbd_macro):
+       * keyboard.c (top_level_1):
+       * editfns.c (Fmessage, Fmessage_box):
+       * callint.c (Fcall_interactively):
+       * fns.c (Fyes_or_no_p): Prefer `message1' over `message'.
+
+2013-02-17  Jan Djärv  <jan.h.d@swipnet.se>
+
+       * xterm.c (syms_of_xterm): Move scroll-bar-adjust-thumb-portion ...
+       * frame.c (syms_of_frame): ... to here.
+
+2013-02-16  Eli Zaretskii  <eliz@gnu.org>
+
+       * w32.c (sys_chown): Remove unused function.
+
+       * w32term.c <input_signal_count>: Declare 'volatile'
+       unconditionally.  (Bug#9066)
+
+       * w32.c (set_errno): Reset h_errno and don't set it to any other
+       value.  Set errno instead.
+       (check_errno): Reset h_errno.
+       (sys_socket, socket_to_fd, sys_bind, sys_connect)
+       (sys_gethostname, sys_getservbyname, sys_getpeername)
+       (sys_shutdown, sys_setsockopt, sys_listen, sys_getsockname)
+       (sys_accept, sys_recvfrom, sys_sendto, fcntl, sys_read): Don't set
+       h_errno.
+       (sys_gethostbyname): Set h_errno only errors detected.
+
 2013-02-15  Paul Eggert  <eggert@cs.ucla.edu>
 
        * process.c (h_errno) [!HAVE_H_ERRNO]: Remove unused decl.