summaryrefslogtreecommitdiff
path: root/src/editfns.c
Commit message (Collapse)AuthorAgeFilesLines
* Update copyright year to 2021Paul Eggert2021-01-011-1/+1
| | | | Run "TZ=UTC0 admin/update-copyright".
* Make goto-char offer the number at point as defaultDaniel Martín2020-12-141-2/+7
| | | | | | | | | | | | * lisp/subr.el (read-natnum-interactive): New function to read natural numbers for interactive functions. * src/editfns.c (Fgoto_char): Call read-natnum-interactive from the interactive definition of goto-char to offer the number at point as default. Also expand the docstring to document this new interactive behavior. * doc/emacs/basic.texi (Moving Point): Expand the Emacs manual to document this new behavior. * etc/NEWS: And announce it (bug#45199).
* Simplify getting value of text-quoting-style (Bug#44471)Stefan Kangas2020-11-091-3/+3
| | | | | | | | | | | * src/doc.c (text_quoting_style): Remove function by merging it... (Ftext_quoting_style): ...here. Rename from Fget_quoting_style. (syms_of_doc): Update defsubr for Ftext_quoting_style. * src/lisp.h (enum text_quoting_style): Remove enum. * src/doprnt.c (doprnt): * src/editfns.c (styled_format): * lisp/help.el (substitute-command-keys): Update callers to use text-quoting-style.
* Don't leave lock files after 'replace-buffer-contents'Eli Zaretskii2020-11-071-0/+7
| | | | | * src/editfns.c (Freplace_buffer_contents): Unlock the buffer's file if no changes have been made. (Bug#44303)
* Use the full name of the null byte/character, not its abbreviationAndreas Schwab2020-10-051-1/+1
| | | | | | | | | | | | | | | | | | | | | * lisp/subr.el (inhibit-nul-byte-detection): Make it an obsolete alias. * src/coding.c (setup_coding_system): Use original name. (detect_coding): Rename nul_byte_found => null_byte_found. (detect_coding_system): Use original name. Rename nul_byte_found => null_byte_found. (Fdefine_coding_system_internal): Use original name. (syms_of_coding): Rename inhibit-nul-byte-detection to inhibit-null-byte-detection. * src/w16select.c (get_clipboard_data): Rename nul_char to null_char. * src/json.c (check_string_without_embedded_nulls): Rename from check_string_without_embedded_nuls. (Fjson_parse_string): Adjust accordingly. * src/coding.h (enum define_coding_undecided_arg_index) (enum coding_attr_index): Rename ...nul_byte... to ...null_byte.... * lisp/info.el (info-insert-file-contents, Info-insert-dir): * lisp/international/mule.el (define-coding-system): * lisp/vc/vc-git.el (vc-git--call): * doc/lispref/nonascii.texi (Lisp and Coding Systems): Use original name.
* replace-buffer-contents cleanupsPaul Eggert2020-08-241-44/+46
| | | | | | | | | * src/editfns.c (NOTE_DELETE, NOTE_INSERT): Avoid unnecessary parens. (Freplace_buffer_contents): Check args before returning results. Avoid integer overflow when computing too_expensive, and work even if MAX-COSTS is bignum. Call alloca and/or malloc just once, not three times. (set_bit, bit_is_set): Simplify micro-optimization by using eassume.
* Fix replace-region-contents performance bugPaul Eggert2020-08-241-16/+15
| | | | | | | | | | | | * src/editfns.c (rbc_quitcounter): Remove; the quitcounter is now part of the context. (EXTRA_CONTEXT_FIELDS): Remove unused member early_abort_tests. Add jmp, quitcounter. (Freplace_buffer_contents): Use setjmp/longjmp to recover from a compareseq that runs too long. Omit unnecessary rarely_quit call. (buffer_chars_equal): Occasionally check for early abort and longjmp out if so (Bug#43016).
* Clarify docs about line movementNoam Postavsky2020-08-211-1/+2
| | | | | | | | | * doc/lispref/positions.texi (Text Lines, Screen Lines): Add index entries. * lisp/simple.el (move-beginning-of-line): Remove incorrect mention of images, and reference beginning-of-visual-line. * src/editfns.c (Fline_beginning_position): Reference `vertical-motion' (bug#35899).
* Drop support for -fcheck-pointer-boundsPaul Eggert2020-08-041-3/+0
| | | | | | | | | | | GCC has removed the -fcheck-pointer bounds option, and the Linux kernel has also removed support for Intel MPX, so there’s no point to keeping this debugging option within Emacs. * src/bytecode.c (BYTE_CODE_THREADED): * src/lisp.h (DEFINE_LISP_SYMBOL, XSYMBOL, make_lisp_symbol): Assume __CHKP__ is not defined. * src/ptr-bounds.h: Remove. All uses of ptr_bounds_clip, ptr_bounds_copy, ptr_bounds_init, ptr_bounds_set removed.
* Merge from origin/emacs-27Glenn Morris2020-05-061-1/+1
|\ | | | | | | | | | | 7be160d800 Improve "Help Summary" section in user manual f6d6ccc984 Clarify message-sendmail-extra-arguments docstring 95fde1a851 * src/editfns.c (Fformat): Small documentation fix.
| * * src/editfns.c (Fformat): Small documentation fix.Philipp Stephani2020-05-051-1/+1
| |
* | Simplify string-to-charPaul Eggert2020-04-261-12/+6
| | | | | | | | | | | | | | | | | | * src/editfns.c (Fstring_to_char): Simplify. * src/editfns.c (Fstring_to_char): Simplify. This tweak improved the CPU time performance of ‘make compile-always’ by about 1.8% on my platform.
* | Pacify gcc -Og x86-64Paul Eggert2020-04-171-1/+1
| | | | | | | | | | * src/editfns.c (Ftranslate_region_internal): Add UNINIT to pacify gcc -Og x86-64 (GCC 9.3.1 20200317 (Red Hat 9.3.1-1)).
* | Prefer more inline functions in character.hPaul Eggert2020-04-171-14/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/buffer.h (fetch_char_advance, fetch_char_advance_no_check) (buf_next_char_len, next_char_len, buf_prev_char_len) (prev_char_len, inc_both, dec_both): New inline functions, replacing the old character.h macros FETCH_CHAR_ADVANCE, FETCH_CHAR_ADVANCE_NO_CHECK, BUF_INC_POS, INC_POS, BUF_DEC_POS, DEC_POS, INC_BOTH, DEC_BOTH respectively. All callers changed. These new functions all assume buffer primitives and so need to be here rather than in character.h. * src/casefiddle.c (make_char_unibyte): New static function, replacing the old MAKE_CHAR_UNIBYTE macro. All callers changed. (do_casify_unibyte_string): Use SINGLE_BYTE_CHAR_P instead of open-coding it. * src/ccl.c (GET_TRANSLATION_TABLE): New static function, replacing the old macro of the same name. * src/character.c (string_char): Omit 2nd arg. 3rd arg can no longer be NULL. All callers changed. * src/character.h (SINGLE_BYTE_CHAR_P): Move up. (MAKE_CHAR_UNIBYTE, MAKE_CHAR_MULTIBYTE, PREV_CHAR_BOUNDARY) (STRING_CHAR_AND_LENGTH, STRING_CHAR_ADVANCE) (FETCH_STRING_CHAR_ADVANCE) (FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE) (FETCH_STRING_CHAR_ADVANCE_NO_CHECK, FETCH_CHAR_ADVANCE) (FETCH_CHAR_ADVANCE_NO_CHECK, INC_POS, DEC_POS, INC_BOTH) (DEC_BOTH, BUF_INC_POS, BUF_DEC_POS): Remove. (make_char_multibyte): New static function, replacing the old macro MAKE_CHAR_MULTIBYTE. All callers changed. (CHAR_STRING_ADVANCE): Remove; all callers changed to use CHAR_STRING. (NEXT_CHAR_BOUNDARY): Remove; it was unused. (raw_prev_char_len): New inline function, replacing the old PREV_CHAR_BOUNDARY macro. All callers changed. (string_char_and_length): New inline function, replacing the old STRING_CHAR_AND_LENGTH macro. All callers changed. (STRING_CHAR): Rewrite in terms of string_char_and_length. (string_char_advance): New inline function, replacing the old STRING_CHAR_ADVANCE macro. All callers changed. (fetch_string_char_advance): New inline function, replacing the old FETCH_STRING_CHAR_ADVANCE macro. All callers changed. (fetch_string_char_as_multibyte_advance): New inline function, replacing the old FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE macro. All callers changed. (fetch_string_char_advance_no_check): New inline function, replacing the old FETCH_STRING_CHAR_ADVANCE_NO_CHECK macro. All callers changed. * src/regex-emacs.c (HEAD_ADDR_VSTRING): Remove; no longer used. * src/syntax.c (scan_lists): Use dec_bytepos instead of open-coding it. * src/xdisp.c (string_char_and_length): Rename from string_char_and_length to avoid name conflict with new function in character.h. All callers changed.
* | Treat out-of-range positions consistentlyPaul Eggert2020-03-271-68/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a position argument to get-byte etc. is an out-of-range integer, treat it the same regardless of whether it is a fixnum or a bignum. * src/buffer.c (fix_position): New function. * src/buffer.c (validate_region): * src/character.c (Fget_byte): * src/coding.c (Ffind_coding_systems_region_internal) (Fcheck_coding_systems_region): * src/composite.c (Ffind_composition_internal): * src/editfns.c (Fposition_bytes, Fchar_after, Fchar_before) (Finsert_buffer_substring, Fcompare_buffer_substrings) (Fnarrow_to_region): * src/fns.c (Fsecure_hash_algorithms): * src/font.c (Finternal_char_font, Ffont_at): * src/fringe.c (Ffringe_bitmaps_at_pos): * src/search.c (search_command): * src/textprop.c (get_char_property_and_overlay): * src/window.c (Fpos_visible_in_window_p): * src/xdisp.c (Fwindow_text_pixel_size): Use it instead of CHECK_FIXNUM_COERCE_MARKER, so that the code is simpler and treats bignums consistently with fixnums. * src/buffer.h (CHECK_FIXNUM_COERCE_MARKER): Define here rather than in lisp.h, and reimplement in terms of fix_position so that it treats bignums consistently with fixnums. * src/lisp.h (CHECK_FIXNUM_COERCE_MARKER): Move to buffer.h. * src/textprop.c (validate_interval_range): Signal with original bounds rather than modified ones.
* | line-beginning-position args can be bignumsPaul Eggert2020-03-251-9/+17
| | | | | | | | | | * src/editfns.c (Fline_beginning_position, Fline_end_position): Do not restrict integer arguments to fixnums.
* | Pacify GCC 9.2.1 20190927 -O3Paul Eggert2020-03-041-8/+11
|/ | | | | | | | | | | | | | | | | | | | | | | | Original problem report by N. Jackson in: https://lists.gnu.org/r/emacs-devel/2020-03/msg00047.html I found some other warnings when I used gcc, and fixed them with this patch. * lib-src/etags.c: Include verify.h. (xnmalloc, xnrealloc): Tell the compiler that NITEMS is nononnegative and ITEM_SIZE is positive. * src/conf_post.h (__has_attribute_returns_nonnull) (ATTRIBUTE_RETURNS_NONNULL): New macros. * src/editfns.c (Fuser_full_name): Don’t assume Fuser_login_name returns non-nil. * src/intervals.c (rotate_right, rotate_left, update_interval): * src/intervals.h (LENGTH, LEFT_TOTAL_LENGTH, RIGHT_TOTAL_LENGTH): Use TOTAL_LENGTH0 or equivalent on intervals that might be null. * src/intervals.h (TOTAL_LENGTH): Assume arg is nonnull. (TOTAL_LENGTH0): New macro, with the old TOTAL_LENGTH meaning. (make_interval, split_interval_right): Add ATTRIBUTE_RETURNS_NONNULL. * src/pdumper.c (dump_check_dump_off): Now returns void, since no caller uses the return value. Redo assert to pacify GCC. (decode_emacs_reloc): Add a seemingly-random eassume to pacify GCC. Ugly, and I suspect due to a bug in GCC.
* ; * src/editfns.c (Fbuffer_size): Tiny clarification.Philipp Stephani2020-02-131-1/+1
|
* Correct "different than" to "different from" where appropriateAlan Mackenzie2020-02-091-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | (doc/emacs/screen.texi) (doc/lispintro/emacs-lisp-intro.texi) (doc/misc/calc.texi) (doc/misc/gnus.texi) (doc/misc/sc.texi) (lisp/align.el) (lisp/allout-widgets.el) (lisp/allout.el) (lisp/emacs-lisp/gv.el) (lisp/font-lock.el) (lisp/gnus/mm-util.el) (lisp/mail/feedmail.el) (lisp/mail/sendmail.el) (lisp/mail/supercite.el) (lisp/org/org-attach.el) (lisp/progmodes/cc-langs.el) (lisp/progmodes/idlw-shell.el) (lisp/ps-print.el) (lisp/simple.el) (src/cmds.c) (src/editfns.c) (src/frame.h) (src/regex-emacs.c) (src/xfaces.c): Replace "different than" by "different from".
* Correct regexp for flags in `format' doc stringMattias Engdegård2020-01-261-1/+1
| | | | | * src/editfns.c (Fformat): Use the correct regexp for describing the flags in a %-sequence (place the hyphen last).
* Update copyright year to 2020Paul Eggert2020-01-011-1/+1
| | | | Run "TZ=UTC0 admin/update-copyright $(git ls-files)".
* Revert aa89c84e00d8dc85100e6fedab7631c415e6364d (bug#38457)Juri Linkov2019-12-161-56/+0
| | | | | | | | | | | | | * src/editfns.c (Fmessage): Don't use minibuffer-message. (Fmessage_in_echo_area): Remove function message-in-echo-area. (syms_of_editfns): Remove variable message-in-echo-area. * lisp/isearch.el (isearch--momentary-message): Remove message-in-echo-area. * lisp/minibuffer.el (minibuffer-message): Don't record message in the *Messages* buffer. (minibuffer-completion-help): Remove message-in-echo-area. * lisp/subr.el (do-after-load-evaluation): Remove discard-input (bug#38560)
* message uses minibuffer-message in the active minibuffer (bug#17272 bug#19064)Juri Linkov2019-11-271-0/+56
| | | | | | | | | | | | | | | | | | | | | | * doc/lispref/display.texi (Displaying Messages): Explain the behavior of using minibuffer-message if the minibuffer is active. * src/editfns.c (Fmessage_in_echo_area): New function with body copied from Fmessage. (Fmessage): Call minibuffer-message in the active minibuffer, otherwise call Fmessage_in_echo_area. (message-in-echo-area): New variable. * lisp/isearch.el (isearch--momentary-message, isearch-message): * lisp/minibuffer.el (minibuffer-message, minibuffer-completion-help): Use 'message-in-echo-area' instead of 'message' where necessary. * lisp/autorevert.el (auto-revert-handler): * lisp/man.el (Man-bgproc-sentinel): * lisp/subr.el (do-after-load-evaluation): Revert recent changes that replaced 'message' with 'minibuffer-message'. This is not needed anymore since 'message' uses 'minibuffer-message' in the active minibuffer.
* Fix byte-counting error in ‘format’Paul Eggert2019-11-141-3/+3
| | | | | | | Problem reported by Paul Pogonyshev (Bug#38191). * src/editfns.c (styled_format): When checking for adjacent %-sequences, use byte position rather than character position. * test/src/editfns-tests.el (format-properties): Test for fix.
* Remove INT_ADD_WRAPV bug workaroundsPaul Eggert2019-08-141-5/+3
| | | | | | | | | * src/alloc.c (free_cons): * src/casefiddle.c (do_casify_multibyte_string): * src/editfns.c (styled_format): * src/image.c (png_load_body): Remove recent workarounds for INT_ADD_WRAPV bugs since the bugs have been fixed (Bug#37006).
* ; Add commentary to recent changesEli Zaretskii2019-08-121-1/+3
| | | | | | | | * src/image.c (png_load_body): * src/editfns.c (styled_format): * src/casefiddle.c (do_casify_multibyte_string): * src/alloc.c (free_cons): Comment why we use a signed temporary integer variable. (Bug#37006)
* Prefer signed when testing for signed overflowPaul Eggert2019-08-111-2/+2
| | | | | | | | | | * src/alloc.c (free_cons): * src/casefiddle.c (do_casify_multibyte_string): * src/editfns.c (styled_format): * src/image.c (png_load_body): Use signed arguments to INT_MULTIPLY_WRAPV etc. This doesn’t fix any bugs, but GCC emits better code when all args are signed. Also, this removes the need for an if in free_cons (Bug#37006).
* Support "%x" etc. formats on more floatsPaul Eggert2019-07-231-5/+12
| | | | | | | | | | | | | | * doc/lispref/strings.texi (Formatting Strings): Document this. * src/editfns.c (styled_format): Support %o, %x, and %X on finite floats less than zero or greater than UINTMAX_MAX. * test/src/editfns-tests.el (format-%x-large-float) (read-large-integer, format-%o-negative-float): Adjust tests to match extended behavior. Rename the latter test from format-%o-invalid-float, since the float is no longer invalid. * test/src/editfns-tests.el (format-%x-large-float) (read-large-integer): Test this.
* Fix typo in previous patchPaul Eggert2019-07-071-1/+1
| | | | * src/editfns.c (styled_format): Fix stray ‘pMd’.
* Remove printmax_t etc.Paul Eggert2019-07-071-7/+7
| | | | | | | | | | | | printmax_t etc. were needed only for platforms that lacked support for printing intmax_t. These platforms are now so obsolete that they are no longer practical porting targets. * src/image.c (gs_load): Fix unlikely buffer overrun discovered while making these changes. It was introduced in 2011-07-17T00:34:43!eggert@cs.ucla.edu. * src/lisp.h (printmax_t, uprintmax_t, pMd, pMu, pMx): Remove. All uses replaced by their standard counterparts intmax_t, uintmax_t, PRIdMAX, PRIuMAX, PRIxMAX.
* * src/editfns.c (Fngettext): Fix typos in docstring.Juanma Barranquero2019-06-101-3/+3
|
* Merge from origin/emacs-26Glenn Morris2019-04-101-2/+3
|\ | | | | | | | | | | | | | | | | | | | | | | | | a5da653 * src/editfns.c (Fnarrow_to_region): Doc fix. (Bug#35163) 646d33d Fix doc strings of 'vc-version-diff' and 'vc-version-ediff' a30a6c3 Improve documentation of set-window-start 92ce2dd Improve documentation of window parameters 6dc42c5 Improve commentary in frame.el a8cffcf Fix typo in a doc string 9e79f19 (emacs-26) ; * src/fontset.c (set-fontset-font): Use uppercas... # Conflicts: # lisp/vc/vc.el
| * * src/editfns.c (Fnarrow_to_region): Doc fix. (Bug#35163)Eli Zaretskii2019-04-081-2/+3
| |
* | Port recent ngettext stub to non-glibcPaul Eggert2019-03-251-25/+9
| | | | | | | | | | | | | | * src/editfns.c: Don’t try to call glibc ngettext; we’re not ready for that yet. (Fngettext): Do not restrict integer arguments to fixnums. Improve doc string a bit.
* | * lisp/international/mule-cmds.el (ngettext): Move to editfns.c.Juri Linkov2019-03-251-0/+37
| | | | | | | | | | * src/editfns.c (Fngettext): Move from mule-cmds.el and use gettext's ngettext when available.
* | Fix misuses of NULL when talking about the NUL characterStefan Monnier2019-03-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/subr.el (inhibit-null-byte-detection): Make it an obsolete alias. * src/coding.c (setup_coding_system): Use new name. (detect_coding): Rename null_byte_found => nul_byte_found. (detect_coding_system): Use new name. Rename null_byte_found => nul_byte_found. (Fdefine_coding_system_internal): Use new name. (syms_of_coding): Rename inhibit-null-byte-detection to inhibit-nul-byte-detection. * src/w16select.c (get_clipboard_data): null_char => nul_char. * src/json.c (check_string_without_embedded_nuls): Rename from check_string_without_embedded_nulls. (Fjson_parse_string): Adjust accordingly. * src/coding.h (enum define_coding_undecided_arg_index) (enum coding_attr_index): ...null_byte... => ...nul_byte.... * lisp/info.el (info-insert-file-contents, Info-insert-dir): * lisp/international/mule.el (define-coding-system): * lisp/vc/vc-git.el (vc-git--call): * doc/lispref/nonascii.texi (Lisp and Coding Systems): Use the new name.
* | * src/editfns.c: Fix docstring typo.Paul Eggert2019-03-101-1/+1
| |
* | Improve binary-as-unsigned treatment (Bug#34792)Paul Eggert2019-03-101-9/+5
| | | | | | | | | | | | | | | | | | | | * etc/NEWS: * src/editfns.c (Fformat, binary_as_unsigned): Update now that we always have bignums. (syms_of_editfns) [!defined lisp_h_FIXNUMP]: Remove now-obsolete code, since lisp_h_FIXNUMP is always defined now. * test/src/editfns-tests.el (read-large-integer): Simplify, now that we can assume binary-as-unsigned defaults to nil.
* | ; * src/editfns.c (Fformat): Fix last change. (Bug#34792)Eli Zaretskii2019-03-091-4/+4
| |
* | Mention `binary-as-unsigned' in `format' docstring (Bug#34792)Ivan Andrus2019-03-091-2/+4
| | | | | | | | | | * src/src/editfns.c (format): Update docstring to mention binary-as-unsigned (Bug#34792)
* | ; Delete unused variable replace-buffer-contents-max-secsTassilo Horn2019-02-251-6/+0
| | | | | | | | | | | | This variable is a leftover of my now deleted scratch/replace-region-contents branch and has never been used in master.
* | Don’t assume timersub and gettimeofdayPaul Eggert2019-02-231-11/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | POSIX does not specify timersub, and marks gettimeofday as obsolescent. Avoid porting problems by using timespec.h functions instead. * src/editfns.c: Include systime.h instead of sys/time.h. (EXTRA_CONTEXT_FIELDS): Replace start and max_secs with time_limit. All uses changed. This removes the need to call gettimeofday or timersub. * src/term.c (timeval_to_Time): Remove. Replace all uses with ... (current_Time): ... this new function, removing the need to call gettimeofday.
* | Improve replace-buffer-contents/replace-region-contentsTassilo Horn2019-02-231-20/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/editfns.c (Freplace_buffer_contents): Add two optional arguments for mitigating performance issues. * lisp/emacs-lisp/subr-x.el (replace-region-contents): Move from subr.el. Add the same two arguments as for replace-buffer-contents. * lisp/json.el (json-pretty-print-max-secs): New variable holding the default MAX-SECS value json-pretty-print passes to replace-buffer-contents. (json-pretty-print): Use it. * doc/lispref/text.texi (Replacing): Add documentation for replace-buffer-contents two new optional arguments. Document replace-region-contents.
* | Add new function replace-buffer-contentsTassilo Horn2019-02-081-1/+9
| | | | | | | | | | | | | | * src/editfns.c (Freplace_buffer_contents): Use lower value of too_expensive and enable heuristic. * lisp/subr.el (replace-region-contents): New convenient wrapper function around replace-buffer-contents.
* | Fix unlikely user-full-name integer overflowPaul Eggert2019-02-021-1/+1
| | | | | | | | | | * src/editfns.c (Fuser_full_name): Don’t assume uid fits into fixnum.
* | Widen modiff counts to avoid wraparoundPaul Eggert2019-01-311-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Widen modification counts to at least 64 bits, to make wraparound practically impossible. * doc/lispref/buffers.texi (Buffer Modification): Don’t say the modification-count can wrap around. * src/buffer.c (Frestore_buffer_modified_p, Fbuffer_swap_text) (modify_overlay): * src/insdel.c (insert_1_both, insert_from_string_1) (insert_from_gap, insert_from_buffer_1) (adjust_after_replace, replace_range, replace_range_2) (del_range_2, modify_text): * src/textprop.c (modify_text_properties): Use modiff_incr instead of incrementing directly. (Fbuffer_modified_tick, Fbuffer_chars_modified_tick): Don’t assume modification counts fit into fixnums. * src/buffer.h (struct buffer_text, struct buffer): * src/cmds.c (internal_self_insert): * src/fileio.c (Finsert_file_contents): * src/indent.c (last_known_column_modified): * src/keyboard.c (command_loop_1): * src/marker.c (cached_modiff): * src/syntax.c (find_start_modiff, parse_sexp_propertize) (find_defun_start): * src/window.h (struct window): Use modiff_count for modification counts. * src/editfns.c (Fsubst_char_in_region): Copy instead of incrementing modification counts, since integer overflow checking is not needed here. * src/lisp.h (modiff_count): New type. (modiff_incr, modiff_to_integer): New inline functions. * src/pdumper.c (dump_buffer): Update hash.
* | forward-line now works with bignumsPaul Eggert2019-01-271-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | * src/cmds.c (Fforward_line): Support bignum arg. (scan_newline): Return void since no caller was using the return value. * src/search.c (find_newline, scan_newline_from_point) (find_newline1): Return the number of newlines counted, not the count shortage, so that the return value always fits in ptrdiff_t even if the original count was a bignum. All callers changed. * test/src/cmds-tests.el (forward-line-with-bignum): New test.
* | Add portable dumperDaniel Colascione2019-01-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a new portable dumper as an alternative to unexec. Use it by default. * src/dmpstruct.awk: New file. * src/doc.c (get_doc_string): use will_dump_p(). * src/editfns.c (styled_format): silence compiler warning with UNINIT. * src/emacs-module.c (syms_of_module): staticpro ltv_mark. * src/emacs.c (gflags): new variable. (init_cmdargs): unwrap (string_starts_with_p, find_argument, dump_error_to_string) (load_pdump): new functions. (main): detect pdumper and --temacs invocation; actually load portable dump when detected; set gflags as appropriate; changes to init functions throughout to avoid passing explicit 'initialized' argument. * src/eval.c (inhibit_lisp_code): remove unused variable. (init_eval_once_for_pdumper): new function. (init_eval_once): call it. * src/filelock.c: CANNOT_DUMP -> will_dump_p() * src/fingerprint-dummy.c: new file * src/fingerprint.h: new file * src/fns.c: CANNOT_DUMP -> will_dump_p(), etc. (weak_hash_tables): remove (hashfn_equal, hashfn_eql): un-staticify (make_hash_table): set new 'next_weak' hash table field; drop global weak_hash_tables logic. (copy_hash_table): drop global weak_hash_tables logic. (hash_table_rehash): new function. (hash_lookup, hash_put, hash_remove_from_table, hash_clear): rehash if needed. (sweep_weak_table): un-staticify; explain logic; bool-ify. (sweep_weak_hash_tables): remove function. * src/font.c (syms_of_font): remember pdumper stuff. * src/fontset.c (syms_of_fontset): remember pdumper stuff. * src/frame.c (make_initial_frame): don't reset Vframe_list. (init_frame_once_for_pdumper, init_frame_once): new functions. (syms_of_frame): remove redundant staticpro. * src/fringe.c (init_fringe_once_for_pdumper): new functin. (init_fringe_once): call it. * src/ftcrfont.c (syms_of_ftcrfont_for_pdumper): new function. (syms_of_ftcrfont): call it. * src/ftfont.c (syms_of_ftfont_for_pdumper): new function. (syms_of_ftfont): call it. * src/ftxont.c (syms_of_ftxfont_for_pdumper): new function. (syms_of_ftxfont): call it. * src/gmalloc.c: adjust for pdumper througout (DUMPED): remove weird custom dumped indicator. * src/gnutls.c (syms_of_gnutls): pdumper note for gnutls_global_initialized. * src/image.c (syms_of_image): add pdumper comment, initializer note. * src/insdel.c (prepare_to_modify_buffer_1): account for buffer contents possibly being in dump image. * src/keyboard.c (syms_of_keyboard_for_pdumper): new function. (syms_of_keyboard): staticpro more; call pdumper syms function. * src/lisp.h: add comments throughout (gflags): declare. (will_dump_p, will_bootstrap_p, will_dump_with_pdumper_p) (dumped_with_pdumper_p, will_dump_with_unexec_p) (dumped_with_unexec_p, definitely_will_not_unexec_p): new functions. (POWER_OF_2, ROUNDUP): move macros. (PSEUDOVECTOR_TYPE, PSEUDOVECTOR_TYPEP): take vectorlike header pointer instead of vector; constify. (Lisp_Hash_Table): add comment about need to rehash on access; add comment for next_weak. (HASH_KEY, HASH_VALUE, HASH_HASH, HASH_TABLE_SIZE): const-ify. (hash_table_rehash): declare. (hash_rehash_needed_p, hash_rehash_if_needed): new functions. (finalizers, doomed_finalizers): declare extern. (SUBR_SECTION_ATTRIBUTE): new macro. (staticvec, staticidx): un-static-ify. (sweep_weak_hash_tables): remove declaration. (sweep_weak_table): declare. (hashfn_eql, hashfn_equal): declare. (number_finalizers_run): new variable. (Vdead): externify when ENABLE_CHECKING. (gc_root_type): new enumeration. (gc_root_visitor): new struct. (visit_static_gc_roots): declare. (vectorlike_nbytes): declare. (vector_nbytes): define as trivial inline function wrapper for vectorlike_nbytes. (init_obarray_once): change signature. (primary_thread): extern-ify. (init_buffer): change signature. (init_frame_once): declare. * src/lread.c (readevalloop): adjust for new dumped predicates. (init_obarray_once): new function. (ndefsubr): new variable. (defsubr): increment it. (load_path_check): adjust for pdumper. (load_path_default): use pdumper functions; adjust for dump search. * src/macfont.m (macfont_init_font_change_handler): avoid shadowing global. (syms_of_macfont_for_pdumper): new function. (syms_of_macfont): call it. * src/menu.c (syms_of_menu): staticpro more stuff. * src/minibuf.c (Ftry_completion): rehash if needed. (init_minibuf_once_for_pdumper): new function. (init_minibuf_once): call it. * src/nsfont.m (syms_of_nsfns): staticpro more. * src/nsfont.m (syms_of_nsfont_for_pdumper): new function. (syms_of_nsfont): call it. * src/nsterm.m (syms_of_nsfont): remember pdumper stuff. * src/pdumper.c: new file. * src/pdumper.h: new file. * src/process.c (init_process_emacs): use new pdumper functions instead of CANNOT_DUMP. * src/profiler.c (syms_of_profiler_for_pdumper): new function. (syms_of_profiler_for_pdumper): call it. * src/search.c (syms_of_search_for_pdumper): new function. (syms_of_search_for_pdumper): call it. * src/sheap.c (bss_sbrk_did_unexec): remove. * src/sheap.h (bss_sbrk_did_unexec): remove. * src/syntax.c (syms_of_syntax): don't redundantly staticpro re_match_object. * src/sysdep.c: use will_dump_with_unexec_p() instead of bss hack thing. * src/syssignals.h (init_sigsegv): declare. * src/systime.h (init_timefns): remove bool from signature. * src/textprop.c (syms_of_textprop): move staticpro. * src/thread.c (main_thread_p): constify. * src/thread.h (main_thread_p): constify. * src/timefns.c (init_timefns): remove bool from signature. (syms_of_timefns_for_pdumper): new function. (syms_of_timefns): call it. * src/w32.c: rearrange code. * src/w32.h (w32_relocate): declare. * src/w32fns.c (syms_of_w32fns): add pdumper note. * src/w32font.c (syms_of_w32font_for_pdumper): new function. (syms_of_w32font): call it. * src/w32heap.c (using_dynamic_heap): new variable. (init_heap): use it. * src/w32menu.c (syms_of_w32menu): add pdumper note. * src/w32proc.c (ctrl_c_handler, mainCRTStartup, _start, open_input_file) (rva_to_section, close_file_data): move here. * src/w32uniscribe.c (syms_of_w32uniscribe_for_pdumper): new function. (syms_of_w32uniscribe): call it. * src/window.c (init_window_once_for_pdumper): new function. (init_window_once): call it; staticpro more stuff. * src/xfont.c (syms_of_xfont_for_pdumper): new function. (syms_of_xfont): call it. * src/xftfont.c (syms_of_xftfont_for_pdumper): new function. (syms_of_xftfont): call it. * src/xmenu.c (syms_of_xmenu_for_pdumper): new function. (syms_of_xmenu): call it. * src/xselect.c (syms_of_xselect_for_pdumper): new function. (syms_of_xselect): call it. * src/xsettings.c (syms_of_xsettings): add more pdumper notes. * src/term.c (syms_of_xterm): add pdumper note. * src/dispnew.c (init_faces_initial): new function. (init_display_interactive): rename from init_display; use will_dump_p instead of !initialized. Initialize faces early for pdumper if needed. (init_display): new function. (syms_of_display_for_pdumper): new function. (syms_of_display): call it. * src/dbusbind.c (syms_of_dbusbind): Add TODO for bus reset on pdumper load. * src/data.c (Fdefalias): Use will_dump_p instead of Vpurify_flag. (Fmake_variable_buffer_local): silence compiler warning with -Og by making valcontents UNINIT. (arith_driver): silence compiler warning with UNINIT. * src/conf_post.h (ATTRIBUTE_SECTION): new macro. * src/composite.c (composition_gstring_put_cache): rehash hash table if needed. * src/coding.c (init_coding_once, syms_of_coding): remember pdumper stuff. * src/charset.h (charset_table_size, charset_table_user): declare. * src/charset.c (charset_table_used, charset_table_size): un-static. (init_charset_oncem, syms_of_charset): remember pdumper stuff. * src/category.c (category_table_version): remove obsolete variable. * src/callint.c (syms_of_callint): staticpro 'preserved_fns' (init_callproc): use will_dump_p instead of !CANNOT_DUMP. * src/bytecode.c (exec_byte_code): rehash table tables if needed * src/buffer.c (alloc_buffer_text, free_buffer_text): account for pdumper (init_buffer_once): add TODO; remember stuff for pdumper. (init_buffer): don't take initialized argument; adjust for pdumper. * src/atimer.c (init_atimer): initialize subr only if !initialized. * src/alloc.c: (vector_marked_p, set_vector_marked) (vectorlike_marked_p, set_vectorlike_marked, cons_marked_p) (set_cons_marked, string_marked_p, set_string_marked) (symbol_marked_p, set_symbol_marked, interval_marked_p) (set_interval_marked): new accessor routines. Use them instead of raw GC access throughout. (Vdead): make non-static when ENABLE_CHECKING. (vectorlike_nbytes): rename of 'vector_nbytes'; take a vectorlike header as input instead of a vector. (number_finalizers_run): new internal C variable. (mark_maybe_object): check for pdumper objects. (valid_pointer_p): don't be gratuitously inefficient under rr(1). (make_pure_c_string): add support for size_byte = -2 mode indicating that string data points into Emacs image rodata. (visit_vectorlike_root): visits GC roots embedded in vectorlike objects. (visit_buffer_root): visits GC roots embedded in our totally-not-a-buffer buffer global objects. (visit_static_gc_roots): visit GC roots in the Emacs data section. (mark_object_root_visitor): root callback used for conventional GC marking (weak_hash_tables): new internal variable for tracking found weak hash tables during GC. (mark_and_sweep_weak_table_contents): new weak hash table marking. (garbage_collect_1): use new GC root visitor machinery. (mark_vectorlike): accept a vectorlike_header instead of a Lisp_Vector. (mark_frame, mark_window, mark_hash_table): new functions. (mark_object): initialize 'm'; check for pdumper objects and use new mark-bit accessors throughout. Remove some object-specific marking code and move to helper functions above. (survives_gc_p): check for pdumper objects. (gc-sweep): clear pdumper mark bits. (init_alloc_once_for_pdumper): new helper function for early init called both during normal init and pdumper load. (init_alloc_once): pdumper integration. * src/Makefile.in: Rewrite dumping for pdumper; add pdumper.o; invoke temacs with --temacs command line option; build dmpstruct.h from dmpstruct.awk; stop relying on CANNOT_DUMP; clean up pdumper intermediate files during build. * nextstep/Makefile.in: build emacs.pdmp into NS packages * lisp/startup.el: account for new '--temacs' and '--dump-file' command line option. * lisp/loadup.el: rewrite early init to account for pdumper; use injected 'dump-mode' variable (set via the new '--temacs' option) instead of parsing command line. * lisp/cus-start.el: Check 'dump-mode' instead of 'purify-flag', since the new 'dump-mode' * lib-src/make-fingerprint.c: new program * lib-src/Makefile.in: built make-fingerprint utility program * configure.ac: Add --with-pdumper toggle to control pdumper support; add --with-unexec toggle to control unexec support. Add --with-dumping option to control which dumping strategy we use by default. Adjust for pdumper throughout. Check for posix_madvise. * Makefile.in: Add @DUMPING@ substitution; add pdumper mode. * .gitignore: Add make-fingerprint, temacs.in, fingerprint.c, dmpstruct.h, and pdumper dump files.
* | Fix translation-region bug with MAX_CHARPaul Eggert2019-01-131-47/+35
| | | | | | | | | | | | | | | | | | | | | | | | Also, clean up the code a bit. Actually I discovered the bug while cleaning up the code. * src/editfns.c (Fsubst_char_in_region) (Ftranslate_region_internal): Use bool for booleans. (Ftranslate_region_internal): Fix off-by-1 bug when a translation table translates the maximum char. Assume C99 decl-after-statement, similar minor cleanups. * test/src/editfns-tests.el (test-translate-region-internal): New test.
* | Minor overflow fix in translate-region-internalPaul Eggert2019-01-131-1/+1
| | | | | | | | | | * src/editfns.c (Ftranslate_region_internal): Use ptrdiff_t, not int, for a count that might exceed INT_MAX.