1. 13 Jul, 2018 2 commits
    • Tom Tromey's avatar
      Make format handle bignums · d14808cd
      Tom Tromey authored
      * src/editfns.c (styled_format): Handle bignums.
      * test/src/editfns-tests.el (read-large-integer): Update.
      (format-bignum): New test.
      d14808cd
    • Tom Tromey's avatar
      Rename integerp->fixnum, etc, in preparation for bignums · 42fe787b
      Tom Tromey authored
      * src/json.c, src/keyboard.c, src/keyboard.h, src/keymap.c,
      src/kqueue.c, src/lcms.c, src/lisp.h, src/lread.c, src/macros.c,
      src/marker.c, src/menu.c, src/minibuf.c, src/msdos.c, src/print.c,
      src/process.c, src/profiler.c, src/search.c, src/sound.c,
      src/syntax.c, src/sysdep.c, src/term.c, src/terminal.c,
      src/textprop.c, src/undo.c, src/w16select.c, src/w32.c,
      src/w32console.c, src/w32cygwinx.c, src/w32fns.c, src/w32font.c,
      src/w32inevt.c, src/w32proc.c, src/w32select.c, src/w32term.c,
      src/w32uniscribe.c, src/widget.c, src/window.c, src/xdisp.c,
      src/xfaces.c, src/xfns.c, src/xfont.c, src/xftfont.c, src/xmenu.c,
      src/xrdb.c, src/xselect.c, src/xterm.c, src/xwidget.c: Rename
      INTEGERP->FIXNUM, make_number->make_fixnum, CHECK_NUMBER->CHECK_FIXNUM,
      make_natnum->make_fixed_natum, NUMBERP->FIXED_OR_FLOATP,
      NATNUMP->FIXNATP, CHECK_NATNUM->CHECK_FIXNAT.
      42fe787b
  2. 03 Jul, 2018 1 commit
    • Eli Zaretskii's avatar
      Speed up 'replace-buffer-contents' some more · 0dce5e59
      Eli Zaretskii authored
      * src/editfns.c (EXTRA_CONTEXT_FIELDS): New members beg_a and beg_b.
      (Freplace_buffer_contents): Set up ctx.beg_a and ctx.beg_b.
      (buffer_chars_equal): Use ctx->beg_a and ctx->beg_b instead of
      calling BUF_BEGV, which is expensive.  This speeds up the recipe
      in bug#31888 by 30%.
      0dce5e59
  3. 30 Jun, 2018 2 commits
    • Eli Zaretskii's avatar
      Improve on last change in replace-buffer-contents · ab983522
      Eli Zaretskii authored
      * src/editfns.c (Freplace_buffer_contents): Call modification
      hooks only for the actual region where changes are made.
      (Bug#31888)
      ab983522
    • Paul Eggert's avatar
      unbind_to performance tuning · 2e281186
      Paul Eggert authored
      * src/alloc.c (which_symbols):
      * src/dispnew.c (Fredisplay):
      * src/editfns.c (Fsubst_char_in_region):
      * src/fileio.c (Fdo_auto_save):
      * src/indent.c (Fvertical_motion):
      * src/keymap.c (Fcurrent_active_maps):
      * src/lread.c (Feval_buffer):
      * src/minibuf.c (get_minibuffer):
      * src/sysdep.c (system_process_attributes):
      * src/textprop.c (Fnext_single_char_property_change)
      (Fprevious_single_char_property_change):
      * src/window.c (Fscroll_other_window, Fscroll_other_window_down):
      * src/xdisp.c (Fformat_mode_line):
      Help the compiler eliminate tail recursion in call to unbind_to.
      * src/coding.c (decode_coding_gap):
      Omit unnecessary unbind_to, as we’re about to call unbind_to anyway.
      * src/coding.c (Fread_coding_system):
      * src/eval.c (eval_sub):
      * src/xdisp.c (handle_single_display_spec, decode_mode_spec):
      * src/xselect.c (x_get_local_selection):
      Avoid need to save a machine register when calling unbind_to.
      * src/minibuf.c (Ftry_completion, Fall_completions):
      Omit unnecessary assignment.
      2e281186
  4. 29 Jun, 2018 1 commit
    • Eli Zaretskii's avatar
      Speed up replace-buffer-contents · eec71ebd
      Eli Zaretskii authored
      * src/editfns.c (EXTRA_CONTEXT_FIELDS): Add a_unibyte and
      b_unibyte members.
      (rbc_quitcounter): New static variable.
      (Freplace_buffer_contents): Initialize a_unibyte, b_unibyte, and
      rbc_quitcounter.  Inhibit modification hooks if they were not
      already inhibited.  Use rarely_quit to allow user to quit, to
      avoid calling maybe_quit too frequently (which hurts performance).
      Remove redundant assertions (which hurt performance too much).
      Call signal_after_change and update_compositions after all the
      changes are done.
      (buffer_chars_equal): Remove redundant assertions (which hurt
      performance).  Avoid using BUF_FETCH_CHAR_AS_MULTIBYTE, which
      hurts performance by referencing Lisp symbols; instead, use
      lower-level macros with explicit tests to select which macro to
      use.  (Bug#31888)
      eec71ebd
  5. 28 Jun, 2018 1 commit
    • Paul Eggert's avatar
      Tune SAFE_FREE · 76eda952
      Paul Eggert authored
      On my platform (Fedora 28 x86-64, AMD Phenom II X4 910e) this sped
      up a SAFE_FREE-using microbenchmark (string-distance "abc" "abc")
      by about 18%, and shrank the Emacs text size by about 0.1%.
      * src/callint.c (Fcall_interactively):
      * src/callproc.c (call_process):
      * src/doc.c (get_doc_string, Fsnarf_documentation):
      * src/editfns.c (Freplace_buffer_contents):
      * src/emacs-module.c (funcall_module):
      * src/eval.c (Flet):
      * src/process.c (Fmake_process):
      * src/term.c (tty_menu_show):
      * src/xdisp.c (safe__call):
      * src/xmenu.c (x_menu_show):
      Use SAFE_FREE_UNBIND_TO.
      * src/data.c (wrong_choice): No need to call SAFE_FREE here.
      * src/lisp.h (USE_SAFE_ALLOCA):
      * src/regex.c (REGEX_USE_SAFE_ALLOCA):
      Do not declare sa_must_free local; no longer needed.
      All uses removed.
      (SAFE_FREE): Rewrite in terms of safe_free.
      (safe_free): New function, optimized to use xfree.
      (SAFE_FREE_UNBIND_TO): New macro.
      (safe_free_unbind_to): New function.
      76eda952
  6. 25 Jun, 2018 1 commit
    • Paul Eggert's avatar
      (format "%d" F) now truncates floating F · d0e2a341
      Paul Eggert authored
      Problem reported by Paul Pogonyshev (Bug#31938).
      * src/editfns.c: Include math.h, for trunc.
      (styled_format): For %d, truncate floating-point numbers and
      convert -0 to 0, going back to how Emacs 26 did things.
      * doc/lispref/strings.texi (Formatting Strings):
      Document behavior of %o, %d, %x, %X on floating-point numbers.
      * src/floatfns.c (trunc) [!HAVE_TRUNC]: Rename from emacs_trunc
      and make it an extern function, so that editfns.c can use it.
      All callers changed.
      * test/src/editfns-tests.el (format-%d-float): New test.
      d0e2a341
  7. 23 Jun, 2018 2 commits
  8. 22 Jun, 2018 1 commit
  9. 15 Jun, 2018 2 commits
    • Eli Zaretskii's avatar
      Fix 'replace-buffer-contents' in multibyte buffers · 0d3c3580
      Eli Zaretskii authored
      * src/editfns.c (buffer_chars_equal): Pass a byte position to
      BUF_FETCH_CHAR_AS_MULTIBYTE, not a character position.
      (Bug#31837)
      
      * test/src/editfns-tests.el (replace-buffer-contents-bug31837):
      New test.
      0d3c3580
    • Paul Eggert's avatar
      Avoid allocating Lisp_Save_Value for excursions · aca938d1
      Paul Eggert authored
      * src/editfns.c (save_excursion_save): New arg PDL,
      specifying where to save the state.  All uses changed.
      (save_excursion_restore): Args are now the marker and info
      rather than a pointer to a Lisp_Save_Value containing them.
      All uses changed.
      * src/eval.c (default_toplevel_binding, Fbacktrace__locals):
      Treat excursions like other miscellaneous pdl types.
      (record_unwind_protect_excursion): Save data directly
      into the pdl rather than creating an object on the heap.
      This avoids the need to allocate and free an object.
      (do_one_unbind, backtrace_eval_unrewind):
      Unwind excursions directly.
      (mark_specpdl): Mark excursions directly.
      * src/lisp.h (SPECPDL_UNWIND_EXCURSION): New constant.
      (union specbinding): New member unwind_excursion.
      aca938d1
  10. 08 Jun, 2018 2 commits
    • Paul Eggert's avatar
      Minor cleanup of save_excursion_restore · 0e1bfd38
      Paul Eggert authored
      * src/editfns.c (save_excursion_restore): Use clearer names
      for locals.  Free earlier, removing the need for a label and goto.
      0e1bfd38
    • Paul Eggert's avatar
      New function record_unwind_protect_excursion · a0aa1d4e
      Paul Eggert authored
      This simplifies callers a bit, and will simplify future changes.
      * src/eval.c (record_unwind_protect_excursion): New function.
      * src/buffer.c (Fkill_buffer):
      * src/bytecode.c (exec_byte_code):
      * src/editfns.c (Fsave_excursion, Freplace_buffer_contents):
      * src/lread.c (readevalloop, Feval_buffer):
      * src/window.c (scroll_command):
      Use it.
      a0aa1d4e
  11. 03 Jun, 2018 3 commits
    • Paul Eggert's avatar
      Centralize Bug#30931 fix · 51ee8bc4
      Paul Eggert authored
      * src/marker.c (detach_marker): New function.
      * src/editfns.c (save_restriction_restore):
      * src/insdel.c (signal_before_change): Use it.
      
      (cherry picked from commit 6f66a43d)
      51ee8bc4
    • Noam Postavsky's avatar
      Fix another case of freed markers in the undo-list (Bug#30931) · daa60233
      Noam Postavsky authored
      * src/alloc.c (free_marker): Remove.
      * src/editfns.c (save_restriction_restore):
      * src/insdel.c (signal_before_change): Detach the markers from the
      buffer when we're done with them instead of calling free_marker on
      them.
      * test/src/editfns-tests.el (delete-region-undo-markers-1)
      (delete-region-undo-markers-2): New tests.
      
      (cherry picked from commit 96b8747d)
      daa60233
    • Paul Eggert's avatar
      Fix CHECK_ALLOCATED_AND_LIVE abort during GC · 7460840a
      Paul Eggert authored
      * src/editfns.c (save_restriction_restore):
      Wait for the GC to free the temporary markers (Bug#30931).
      
      (cherry picked from commit 670f2ffa)
      7460840a
  12. 30 Mar, 2018 3 commits
    • Paul Eggert's avatar
      Centralize Bug#30931 fix · 6f66a43d
      Paul Eggert authored
      * src/marker.c (detach_marker): New function.
      * src/editfns.c (save_restriction_restore):
      * src/insdel.c (signal_before_change): Use it.
      6f66a43d
    • Noam Postavsky's avatar
      Fix another case of freed markers in the undo-list (Bug#30931) · 96b8747d
      Noam Postavsky authored
      * src/alloc.c (free_marker): Remove.
      * src/editfns.c (save_restriction_restore):
      * src/insdel.c (signal_before_change): Detach the markers from the
      buffer when we're done with them instead of calling free_marker on
      them.
      * test/src/editfns-tests.el (delete-region-undo-markers-1)
      (delete-region-undo-markers-2): New tests.
      96b8747d
    • Paul Eggert's avatar
      Fix CHECK_ALLOCATED_AND_LIVE abort during GC · 670f2ffa
      Paul Eggert authored
      * src/editfns.c (save_restriction_restore):
      Wait for the GC to free the temporary markers (Bug#30931).
      670f2ffa
  13. 19 Mar, 2018 3 commits
    • Paul Eggert's avatar
      Improve port to NetBSD tzalloc · 6d12e7af
      Paul Eggert authored
      Problem reported by Valery Ushakov (Bug#30738#22).
      * src/editfns.c (HAVE_TZALLOC_BUG): New macro.
      (tzlookup): Use it.  Compile on all platforms, not just on NetBSD.
      6d12e7af
    • Paul Eggert's avatar
      Tune time zone 0 · 7a7ee53d
      Paul Eggert authored
      * src/editfns.c (tzlookup): Treat time zone 0 like t, for speed.
      Suggested by Valery Ushakov (Bug#30738#19).
      7a7ee53d
    • Karl Fogel's avatar
      Revert move of interactive `transpose-regions' to Lisp · 6d2e8fdd
      Karl Fogel authored
      This reverts my commit 3a3aa0e0 of 2018-03-18 at 21:43:18 UTC.
      I thought consensus had been reached, but it had not: Eli Zaretskii
      felt the pre-3a3aa0e0 situation was fine and would not like to
      see it changed without at least further discussion.
      6d2e8fdd
  14. 18 Mar, 2018 1 commit
    • Karl Fogel's avatar
      Move interactive `transpose-regions' to Lisp · 3a3aa0e0
      Karl Fogel authored
      Define `transpose-regions' in Lisp, because its complex interactive
      spec was ungainly in C, and change the C version to non-interactive
      `transpose-regions-internal'.  The Lisp function is just a wrapper
      around the C function, which still does all the work.
      
      * lisp/simple.el (transpose-regions): New wrapper function, with
        interactive spec taken from old C `transpose-regions'.
      
      * src/editfns.c (Ftranspose_regions): Rename to...
        (Ftranspose_regions_internal): ...here, and remove interactive spec.
      
      Discussion on Emacs Devel:
      
        From: Karl Fogel
        To: Emacs Development
        Cc: Richard Copley, Charles A. Roelli
        Subject: Re: [Emacs-diffs] master b88e7c8b: \
                 Make transpose-regions interactive (Bug#30343)
        Date: Fri, 16 Mar 2018 10:23:31 -0500
        Message-ID: <87po44jb7w.fsf@red-bean.com>
      
        https://lists.gnu.org/archive/html/emacs-devel/2018-03/msg00555.html
      3a3aa0e0
  15. 15 Mar, 2018 1 commit
    • Paul Eggert's avatar
      Improve port to NetBSD tzalloc · 64a1da49
      Paul Eggert authored
      Problem reported by Valery Ushakov (Bug#30738#13).
      * src/editfns.c (tzlookup) [__NetBSD_Version__ < 700000000]:
      If tzalloc fails for any reason other than memory exhaustion,
      assume it’s because NetBSD 6 does not support tzalloc on
      POSIX-format TZ strings, and fall back on tzdb if possible.
      64a1da49
  16. 11 Mar, 2018 2 commits
    • Charles A. Roelli's avatar
      Make transpose-regions interactive (Bug#30343) · b88e7c8b
      Charles A. Roelli authored
      * doc/emacs/fixit.texi (Transpose): Mention and explain the new
      command.
      * editfns.c (Ftranspose_regions): Add an interactive calling
      specification, and add documentation for it.
      b88e7c8b
    • Paul Eggert's avatar
      Port to NetBSD tzalloc · d48f4c3b
      Paul Eggert authored
      Problem reported by Valery Ushakov (Bug#30738).
      * src/editfns.c (xtzalloc): Remove.
      (invalid_time_zone_specification): New function.
      (tzlookup): Port to NetBSD, where tzalloc can fail when the TZ
      string has an invalid value.
      d48f4c3b
  17. 09 Mar, 2018 1 commit
    • Paul Eggert's avatar
      Avoid losing info when formatting integers · 80e145fc
      Paul Eggert authored
      * doc/lispref/numbers.texi (Integer Basics): Clarify that
      out-of-range integers are treated as floating point only when the
      integers are decimal.
      * etc/NEWS: Mention changes.
      * src/editfns.c (styled_format): Use %.0f when formatting %d or %i
      values outside machine integer range, to avoid losing info.
      Signal an error for %o or %x values that are too large to be
      formatted, to avoid losing info.
      80e145fc
  18. 06 Jan, 2018 2 commits
  19. 01 Jan, 2018 1 commit
  20. 12 Dec, 2017 1 commit
    • Paul Eggert's avatar
      Narrow pointer bounds when appropriate · 4295050e
      Paul Eggert authored
      This typically occurs in a storage manager, where the caller
      is expected to access only the newly-allocated object,
      instead of using the returned value to access unrelated
      parts of the heap.
      * src/alloc.c (allocate_string, allocate_string_data)
      (compact_small_strings, find_string_data_in_pure)
      (sweep_strings, setup_on_free_list, allocate_vectorlike
      (pure_alloc):
      * src/bytecode.c (exec_byte_code):
      * src/callint.c (Fcall_interactively):
      * src/dispnew.c (scrolling):
      * src/editfns.c (styled_format):
      * src/frame.c (xrdb_get_resource, x_get_resource_string):
      * src/fringe.c (Fdefine_fringe_bitmap):
      * src/gmalloc.c (malloc, realloc, aligned_alloc):
      Narrow pointer bounds when appropriate.
      * src/alloc.c (SDATA_OF_STRING):
      * src/lisp.h (make_lisp_symbol) [__CHKP__]:
      Widen bounds here, though.
      * src/bytecode.c, src/callint.c, src/dispnew.c, src/editfns.c:
      * src/emacs.c, src/frame.c, src/fringe.c:
      Include ptr-bounds.h.
      * src/ptr-bounds.h (ptr_bounds_clip): New function.
      4295050e
  21. 08 Dec, 2017 2 commits
  22. 03 Dec, 2017 1 commit
    • Paul Eggert's avatar
      Fix bug in i18n/l10n optimization · 04e5b28f
      Paul Eggert authored
      This fixes a off-by-one buffer overrun bug introduced in
      2017-06-04T15:39:37Z!eggert@cs.ucla.edu.  Problem uncovered by an
      experimental version of Emacs built with -fcheck-pointer-bounds
      and running on Intel MPX hardware.
      * src/editfns.c (styled_format): Avoid overrunning internal buffers.
      04e5b28f
  23. 22 Nov, 2017 1 commit
  24. 04 Nov, 2017 1 commit
    • Eli Zaretskii's avatar
      Allow 'make-string' callers force creation of multibyte strings · bd886c6f
      Eli Zaretskii authored
      * src/alloc.c (Fmake_string): Accept additional argument
      MULTIBYTE, and produce a multibyte string if it is non-nil.
      (make_event_array):
      * src/lread.c (read0):
      * src/editfns.c (Ftranslate_region_internal):
      * src/coding.c (Fdefine_coding_system_internal):
      * src/cmds.c (internal_self_insert):
      * src/xdisp.c (build_desired_tool_bar_string)
      (store_mode_line_string): All C callers changed.
      
      * doc/lispref/strings.texi (Creating Strings): Document the new
      optional argument.
      
      * etc/NEWS: Mention the new optional argument.
      
      * lisp/ruler-mode.el (ruler-mode-ruler): Call make-string with the
      3rd argument non-nil.
      bd886c6f
  25. 28 Oct, 2017 1 commit
    • Glenn Morris's avatar
      Fix some doc typos · e6b4e5ff
      Glenn Morris authored
      * lisp/calendar/todo-mode.el (todo-next-item)
      (todo-previous-item, todo-toggle-item-header):
      * lisp/window.el (move-to-window-group-line):
      * src/editfns.c (Fformat):
      * test/lisp/calendar/todo-mode-tests.el (todo-test-move-item05):
      Fix doc typos.
      
      ; And in some comments.
      e6b4e5ff
  26. 18 Oct, 2017 1 commit
    • Paul Eggert's avatar
      Improve format-time-string doc · 8ca6fa58
      Paul Eggert authored
      * doc/lispref/os.texi (Time Parsing): Fix some errors in the
      documentation for format-time-string.  Document ^, #, %s, and %z
      with colons.  Say that unrecognized sequences are output as-is.
      * src/editfns.c (Fformat_time_string): %S can stand for 60.
      Also mention unrecognized sequences.
      8ca6fa58