summaryrefslogtreecommitdiff
path: root/src/coding.c
Commit message (Collapse)AuthorAgeFilesLines
* ; Add 2022 to copyright years.Eli Zaretskii2022-01-011-1/+1
|
* * src/coding.c (Fdecode_coding_region, Fencode_coding_region): Doc fix.Eli Zaretskii2021-11-281-3/+6
|
* Improve documentation of 'decode-coding-region'Eli Zaretskii2021-11-121-4/+5
| | | | | | | | * src/coding.c (Fdecode_coding_region): Doc fix. * doc/lispref/nonascii.texi (Coding System Basics) (Explicit Encoding): Explain the significance of using 'undecided' in 'decode-coding-*' functions.
* Check for null bytes in filenames in 'expand-file-name' (bug#49723)Federico Tedin2021-09-181-2/+1
| | | | | | | | | | | | * src/fileio.c (expand-file-name): Check for null bytes for both NAME and DEFAULT-DIRECTORY arguments. Also check for null bytes in buffer-local default-directory, assuming it is used. * src/coding.c (encode_file_name): Use CHECK_STRING_NULL_BYTES. * src/lisp.h (CHECK_STRING_NULL_BYTES): Add function for checking for null bytes in Lisp strings. * test/src/fileio-tests.el (fileio-test--expand-file-name-null-bytes): Add test for new changes to expand-file-name. * etc/NEWS: Announce changes.
* Fix TTY display performance degradation due to many markersEli Zaretskii2021-08-171-4/+40
| | | | | | | * src/coding.c (encode_coding_object): Don't assume that src_object == dst_object means src_object is the current buffer. Add the missing commentary that explains the arguments. (Bug#49127)
* Fix Fdirectory_append check for whether strings have to be convertedLars Ingebrigtsen2021-07-241-1/+1
| | | | | | | | | | | * src/coding.c (string_ascii_p): Make it non-static. * src/fileio.c (Fdirectory_append): Fix check for whether we need to convert to multibyte. * src/fns.c (string_ascii_p): Remove copy. * src/lisp.h: Declare string_ascii_p.
* Fix encoding by ISO-2022-JPKenichi Handa2021-03-271-0/+6
| | | | | * src/coding.c (encode_coding): Reset the CODING_MODE_LAST_BLOCK flag for all iterations but the last one. (Bug#46933)
* Update copyright year to 2021Paul Eggert2021-01-011-1/+1
| | | | Run "TZ=UTC0 admin/update-copyright".
* Reject filenames containing NUL bytes.Philipp Stephani2020-12-231-2/+16
| | | | | | | | | | | | | | | Such filenames are dangerous, as Emacs would silently only use the part up to the first NUL byte. Reject them explicitly instead. * src/coding.c (encode_file_name_1): New helper function. (encode_file_name): Check that encoded filename doesn't contain a NUL byte. (syms_of_coding): Define 'filenamep' symbol. * test/src/fileio-tests.el (fileio-tests/null-character): New unit test. * etc/NEWS: Document change.
* Inhibit buffer hooks in temporary buffersBasil L. Contovounesios2020-12-201-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Give get-buffer-create an optional argument to inhibit buffer hooks in internal or temporary buffers for efficiency (bug#34765). * etc/NEWS: Announce new parameter of get-buffer-create and generate-new-buffer, and that with-temp-buffer and with-temp-file now inhibit buffer hooks. * doc/lispref/buffers.texi (Buffer Names): Fix typo. (Creating Buffers): Document new parameter of get-buffer-create and generate-new-buffer. (Buffer List, Killing Buffers): Document when buffer hooks are inhibited. (Current Buffer): * doc/lispref/files.texi (Writing to Files): Document that with-temp-buffer and with-temp-file inhibit buffer hooks. * doc/lispref/internals.texi (Buffer Internals): Document inhibit_buffer_hooks flag. Remove stale comment. * doc/misc/gnus-faq.texi (FAQ 5-8): * lisp/simple.el (shell-command-on-region): Fix indentation. * lisp/files.el (kill-buffer-hook): Document when hook is inhibited. (create-file-buffer): * lisp/gnus/gnus-uu.el (gnus-uu-unshar-article): * lisp/international/mule.el (load-with-code-conversion): * lisp/mh-e/mh-xface.el (mh-x-image-url-fetch-image): * lisp/net/imap.el (imap-open): * lisp/net/mailcap.el (mailcap-maybe-eval): * lisp/progmodes/flymake-proc.el (flymake-proc--read-file-to-temp-buffer) (flymake-proc--copy-buffer-to-temp-buffer): Simplify. * lisp/subr.el (generate-new-buffer): Forward new optional argument to inhibit buffer hooks to get-buffer-create. (with-temp-file, with-temp-buffer, with-output-to-string): * lisp/json.el (json-encode-string): Inhibit buffer hooks in buffer used. * src/buffer.c (run_buffer_list_update_hook): New helper function. (Fget_buffer_create): Use it. Add optional argument to set inhibit_buffer_hooks flag instead of comparing the buffer name to Vcode_conversion_workbuf_name. All callers changed. (Fmake_indirect_buffer, Frename_buffer, Fbury_buffer_internal) (record_buffer): Use run_buffer_list_update_hook. (Fkill_buffer): Document when buffer hooks are inhibited. Use run_buffer_list_update_hook. (init_buffer_once): Inhibit buffer hooks in Vprin1_to_string_buffer. (Vkill_buffer_query_functions, Vbuffer_list_update_hook): Document when hooks are inhibited. * src/buffer.h (struct buffer): Update inhibit_buffer_hooks commentary. * src/coding.h (Vcode_conversion_workbuf_name): * src/coding.c (Vcode_conversion_workbuf_name): Make static again since it is no longer needed in src/buffer.c. (code_conversion_restore, code_conversion_save, syms_of_coding): Prefer boolean over integer constants. * src/fileio.c (Finsert_file_contents): Inhibit buffer hooks in " *code-converting-work*" buffer. * src/window.c (Fselect_window): Fix grammar. Mention window-selection-change-functions alongside buffer-list-update-hook. * test/src/buffer-tests.el: Fix requires. (buffer-tests-inhibit-buffer-hooks): New test.
* Use the full name of the null byte/character, not its abbreviationAndreas Schwab2020-10-051-30/+30
| | | | | | | | | | | | | | | | | | | | | * 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.
* Improve handling of coding-system mnemonic indicatorsEli Zaretskii2020-08-231-2/+8
| | | | | | | | | | | | | | This fixes assertion violations when the mnemonic is given as a string, and allows non-ASCII characters be used as mode-line mnemonic of a coding-system. * src/xdisp.c (decode_mode_spec_coding): Handle multibyte characters as coding-system's mnemonic. (display_mode_element): If decode_mode_spec returns a multibyte string, display it as multibyte. * src/coding.c (Fdefine_coding_system_internal) (Fcoding_system_put): If :mnemonic is a string, use its first character. This avoids assertion violations if someone uses a string as the mnemonic of a coding-system.
* Fix GC bugs related to uninitialized vectorsPaul Eggert2020-08-151-6/+3
| | | | | | | | | | | | | | | | | | | | | | Avoid problems if GC occurs while initializing a vector. Problem with Fdelete reported by Pip Cet in: https://lists.gnu.org/r/emacs-devel/2020-08/msg00313.html I looked for similar problems elsewhere and found quite a few. * src/coding.c (make_subsidiaries): * src/composite.c (syms_of_composite): * src/font.c (build_style_table, Ffont_get_glyphs): * src/nsselect.m (clean_local_selection_data): * src/nsxwidget.m (js_to_lisp): * src/syntax.c (init_syntax_once): * src/window.c (Fcurrent_window_configuration): * src/xselect.c (selection_data_to_lisp_data) (clean_local_selection_data): Use make_nil_vector instead of make_uninit_vector. * src/fns.c (Fdelete): * src/xwidget.c (webkit_js_to_lisp): Use allocate_nil_vector instead of allocate_vector. * src/search.c (Fnewline_cache_check): Use make_vector instead of make_uninit_vector.
* Remove many items obsolete since Emacs 23.1Stefan Kangas2020-08-141-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Emacs 23.1 was five major releases and over a decade ago. This list can be reviewed before to the next release, but for now hopefully this motivates any needed external updates. Ref: https://lists.gnu.org/archive/html/emacs-devel/2020-05/msg02198.html * lisp/abbrev.el (pre-abbrev-expand-hook): * lisp/bookmark.el (bookmark-read-annotation-text-func) (bookmark-jump-noselect): * lisp/buff-menu.el (buffer-menu-mode-hook): * lisp/cus-edit.el (custom-mode-hook, custom-mode): * lisp/dirtrack.el (dirtrack-debug-toggle, dirtrack-debug): * lisp/emacs-lisp/crm.el (crm-minibuffer-complete) (crm-minibuffer-completion-help) (crm-minibuffer-complete-and-exit): * lisp/emacs-lisp/easymenu.el (easy-menu-precalculate-equivalent-keybindings): * lisp/emacs-lisp/lisp-mode.el (lisp-mode-auto-fill): * lisp/epa.el (epa-display-verify-result): * lisp/epg.el (epg-passphrase-callback-function): * lisp/eshell/eshell.el (eshell-report-bug): * lisp/ffap.el (ffap-bug, ffap-submit-bug): * lisp/files.el (locate-file-completion): * lisp/hi-lock.el (hi-lock-face-history, hi-lock-regexp-history): * lisp/hilit-chg.el (highlight-changes-initial-state) (highlight-changes-active-string) (highlight-changes-passive-string, global-highlight-changes): * lisp/international/mule-cmds.el (nonascii-insert-offset) (nonascii-translation-table): * lisp/international/mule-diag.el (non-iso-charset-alist): * lisp/international/mule-util.el (detect-coding-with-priority): * lisp/international/mule.el (charset-id, charset-bytes) (charset-list, char-valid-p, generic-char-p) (char-coding-system-table, make-coding-system) (set-coding-priority) * lisp/mail/rmail.el (rmail-message-filter): * lisp/minibuffer.el (complete-in-turn, dynamic-completion-table) (completion-common-substring) (minibuffer-local-must-match-filename-map): * lisp/mouse.el (mouse-major-mode-menu, mouse-popup-menubar) (mouse-popup-menubar-stuff): * lisp/net/newst-treeview.el (newsticker-groups-filename): * lisp/obsolete/tpu-edt.el (tpu-have-ispell, GOLD-map): * lisp/password-cache.el (password-read-and-add): * lisp/shell.el (shell-dirtrack-toggle): * lisp/subr.el (forward-point, redisplay-end-trigger-functions) (process-filter-multibyte-p, set-process-filter-multibyte): * lisp/t-mouse.el (t-mouse-mode): * lisp/term/w32-win.el (w32-focus-frame, w32-select-font): * lisp/textmodes/ispell.el (ispell-aspell-supports-utf8): * lisp/textmodes/remember.el (remember-buffer): * lisp/tooltip.el (tooltip-hook): * lisp/url/url-util.el (url-generate-unique-filename): * lisp/url/url-vars.el (url-temporary-directory): * lisp/vc/vc-hooks.el (vc-workfile-version) (vc-default-working-revision): * lisp/vc/vc-mtn.el (vc-mtn-command): * lisp/vc/vc.el (vc-revert-buffer): * lisp/vcursor.el (vcursor-toggle-vcursor-map): Remove items, obsolete since Emacs 23.1. * lisp/abbrev.el (expand-abbrev): * lisp/epg.el (epg-context): Change 'epg-passphrase-callback-function' call to 'epa-' alternative. * lisp/eshell/em-rebind.el (eshell-cannot-leave-input-list): Don't refer to removed function 'forward-point'. * test/manual/etags/c-src/abbrev.c (Fexpand_abbrev): (syms_of_abbrev): Don't run removed hook 'pre-abbrev-expand-hook'. * lisp/international/mule.el (transform-make-coding-system-args): Declare obsolete. * lisp/progmodes/idlwave.el: Update reference to removed function 'char-valid-p'. * lisp/gnus/mml2015.el (epg-encrypt-string): * lisp/gnus/mml1991.el (epg-make-context): * lisp/gnus/mml-smime.el (autoload): Remove autoload of removed 'epg-passphrase-callback-function'. * lisp/minibuffer.el (completion-extra-properties): Remove support for `completion-common-substring'. * lisp/obsolete/tpu-edt.el (tpu-toggle-overwrite-mode) Remove support for removed `spell' package. * src/coding.c (syms_of_coding): * doc/misc/efaq.texi: * doc/emacs/frames.texi (Menu Mouse Clicks): * doc/misc/url.texi (Customization): Doc fixes. ; * etc/NEWS: List removed items.
* Document that {en,de}code-coding-string preserve match dataMattias Engdegård2020-05-281-2/+2
| | | | | | | | | | * lisp/international/mule.el (define-coding-system): Require :pre-write-conversion and :post-read-conversion functions to leave the match data untouched. * src/coding.c (Fdecode_coding_string, Fencode_coding_string): Document functions as match-data-preserving. Suggested by Stefan Monnier (see bug#41445).
* Fix string-to-multibyte overlong sequence bugPaul Eggert2020-04-201-6/+8
| | | | | | | | | * src/character.h (MULTIBYTE_LENGTH, MULTIBYTE_LENGTH_NO_CHECK): Remove, replacing with ... (multibyte_length): ... this new function. All callers changed. The new function rejects overlong multibyte forms. * test/src/buffer-tests.el (buffer-multibyte-overlong-sequences): New test.
* Prefer more inline functions in character.hPaul Eggert2020-04-171-35/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* Allow ENCODE_FILE and DECODE_FILE to use no-copy conversionMattias Engdegård2020-04-111-12/+17
| | | | | | | | | | They already did return their argument under some circumstances; this change broadens it to further reduce allocation in common cases (bug#40407). * src/coding.c (convert_string_nocopy): New function. (decode_file_name, encode_file_name): Use convert_string_nocopy. * src/coding.h (ENCODE_FILE, DECODE_FILE): Note the nocopy semantics.
* Set last-coding-system-used upon ASCII conversion bypass (bug#40407)Mattias Engdegård2020-04-091-5/+9
| | | | | | | | Spotted by Kazuhiro Ito. * src/coding.c (code_convert_string): Set Vlast_coding_system if appropriate. * test/src/coding-tests.el (coding-nocopy-ascii): Add test.
* Fix ASCII-only conversion logic (bug#40407)Mattias Engdegård2020-04-091-29/+17
| | | | | | | | | | | To sidestep conversion altogether when EOL conversion applies, we must either be encoding a string without NL, or decoding without CR. * src/coding.c (string_ascii_p): Revert to a pure predicate. (code_convert_string): Fix logic. Don't use uninitialised ascii_p (removed). Use memchr to detect CR or LF in string when needed. * test/src/coding-tests.el (coding-nocopy-ascii): Update tests to include encodings with explicit EOL conversions.
* Don't crash with invalid argument in check-coding-systems-regionMattias Engdegård2020-04-091-1/+4
| | | | | | | * src/coding.c (Fcheck_coding_systems_region): Don't crash if the third arg contains something that isn't a coding system. * test/src/coding-tests.el (coding-check-coding-systems-region): New test.
* Fix decoding of ASCII strings with embedded CR charactersEli Zaretskii2020-04-091-2/+2
| | | | | | | | | | | | * src/coding.c (string_ascii_p): Return a negative value if an all-ASCII string STR includes the CR character, otherwise a positive value. (code_convert_string): If the string is ASCII, but includes CR characters, use the fast path only if EOL doesn't need to be decoded. (Bug#40519) * test/src/coding-tests.el (coding-nocopy-ascii): Add more tests for bug#40519.
* Fix decoding ASCII strings with embedded CR charactersEli Zaretskii2020-04-091-11/+26
| | | | | | | | | | | | * src/coding.c (string_ascii_p): Return a negative value if an all-ASCII string STR includes the CR character, otherwise a positive value. (code_convert_string): If the string is ASCII, but includes CR characters, use the fast path only if EOL doesn't need to be decoded. (Bug#40519) * test/src/coding-tests.el (coding-nocopy-ascii): Add tests for bug#40519.
* * src/coding.c (code_convert_string): Fix type mismatches.Paul Eggert2020-04-051-2/+2
|
* Avoid expensive recoding for ASCII identity cases (bug#40407)Mattias Engdegård2020-04-051-1/+26
| | | | | | | | | | Optimise for the common case of encoding or decoding an ASCII-only string using an ASCII-compatible coding, for file names in particular. * src/coding.c (string_ascii_p): New function. (code_convert_string): Return the input string for ASCII-only inputs and ASCII-compatible codings. * test/src/coding-tests.el (coding-nocopy-ascii): New test.
* Fix inverted NOCOPY encode/decode parameter (bug#40407)Mattias Engdegård2020-04-051-1/+1
| | | | | | | | | | In {encode,decode}-coding-string, the NOCOPY parameter had the opposite effect to what was intended and documented. This 18 year old bug (introduced in 4031e2bf0a) only affected calls with CODING-SYSTEM being nil. * src/coding.c (code_convert_string): Correct use of NOCOPY. * test/src/coding-tests.el (coding-nocopy-trivial): New test.
* Improve integer range checkingPaul Eggert2020-04-051-5/+3
| | | | | | | | | | | | | | | | | | * src/bignum.c (check_integer_range, check_uinteger_max) (check_int_nonnegative): New functions. * src/frame.c (check_frame_pixels): New function. (Fset_frame_height, Fset_frame_width, Fset_frame_size): Use it. * src/lisp.h (CHECK_RANGED_INTEGER, CHECK_TYPE_RANGED_INTEGER): Remove these macros. Unless otherwise specified, all callers replaced by calls to check_integer_range, check_uinteger_range, check_int_nonnegative. * src/frame.c (gui_set_right_divider_width) (gui_set_bottom_divider_width): * src/nsfns.m (ns_set_internal_border_width): * src/xfns.c (x_set_internal_border_width): Using check_int_nonnegative means these functions no longer incorrectly reject negative bignums; they treat them as 0, just like negative fixnums.
* Treat out-of-range positions consistentlyPaul Eggert2020-03-271-21/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Use decode_string_utf_8 in emacs-module.c.Philipp Stephani2020-01-131-0/+2
| | | | | | | | | | | Now that decode_string_utf_8 is available, we can use it to signal errors on invalid input. * src/coding.c (syms_of_coding): Move Qutf_8_string_p from json.c since it’s now used outside json.c. * src/emacs-module.c (module_decode_utf_8): New helper function. (module_make_function, module_copy_string_contents): Use it.
* Update copyright year to 2020Paul Eggert2020-01-011-1/+1
| | | | Run "TZ=UTC0 admin/update-copyright $(git ls-files)".
* Clarify base64 requirements and say what {en,de}code_coding_region doesLars Ingebrigtsen2019-12-241-0/+14
| | | | | | | | | | * src/coding.c (Fencode_coding_region): Clarify what this does. (Fdecode_coding_region): Ditto. * src/fns.c (Fbase64_decode_region): Clarify that this function returns bytes, not text (bug#38587). (Fbase64_encode_region): Clarify that this function takes bytes, not text.
* Spelling fixesPaul Eggert2019-12-091-4/+4
|
* Fix and speed up en/decoding of UTF-8 stringsEli Zaretskii2019-11-231-80/+122
| | | | | | | | | | | | * src/coding.c (get_char_bytes, encode_string_utf_8) (decode_string_utf_8): Fix commentary. (encode_string_utf_8): Return the original ASCII string only if NOCOPY is non-zero. (decode_string_utf_8): Accept 2 additional arguments STR and STR_LEN, which allow to pass the input text as a C string. (make_string_from_utf8): Delegate the job to decode_string_utf_8. * src/coding.h: Update the prototype of decode_string_utf_8. * src/json.c (json_encode): Call encode_string_utf_8.
* Fix duplicated words in commentsRobert Pluim2019-10-151-1/+1
| | | | | | | | * src/coding.c (encode_string_utf_8): * src/keyboard.c (syms_of_keyboard): * src/mini-gmp.c (gmp_lucas_mod, mpz_export): * src/pdumper.c (dump_set_referrer, dump_queue_compute_score): * src/timefns.c (Ftime_convert): Remove duplicated words.
* Update some URLsPaul Eggert2019-09-231-1/+1
| | | | | | | | | | | | | | | | | This mostly changes http: to https: in URLs. It also updates some URLs that have moved, removes some URLs that no longer work, recommends against using procmail (procmail.org no longer works), and removes some mentions of the no-longer-existing Gmane, LPF and VTW. It doesn't update all URLs, just the ones I had time for. * GNUmakefile (help): * admin/admin.el (manual-doctype-string): * admin/charsets/Makefile.in (${charsetdir}/ALTERNATIVNYJ.map): * admin/charsets/mapconv: * lisp/net/soap-client.el (soap-create-envelope): * lisp/org/org.el (org-doi-server-url): * lisp/textmodes/bibtex.el (bibtex-generate-url-list): Prefer https: to http: un URLs.
* Fix a recent change in coding.cEli Zaretskii2019-08-251-7/+10
| | | | | | | | | | This partially reverts the changes in "extern function cleanup". * src/coding.c (encode_string_utf_8, decode_string_utf_8): Now extern again. They should NOT be static, as they are intended to be used by the likes of json.c, where we need highly-optimized code for processing UTF-8 strings. E.g., decode_string_utf_8 beats make_string_from_utf8 by a factor of 2 to 5 in a large number of scenarios.
* extern function cleanupPaul Eggert2019-08-241-6/+6
| | | | | | | | | | | | | Most of these functions can be static. A few are unused. * src/coding.c (encode_string_utf_8, decode_string_utf_8): Define only if ENABLE_UTF_8_CONVERTER_TEST, as they're not needed otherwise. * src/coding.c (encode_string_utf_8, decode_string_utf_8): * src/data.c (integer_mod): * src/fns.c (base64_encode_region_1, base64_encode_string_1): * src/ftfont.c (ftfont_get_fc_charset): Now static. * src/sysdep.c (verrprintf): Remove; unused.
* Fix the MS-Windows build broken by recent changesEli Zaretskii2019-08-041-0/+2
| | | | | | | * src/inotify.c (syms_of_inotify) <Qignored>: Don't define here... * src/coding.c (syms_of_coding) <Qignored>: ...define it here, because it is needed also on platforms that don't compile inotify.c.
* Minor fix to recent coding.c changePaul Eggert2019-08-041-63/+60
| | | | | | * src/coding.c (get_buffer_gap_address): Don’t assume string or buffer length fits in int. Also, improve wording of comments.
* Add Unicode-safe UTF-8 converterK. Handa2019-08-041-0/+730
| | | | | * src/coding.c (encode_string_utf_8, decode_string_utf_8): New functions. * src/coding.h (encode_string_utf_8, decode_string_utf_8): Extern them.
* Avoid some unnecessary stdio.h includesPaul Eggert2019-07-081-1/+0
| | | | | | | | | * src/atimer.c, src/callproc.c, src/coding.c, src/dired.c, src/eval.c: * src/fringe.c, src/ftcrfont.c, src/ftfont.c, src/ftxfont.c: * src/gfilenotify.c, src/indent.c, src/kqueue.c, src/menu.c: * src/scroll.c, src/terminal.c, src/unexcoff.c, src/window.c: * src/xfont.c, src/xftfont.c: Do not include stdio.h since it is unused.
* * src/coding.c (decode_coding): Improve doc.Stefan Monnier2019-07-041-3/+7
|
* * src/coding.c (decode_coding_gap): Remove `chars` argument.Stefan Monnier2019-07-021-7/+10
| | | | | | * src/json.c (Fjson_insert): * src/fileio.c (Finsert_file_contents): * src/coding.h (decode_coding_gap): Adjust accordingly.
* Merge from origin/emacs-26Glenn Morris2019-06-011-9/+19
|\ | | | | | | | | | | | | | | | | | | | | 2168165 ; * doc/lispref/nonascii.texi (Explicit Encoding): Fix typo. 8f18d12 Improve documentation of decoding into a unibyte buffer 7681a57 Remove redundants "See" before @xref or @pxref (Bug#35793) 9bee762 ; * src/coding.c: Improve commentary. (Bug#34765) e61349c Fix customization type of recentf-max-saved-items # Conflicts: # src/coding.c
| * Improve documentation of decoding into a unibyte bufferEli Zaretskii2019-05-251-2/+5
| | | | | | | | | | | | | | | | | | * doc/lispref/nonascii.texi (Explicit Encoding): Document what happens when DESTINATION of decoding is a unibyte buffer. * src/coding.c (Fdecode_coding_region) (Fdecode_coding_string): Document what happens if DESTINATION is a unibyte buffer.
| * ; * src/coding.c: Improve commentary. (Bug#34765)Eli Zaretskii2019-05-231-7/+14
| |
* | Fix names of functions in last commitEli Zaretskii2019-04-281-7/+11
| | | | | | | | | | | | | | * src/coding.h (build_string_from_utf8): Rename from build_utf8_string. All callers changed. * src/coding.c (make_string_from_utf8): Rename from make_utf8_string. All callers changed.
* | Refactoring: move UTF-8 decoding functions into coding.h.Philipp Stephani2019-04-281-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | json_make_string and json_build_string are generally useful and not JSON-specific. Move them to coding.[ch]. * src/coding.h (build_utf8_string): Move from json.c. * src/coding.c (make_utf8_string): Move from json.c. * src/json.c (json_make_string, json_build_string): Move to coding.[ch]. Split out JSON-specific comment. (json_parse_error, Fjson_serialize, json_to_lisp): Fix callers. * src/emacs-module.c (module_make_function, module_make_string): Use new functions. (module_decode, module_decode_copy): Remove.
* | Remove static var system_eol_typePaul Eggert2019-04-141-24/+14
| | | | | | | | | | | | * src/coding.c (system_eol_type): Remove. (coding_inherit_eol_type, syms_of_coding): Simplify to avoid the need for system_eol_type.
* | Don't run buffer-related hooks in " *code conversion work*" buffersEli Zaretskii2019-03-301-22/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Note: portions of this change were mistakenly pushed as part of an unrelated commit a35a1f6a9. * src/buffer.c (Fget_buffer_create): Set inhibit_buffer_hooks non-zero for temporary buffers created by coding.c. Don't run buffer-list-update-hook for such buffers. (Frename_buffer, Fkill_buffer, record_buffer) (Fbury_buffer_internal): Don't run hooks for buffers whose inhibit_buffer_hooks flag is set. * src/buffer.h (struct buffer): New member inhibit_buffer_hooks. * src/pdumper.c (dump_buffer): Dump the new field. Update the hash value in HASH_buffer_XXX. * src/coding.c (make_conversion_work_buffer): Function deleted; code moved to code_conversion_save. (code_conversion_save): Insert code from make_conversion_work_buffer, but arrange for unwind-protecting the current buffer before switching to the work buffer. This avoids leaving reused_workbuf_in_use set if user presses C-g during encoding/decoding. (Vcode_conversion_workbuf_name): Now external variable. * src/coding.h (Vcode_conversion_reused_workbuf): Declare.