X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/b235ceaaf69345a5c79ec96ce0ca61b29fb232e1..91917dd58ec5278e555b9c693a830749083e8f89:/src/fileio.c diff --git a/src/fileio.c b/src/fileio.c index b82b7d360b..e18ddb1a7a 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -43,7 +43,7 @@ along with GNU Emacs. If not, see . */ #include #include "lisp.h" -#include "intervals.h" +#include "composite.h" #include "character.h" #include "buffer.h" #include "coding.h" @@ -51,7 +51,6 @@ along with GNU Emacs. If not, see . */ #include "blockinput.h" #include "region-cache.h" #include "frame.h" -#include "dispextern.h" #ifdef WINDOWSNT #define NOMINMAX 1 @@ -451,7 +450,7 @@ DEFUN ("unhandled-file-name-directory", Funhandled_file_name_directory, A `directly usable' directory name is one that may be used without the intervention of any file handler. If FILENAME is a directly usable file itself, return -(file-name-directory FILENAME). +(file-name-as-directory FILENAME). If FILENAME refers to a file which is not accessible from a local process, then this should return nil. The `call-process' and `start-process' functions use this function to @@ -470,7 +469,7 @@ get a current directory to run processes in. */) return STRINGP (handled_name) ? handled_name : Qnil; } - return Ffile_name_directory (filename); + return Ffile_name_as_directory (filename); } /* Maximum number of bytes that DST will be longer than SRC @@ -3470,7 +3469,11 @@ by calling `format-decode', which see. */) mtime = time_error_value (save_errno); st.st_size = -1; if (!NILP (Vcoding_system_for_read)) - Fset (Qbuffer_file_coding_system, Vcoding_system_for_read); + { + /* Don't let invalid values into buffer-file-coding-system. */ + CHECK_CODING_SYSTEM (Vcoding_system_for_read); + Fset (Qbuffer_file_coding_system, Vcoding_system_for_read); + } goto notfound; } @@ -4260,9 +4263,14 @@ by calling `format-decode', which see. */) if (CODING_FOR_UNIBYTE (&coding) /* Can't do this if part of the buffer might be preserved. */ && NILP (replace)) - /* Visiting a file with these coding system makes the buffer - unibyte. */ - bset_enable_multibyte_characters (current_buffer, Qnil); + { + /* Visiting a file with these coding system makes the buffer + unibyte. */ + if (inserted > 0) + bset_enable_multibyte_characters (current_buffer, Qnil); + else + Fset_buffer_multibyte (Qnil); + } } coding.dst_multibyte = ! NILP (BVAR (current_buffer, enable_multibyte_characters)); @@ -4569,7 +4577,7 @@ choose_write_coding_system (Lisp_Object start, Lisp_Object end, Lisp_Object file if (NILP (val)) { /* If we still have not decided a coding system, use the - default value of buffer-file-coding-system. */ + current buffer's value of buffer-file-coding-system. */ val = BVAR (current_buffer, buffer_file_coding_system); using_default_coding = 1; } @@ -4587,9 +4595,16 @@ choose_write_coding_system (Lisp_Object start, Lisp_Object end, Lisp_Object file if (!force_raw_text && !NILP (Ffboundp (Vselect_safe_coding_system_function))) - /* Confirm that VAL can surely encode the current region. */ - val = call5 (Vselect_safe_coding_system_function, - start, end, val, Qnil, filename); + { + /* Confirm that VAL can surely encode the current region. */ + val = call5 (Vselect_safe_coding_system_function, + start, end, val, Qnil, filename); + /* As the function specified by select-safe-coding-system-function + is out of our control, make sure we are not fed by bogus + values. */ + if (!NILP (val)) + CHECK_CODING_SYSTEM (val); + } /* If the decided coding-system doesn't specify end-of-line format, we use that of