changeset 9955:dfb5d7e86733

(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.
author Richard M. Stallman <rms@gnu.org>
date Wed, 16 Nov 1994 00:52:35 +0000
parents 18b408b05189
children cc76b76a1ed1
files src/fileio.c
diffstat 1 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/fileio.c	Wed Nov 16 00:42:11 1994 +0000
+++ b/src/fileio.c	Wed Nov 16 00:52:35 1994 +0000
@@ -225,6 +225,7 @@
 Lisp_Object Qwrite_region;
 Lisp_Object Qverify_visited_file_modtime;
 Lisp_Object Qset_visited_file_modtime;
+Lisp_Object Qsubstitute_in_file_name;
 
 DEFUN ("find-file-name-handler", Ffind_file_name_handler, Sfind_file_name_handler, 2, 2, 0,
   "Return FILENAME's handler function for OPERATION, if it has one.\n\
@@ -1555,9 +1556,16 @@
   int total = 0;
   int substituted = 0;
   unsigned char *xnm;
+  Lisp_Object handler;
 
   CHECK_STRING (string, 0);
 
+  /* If the file name has special constructs in it,
+     call the corresponding file handler.  */
+  handler = Ffind_file_name_handler (string, Qsubstitute_in_file_name);
+  if (!NILP (handler))
+    return call2 (handler, Qsubstitute_in_file_name, string);
+
   nm = XSTRING (string)->data;
 #ifdef MSDOS
   dostounix_filename (nm = strcpy (alloca (strlen (nm) + 1), nm));
@@ -3935,7 +3943,7 @@
 {
   Lisp_Object name, specdir, realdir, val, orig_string;
   int changed;
-  struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
+  struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
 
   realdir = dir;
   name = string;
@@ -3943,7 +3951,7 @@
   specdir = Qnil;
   changed = 0;
   /* No need to protect ACTION--we only compare it with t and nil.  */
-  GCPRO4 (string, realdir, name, specdir);
+  GCPRO5 (string, realdir, name, specdir, orig_string);
 
   if (XSTRING (string)->size == 0)
     {
@@ -4183,6 +4191,7 @@
   Qwrite_region = intern ("write-region");
   Qverify_visited_file_modtime = intern ("verify-visited-file-modtime");
   Qset_visited_file_modtime = intern ("set-visited-file-modtime");
+  Qsubstitute_in_file_name = intern ("substitute-in-file-name");
 
   staticpro (&Qexpand_file_name);
   staticpro (&Qdirectory_file_name);
@@ -4210,6 +4219,7 @@
   staticpro (&Qinsert_file_contents);
   staticpro (&Qwrite_region);
   staticpro (&Qverify_visited_file_modtime);
+  staticpro (&Qsubstitute_in_file_name);
 
   Qfile_name_history = intern ("file-name-history");
   Fset (Qfile_name_history, Qnil);