diff options
| author | Yuuki Harano | 2020-12-27 03:13:00 +0900 |
|---|---|---|
| committer | Yuuki Harano | 2020-12-27 03:13:00 +0900 |
| commit | b64089c37b4305a511e5ddbf02746862c7c7575e (patch) | |
| tree | c6978d471e4b0b061b7cc9c46147968379aec94f /src/coding.c | |
| parent | 565d8f57d349c19d9bbb5d5d5fdacf3c70b85d42 (diff) | |
| parent | 4b2ca6bfc079c66cfcf39f2f36dc139012787535 (diff) | |
| download | emacs-b64089c37b4305a511e5ddbf02746862c7c7575e.tar.gz emacs-b64089c37b4305a511e5ddbf02746862c7c7575e.zip | |
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs into feature/pgtk
Diffstat (limited to 'src/coding.c')
| -rw-r--r-- | src/coding.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/src/coding.c b/src/coding.c index 2142e7fa518..8c2443889d4 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -7821,7 +7821,7 @@ encode_coding (struct coding_system *coding) | |||
| 7821 | 7821 | ||
| 7822 | /* A string that serves as name of the reusable work buffer, and as base | 7822 | /* A string that serves as name of the reusable work buffer, and as base |
| 7823 | name of temporary work buffers used for code-conversion operations. */ | 7823 | name of temporary work buffers used for code-conversion operations. */ |
| 7824 | Lisp_Object Vcode_conversion_workbuf_name; | 7824 | static Lisp_Object Vcode_conversion_workbuf_name; |
| 7825 | 7825 | ||
| 7826 | /* The reusable working buffer, created once and never killed. */ | 7826 | /* The reusable working buffer, created once and never killed. */ |
| 7827 | static Lisp_Object Vcode_conversion_reused_workbuf; | 7827 | static Lisp_Object Vcode_conversion_reused_workbuf; |
| @@ -7839,7 +7839,7 @@ code_conversion_restore (Lisp_Object arg) | |||
| 7839 | if (! NILP (workbuf)) | 7839 | if (! NILP (workbuf)) |
| 7840 | { | 7840 | { |
| 7841 | if (EQ (workbuf, Vcode_conversion_reused_workbuf)) | 7841 | if (EQ (workbuf, Vcode_conversion_reused_workbuf)) |
| 7842 | reused_workbuf_in_use = 0; | 7842 | reused_workbuf_in_use = false; |
| 7843 | else | 7843 | else |
| 7844 | Fkill_buffer (workbuf); | 7844 | Fkill_buffer (workbuf); |
| 7845 | } | 7845 | } |
| @@ -7857,13 +7857,13 @@ code_conversion_save (bool with_work_buf, bool multibyte) | |||
| 7857 | { | 7857 | { |
| 7858 | Lisp_Object name | 7858 | Lisp_Object name |
| 7859 | = Fgenerate_new_buffer_name (Vcode_conversion_workbuf_name, Qnil); | 7859 | = Fgenerate_new_buffer_name (Vcode_conversion_workbuf_name, Qnil); |
| 7860 | workbuf = Fget_buffer_create (name); | 7860 | workbuf = Fget_buffer_create (name, Qt); |
| 7861 | } | 7861 | } |
| 7862 | else | 7862 | else |
| 7863 | { | 7863 | { |
| 7864 | if (NILP (Fbuffer_live_p (Vcode_conversion_reused_workbuf))) | 7864 | if (NILP (Fbuffer_live_p (Vcode_conversion_reused_workbuf))) |
| 7865 | Vcode_conversion_reused_workbuf | 7865 | Vcode_conversion_reused_workbuf |
| 7866 | = Fget_buffer_create (Vcode_conversion_workbuf_name); | 7866 | = Fget_buffer_create (Vcode_conversion_workbuf_name, Qt); |
| 7867 | workbuf = Vcode_conversion_reused_workbuf; | 7867 | workbuf = Vcode_conversion_reused_workbuf; |
| 7868 | } | 7868 | } |
| 7869 | } | 7869 | } |
| @@ -7881,7 +7881,7 @@ code_conversion_save (bool with_work_buf, bool multibyte) | |||
| 7881 | bset_undo_list (current_buffer, Qt); | 7881 | bset_undo_list (current_buffer, Qt); |
| 7882 | bset_enable_multibyte_characters (current_buffer, multibyte ? Qt : Qnil); | 7882 | bset_enable_multibyte_characters (current_buffer, multibyte ? Qt : Qnil); |
| 7883 | if (EQ (workbuf, Vcode_conversion_reused_workbuf)) | 7883 | if (EQ (workbuf, Vcode_conversion_reused_workbuf)) |
| 7884 | reused_workbuf_in_use = 1; | 7884 | reused_workbuf_in_use = true; |
| 7885 | set_buffer_internal (current); | 7885 | set_buffer_internal (current); |
| 7886 | } | 7886 | } |
| 7887 | 7887 | ||
| @@ -10354,8 +10354,8 @@ decode_file_name (Lisp_Object fname) | |||
| 10354 | #endif | 10354 | #endif |
| 10355 | } | 10355 | } |
| 10356 | 10356 | ||
| 10357 | Lisp_Object | 10357 | static Lisp_Object |
| 10358 | encode_file_name (Lisp_Object fname) | 10358 | encode_file_name_1 (Lisp_Object fname) |
| 10359 | { | 10359 | { |
| 10360 | /* This is especially important during bootstrap and dumping, when | 10360 | /* This is especially important during bootstrap and dumping, when |
| 10361 | file-name encoding is not yet known, and therefore any non-ASCII | 10361 | file-name encoding is not yet known, and therefore any non-ASCII |
| @@ -10380,6 +10380,19 @@ encode_file_name (Lisp_Object fname) | |||
| 10380 | #endif | 10380 | #endif |
| 10381 | } | 10381 | } |
| 10382 | 10382 | ||
| 10383 | Lisp_Object | ||
| 10384 | encode_file_name (Lisp_Object fname) | ||
| 10385 | { | ||
| 10386 | Lisp_Object encoded = encode_file_name_1 (fname); | ||
| 10387 | /* No system accepts NUL bytes in filenames. Allowing them can | ||
| 10388 | cause subtle bugs because the system would silently use a | ||
| 10389 | different filename than expected. Perform this check after | ||
| 10390 | encoding to not miss NUL bytes introduced through encoding. */ | ||
| 10391 | CHECK_TYPE (memchr (SSDATA (encoded), '\0', SBYTES (encoded)) == NULL, | ||
| 10392 | Qfilenamep, fname); | ||
| 10393 | return encoded; | ||
| 10394 | } | ||
| 10395 | |||
| 10383 | DEFUN ("decode-coding-string", Fdecode_coding_string, Sdecode_coding_string, | 10396 | DEFUN ("decode-coding-string", Fdecode_coding_string, Sdecode_coding_string, |
| 10384 | 2, 4, 0, | 10397 | 2, 4, 0, |
| 10385 | doc: /* Decode STRING which is encoded in CODING-SYSTEM, and return the result. | 10398 | doc: /* Decode STRING which is encoded in CODING-SYSTEM, and return the result. |
| @@ -11639,7 +11652,7 @@ syms_of_coding (void) | |||
| 11639 | staticpro (&Vcode_conversion_workbuf_name); | 11652 | staticpro (&Vcode_conversion_workbuf_name); |
| 11640 | Vcode_conversion_workbuf_name = build_pure_c_string (" *code-conversion-work*"); | 11653 | Vcode_conversion_workbuf_name = build_pure_c_string (" *code-conversion-work*"); |
| 11641 | 11654 | ||
| 11642 | reused_workbuf_in_use = 0; | 11655 | reused_workbuf_in_use = false; |
| 11643 | PDUMPER_REMEMBER_SCALAR (reused_workbuf_in_use); | 11656 | PDUMPER_REMEMBER_SCALAR (reused_workbuf_in_use); |
| 11644 | 11657 | ||
| 11645 | DEFSYM (Qcharset, "charset"); | 11658 | DEFSYM (Qcharset, "charset"); |
| @@ -11780,6 +11793,7 @@ syms_of_coding (void) | |||
| 11780 | DEFSYM (Qignored, "ignored"); | 11793 | DEFSYM (Qignored, "ignored"); |
| 11781 | 11794 | ||
| 11782 | DEFSYM (Qutf_8_string_p, "utf-8-string-p"); | 11795 | DEFSYM (Qutf_8_string_p, "utf-8-string-p"); |
| 11796 | DEFSYM (Qfilenamep, "filenamep"); | ||
| 11783 | 11797 | ||
| 11784 | defsubr (&Scoding_system_p); | 11798 | defsubr (&Scoding_system_p); |
| 11785 | defsubr (&Sread_coding_system); | 11799 | defsubr (&Sread_coding_system); |