diff options
| author | Richard M. Stallman | 1994-11-16 00:52:35 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1994-11-16 00:52:35 +0000 |
| commit | 8ce069f595ee3393fdeef248572039a66cc11d64 (patch) | |
| tree | edb0b59b1fab1a82e135bab197100b549a564df7 /src | |
| parent | c80bd143cf695be5272821ef623527abcd88ea5d (diff) | |
| download | emacs-8ce069f595ee3393fdeef248572039a66cc11d64.tar.gz emacs-8ce069f595ee3393fdeef248572039a66cc11d64.zip | |
(Fread_file_name_internal): Protect orig_string.
(Fsubstitute_in_file_name): Run a handler.
(Qsubstitute_in_file_name): New variable.
(syms_of_fileio): Set it up.
Diffstat (limited to 'src')
| -rw-r--r-- | src/fileio.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/fileio.c b/src/fileio.c index 317fd1b23e7..9772e4c5030 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -225,6 +225,7 @@ Lisp_Object Qinsert_file_contents; | |||
| 225 | Lisp_Object Qwrite_region; | 225 | Lisp_Object Qwrite_region; |
| 226 | Lisp_Object Qverify_visited_file_modtime; | 226 | Lisp_Object Qverify_visited_file_modtime; |
| 227 | Lisp_Object Qset_visited_file_modtime; | 227 | Lisp_Object Qset_visited_file_modtime; |
| 228 | Lisp_Object Qsubstitute_in_file_name; | ||
| 228 | 229 | ||
| 229 | DEFUN ("find-file-name-handler", Ffind_file_name_handler, Sfind_file_name_handler, 2, 2, 0, | 230 | DEFUN ("find-file-name-handler", Ffind_file_name_handler, Sfind_file_name_handler, 2, 2, 0, |
| 230 | "Return FILENAME's handler function for OPERATION, if it has one.\n\ | 231 | "Return FILENAME's handler function for OPERATION, if it has one.\n\ |
| @@ -1555,9 +1556,16 @@ duplicates what `expand-file-name' does.") | |||
| 1555 | int total = 0; | 1556 | int total = 0; |
| 1556 | int substituted = 0; | 1557 | int substituted = 0; |
| 1557 | unsigned char *xnm; | 1558 | unsigned char *xnm; |
| 1559 | Lisp_Object handler; | ||
| 1558 | 1560 | ||
| 1559 | CHECK_STRING (string, 0); | 1561 | CHECK_STRING (string, 0); |
| 1560 | 1562 | ||
| 1563 | /* If the file name has special constructs in it, | ||
| 1564 | call the corresponding file handler. */ | ||
| 1565 | handler = Ffind_file_name_handler (string, Qsubstitute_in_file_name); | ||
| 1566 | if (!NILP (handler)) | ||
| 1567 | return call2 (handler, Qsubstitute_in_file_name, string); | ||
| 1568 | |||
| 1561 | nm = XSTRING (string)->data; | 1569 | nm = XSTRING (string)->data; |
| 1562 | #ifdef MSDOS | 1570 | #ifdef MSDOS |
| 1563 | dostounix_filename (nm = strcpy (alloca (strlen (nm) + 1), nm)); | 1571 | dostounix_filename (nm = strcpy (alloca (strlen (nm) + 1), nm)); |
| @@ -3935,7 +3943,7 @@ DEFUN ("read-file-name-internal", Fread_file_name_internal, Sread_file_name_inte | |||
| 3935 | { | 3943 | { |
| 3936 | Lisp_Object name, specdir, realdir, val, orig_string; | 3944 | Lisp_Object name, specdir, realdir, val, orig_string; |
| 3937 | int changed; | 3945 | int changed; |
| 3938 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; | 3946 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; |
| 3939 | 3947 | ||
| 3940 | realdir = dir; | 3948 | realdir = dir; |
| 3941 | name = string; | 3949 | name = string; |
| @@ -3943,7 +3951,7 @@ DEFUN ("read-file-name-internal", Fread_file_name_internal, Sread_file_name_inte | |||
| 3943 | specdir = Qnil; | 3951 | specdir = Qnil; |
| 3944 | changed = 0; | 3952 | changed = 0; |
| 3945 | /* No need to protect ACTION--we only compare it with t and nil. */ | 3953 | /* No need to protect ACTION--we only compare it with t and nil. */ |
| 3946 | GCPRO4 (string, realdir, name, specdir); | 3954 | GCPRO5 (string, realdir, name, specdir, orig_string); |
| 3947 | 3955 | ||
| 3948 | if (XSTRING (string)->size == 0) | 3956 | if (XSTRING (string)->size == 0) |
| 3949 | { | 3957 | { |
| @@ -4183,6 +4191,7 @@ syms_of_fileio () | |||
| 4183 | Qwrite_region = intern ("write-region"); | 4191 | Qwrite_region = intern ("write-region"); |
| 4184 | Qverify_visited_file_modtime = intern ("verify-visited-file-modtime"); | 4192 | Qverify_visited_file_modtime = intern ("verify-visited-file-modtime"); |
| 4185 | Qset_visited_file_modtime = intern ("set-visited-file-modtime"); | 4193 | Qset_visited_file_modtime = intern ("set-visited-file-modtime"); |
| 4194 | Qsubstitute_in_file_name = intern ("substitute-in-file-name"); | ||
| 4186 | 4195 | ||
| 4187 | staticpro (&Qexpand_file_name); | 4196 | staticpro (&Qexpand_file_name); |
| 4188 | staticpro (&Qdirectory_file_name); | 4197 | staticpro (&Qdirectory_file_name); |
| @@ -4210,6 +4219,7 @@ syms_of_fileio () | |||
| 4210 | staticpro (&Qinsert_file_contents); | 4219 | staticpro (&Qinsert_file_contents); |
| 4211 | staticpro (&Qwrite_region); | 4220 | staticpro (&Qwrite_region); |
| 4212 | staticpro (&Qverify_visited_file_modtime); | 4221 | staticpro (&Qverify_visited_file_modtime); |
| 4222 | staticpro (&Qsubstitute_in_file_name); | ||
| 4213 | 4223 | ||
| 4214 | Qfile_name_history = intern ("file-name-history"); | 4224 | Qfile_name_history = intern ("file-name-history"); |
| 4215 | Fset (Qfile_name_history, Qnil); | 4225 | Fset (Qfile_name_history, Qnil); |