aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa1998-03-03 07:18:46 +0000
committerKenichi Handa1998-03-03 07:18:46 +0000
commitcd913586adcd4e89bb982f9a49bdb7080914f05a (patch)
tree3109ca7aea23780e2a3f3a8ef02c5d3bc68d6e1f /src
parent0457b5e41d5ecaf6eb84d1dbf4271afb8479bfe8 (diff)
downloademacs-cd913586adcd4e89bb982f9a49bdb7080914f05a.tar.gz
emacs-cd913586adcd4e89bb982f9a49bdb7080914f05a.zip
(ENCODE_FILE): This macro is moved to coding.h.
(Vdefault_file_name_coding_system): New variable. (syms_of_fileio): Defsubr it. (Ffile_symlink_p): Use DECODE_FILE. (Ffile_name_directory): Use size_byte member of XSTRING (filename). (Ffile_name_as_directory): Likewise. (Fdirectory_file_name): Likewise. (Fsubstitute_in_file_name): Likewise. (expand_and_dir_to_file): Likewise. (Fdo_auto_save): Likewise. (Fread_file_name): Likewise.
Diffstat (limited to 'src')
-rw-r--r--src/fileio.c53
1 files changed, 31 insertions, 22 deletions
diff --git a/src/fileio.c b/src/fileio.c
index 4f0fcd18bac..4006bf839aa 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -152,14 +152,6 @@ extern char *strerror ();
152#define min(a, b) ((a) < (b) ? (a) : (b)) 152#define min(a, b) ((a) < (b) ? (a) : (b))
153#define max(a, b) ((a) > (b) ? (a) : (b)) 153#define max(a, b) ((a) > (b) ? (a) : (b))
154 154
155/* Encode the file name NAME using the specified coding system
156 for file names, if any. */
157#define ENCODE_FILE(name) \
158 (! NILP (Vfile_name_coding_system) \
159 && XFASTINT (Vfile_name_coding_system) != 0 \
160 ? Fencode_coding_string (name, Vfile_name_coding_system, Qt) \
161 : name)
162
163/* Nonzero during writing of auto-save files */ 155/* Nonzero during writing of auto-save files */
164int auto_saving; 156int auto_saving;
165 157
@@ -170,6 +162,10 @@ int auto_save_mode_bits;
170/* Coding system for file names, or nil if none. */ 162/* Coding system for file names, or nil if none. */
171Lisp_Object Vfile_name_coding_system; 163Lisp_Object Vfile_name_coding_system;
172 164
165/* Coding system for file names used only when
166 Vfile_name_coding_system is nil. */
167Lisp_Object Vdefault_file_name_coding_system;
168
173/* Alist of elements (REGEXP . HANDLER) for file names 169/* Alist of elements (REGEXP . HANDLER) for file names
174 whose I/O is done with a special handler. */ 170 whose I/O is done with a special handler. */
175Lisp_Object Vfile_name_handler_alist; 171Lisp_Object Vfile_name_handler_alist;
@@ -379,7 +375,7 @@ on VMS, perhaps instead a string ending in `:', `]' or `>'.")
379#ifdef DOS_NT 375#ifdef DOS_NT
380 beg = strcpy (alloca (strlen (beg) + 1), beg); 376 beg = strcpy (alloca (strlen (beg) + 1), beg);
381#endif 377#endif
382 p = beg + XSTRING (filename)->size; 378 p = beg + XSTRING (filename)->size_byte;
383 379
384 while (p != beg && !IS_DIRECTORY_SEP (p[-1]) 380 while (p != beg && !IS_DIRECTORY_SEP (p[-1])
385#ifdef VMS 381#ifdef VMS
@@ -589,7 +585,7 @@ On VMS, converts \"[X]FOO.DIR\" to \"[X.FOO]\", etc.")
589 if (!NILP (handler)) 585 if (!NILP (handler))
590 return call2 (handler, Qfile_name_as_directory, file); 586 return call2 (handler, Qfile_name_as_directory, file);
591 587
592 buf = (char *) alloca (XSTRING (file)->size + 10); 588 buf = (char *) alloca (XSTRING (file)->size_byte + 10);
593 return build_string (file_name_as_directory (buf, XSTRING (file)->data)); 589 return build_string (file_name_as_directory (buf, XSTRING (file)->data));
594} 590}
595 591
@@ -784,9 +780,9 @@ it returns a file name such as \"[X]Y.DIR.1\".")
784 /* 20 extra chars is insufficient for VMS, since we might perform a 780 /* 20 extra chars is insufficient for VMS, since we might perform a
785 logical name translation. an equivalence string can be up to 255 781 logical name translation. an equivalence string can be up to 255
786 chars long, so grab that much extra space... - sss */ 782 chars long, so grab that much extra space... - sss */
787 buf = (char *) alloca (XSTRING (directory)->size + 20 + 255); 783 buf = (char *) alloca (XSTRING (directory)->size_byte + 20 + 255);
788#else 784#else
789 buf = (char *) alloca (XSTRING (directory)->size + 20); 785 buf = (char *) alloca (XSTRING (directory)->size_byte + 20);
790#endif 786#endif
791 directory_file_name (XSTRING (directory)->data, buf); 787 directory_file_name (XSTRING (directory)->data, buf);
792 return build_string (buf); 788 return build_string (buf);
@@ -1809,7 +1805,7 @@ duplicates what `expand-file-name' does.")
1809 CORRECT_DIR_SEPS (nm); 1805 CORRECT_DIR_SEPS (nm);
1810 substituted = (strcmp (nm, XSTRING (filename)->data) != 0); 1806 substituted = (strcmp (nm, XSTRING (filename)->data) != 0);
1811#endif 1807#endif
1812 endp = nm + XSTRING (filename)->size; 1808 endp = nm + XSTRING (filename)->size_byte;
1813 1809
1814 /* If /~ or // appears, discard everything through first slash. */ 1810 /* If /~ or // appears, discard everything through first slash. */
1815 1811
@@ -1902,7 +1898,7 @@ duplicates what `expand-file-name' does.")
1902 1898
1903 /* If substitution required, recopy the string and do it */ 1899 /* If substitution required, recopy the string and do it */
1904 /* Make space in stack frame for the new copy */ 1900 /* Make space in stack frame for the new copy */
1905 xnm = (unsigned char *) alloca (XSTRING (filename)->size + total + 1); 1901 xnm = (unsigned char *) alloca (XSTRING (filename)->size_byte + total + 1);
1906 x = xnm; 1902 x = xnm;
1907 1903
1908 /* Copy the rest of the name through, replacing $ constructs with values */ 1904 /* Copy the rest of the name through, replacing $ constructs with values */
@@ -2021,7 +2017,7 @@ expand_and_dir_to_file (filename, defdir)
2021 absname = Fexpand_file_name (filename, defdir); 2017 absname = Fexpand_file_name (filename, defdir);
2022#ifdef VMS 2018#ifdef VMS
2023 { 2019 {
2024 register int c = XSTRING (absname)->data[XSTRING (absname)->size - 1]; 2020 register int c = XSTRING (absname)->data[XSTRING (absname)->size_byte - 1];
2025 if (c == ':' || c == ']' || c == '>') 2021 if (c == ':' || c == ']' || c == '>')
2026 absname = Fdirectory_file_name (absname); 2022 absname = Fdirectory_file_name (absname);
2027 } 2023 }
@@ -2029,8 +2025,8 @@ expand_and_dir_to_file (filename, defdir)
2029 /* Remove final slash, if any (unless this is the root dir). 2025 /* Remove final slash, if any (unless this is the root dir).
2030 stat behaves differently depending! */ 2026 stat behaves differently depending! */
2031 if (XSTRING (absname)->size > 1 2027 if (XSTRING (absname)->size > 1
2032 && IS_DIRECTORY_SEP (XSTRING (absname)->data[XSTRING (absname)->size - 1]) 2028 && IS_DIRECTORY_SEP (XSTRING (absname)->data[XSTRING (absname)->size_byte - 1])
2033 && !IS_DEVICE_SEP (XSTRING (absname)->data[XSTRING (absname)->size-2])) 2029 && !IS_DEVICE_SEP (XSTRING (absname)->data[XSTRING (absname)->size_byte-2]))
2034 /* We cannot take shortcuts; they might be wrong for magic file names. */ 2030 /* We cannot take shortcuts; they might be wrong for magic file names. */
2035 absname = Fdirectory_file_name (absname); 2031 absname = Fdirectory_file_name (absname);
2036#endif 2032#endif
@@ -2881,7 +2877,8 @@ Otherwise returns nil.")
2881 } 2877 }
2882 val = make_string (buf, valsize); 2878 val = make_string (buf, valsize);
2883 xfree (buf); 2879 xfree (buf);
2884 return Fdecode_coding_string (val, Vfile_name_coding_system, Qt); 2880 val = DECODE_FILE (val);
2881 return val;
2885#else /* not S_IFLNK */ 2882#else /* not S_IFLNK */
2886 return Qnil; 2883 return Qnil;
2887#endif /* not S_IFLNK */ 2884#endif /* not S_IFLNK */
@@ -4790,11 +4787,11 @@ A non-nil CURRENT-ONLY argument means save only current buffer.")
4790 if (!NILP (b->filename)) 4787 if (!NILP (b->filename))
4791 { 4788 {
4792 fwrite (XSTRING (b->filename)->data, 1, 4789 fwrite (XSTRING (b->filename)->data, 1,
4793 XSTRING (b->filename)->size, stream); 4790 XSTRING (b->filename)->size_byte, stream);
4794 } 4791 }
4795 putc ('\n', stream); 4792 putc ('\n', stream);
4796 fwrite (XSTRING (b->auto_save_file_name)->data, 1, 4793 fwrite (XSTRING (b->auto_save_file_name)->data, 1,
4797 XSTRING (b->auto_save_file_name)->size, stream); 4794 XSTRING (b->auto_save_file_name)->size_byte, stream);
4798 putc ('\n', stream); 4795 putc ('\n', stream);
4799 } 4796 }
4800 4797
@@ -5069,7 +5066,7 @@ DIR defaults to current buffer's directory default.")
5069 && IS_DIRECTORY_SEP (XSTRING (dir)->data[strlen (homedir)])) 5066 && IS_DIRECTORY_SEP (XSTRING (dir)->data[strlen (homedir)]))
5070 { 5067 {
5071 dir = make_string (XSTRING (dir)->data + strlen (homedir) - 1, 5068 dir = make_string (XSTRING (dir)->data + strlen (homedir) - 1,
5072 XSTRING (dir)->size - strlen (homedir) + 1); 5069 XSTRING (dir)->size_byte - strlen (homedir) + 1);
5073 XSTRING (dir)->data[0] = '~'; 5070 XSTRING (dir)->data[0] = '~';
5074 } 5071 }
5075 5072
@@ -5244,9 +5241,21 @@ syms_of_fileio ()
5244#endif /* DOS_NT */ 5241#endif /* DOS_NT */
5245 5242
5246 DEFVAR_LISP ("file-name-coding-system", &Vfile_name_coding_system, 5243 DEFVAR_LISP ("file-name-coding-system", &Vfile_name_coding_system,
5247 "*Coding system for encoding file names."); 5244 "*Coding system for encoding file names.\n\
5245If it is nil, default-file-name-coding-system (which see) is used.");
5248 Vfile_name_coding_system = Qnil; 5246 Vfile_name_coding_system = Qnil;
5249 5247
5248 DEFVAR_LISP ("default-file-name-coding-system",
5249 &Vdefault_file_name_coding_system,
5250 "Default coding system for encoding file names.\n\
5251This variable is used only when file-name-coding-system is nil.\n\
5252\n\
5253This variable is set/changed by the command set-language-environment.\n\
5254User should not set this variable manually,\n\
5255instead use file-name-coding-system to get a constant encoding\n\
5256of file names regardless of the current language environment.");
5257 Vdefault_file_name_coding_system = Qnil;
5258
5250 DEFVAR_LISP ("auto-save-file-format", &Vauto_save_file_format, 5259 DEFVAR_LISP ("auto-save-file-format", &Vauto_save_file_format,
5251 "*Format in which to write auto-save files.\n\ 5260 "*Format in which to write auto-save files.\n\
5252Should be a list of symbols naming formats that are defined in `format-alist'.\n\ 5261Should be a list of symbols naming formats that are defined in `format-alist'.\n\