comparison src/fileio.c @ 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 62392796a691
children 72bee09fc541
comparison
equal deleted inserted replaced
9954:18b408b05189 9955:dfb5d7e86733
223 Lisp_Object Qfile_newer_than_file_p; 223 Lisp_Object Qfile_newer_than_file_p;
224 Lisp_Object Qinsert_file_contents; 224 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\
231 Otherwise, return nil.\n\ 232 Otherwise, return nil.\n\
232 A file name is handled if one of the regular expressions in\n\ 233 A file name is handled if one of the regular expressions in\n\
1553 register unsigned char *s, *p, *o, *x, *endp; 1554 register unsigned char *s, *p, *o, *x, *endp;
1554 unsigned char *target; 1555 unsigned char *target;
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);
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);
1560 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));
1564 substituted = !strcmp (nm, XSTRING (string)->data); 1572 substituted = !strcmp (nm, XSTRING (string)->data);
3933 /* action is nil for complete, t for return list of completions, 3941 /* action is nil for complete, t for return list of completions,
3934 lambda for verify final value */ 3942 lambda for verify final value */
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;
3942 orig_string = Qnil; 3950 orig_string = Qnil;
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 {
3950 if (EQ (action, Qlambda)) 3958 if (EQ (action, Qlambda))
3951 { 3959 {
4181 Qfile_newer_than_file_p = intern ("file-newer-than-file-p"); 4189 Qfile_newer_than_file_p = intern ("file-newer-than-file-p");
4182 Qinsert_file_contents = intern ("insert-file-contents"); 4190 Qinsert_file_contents = intern ("insert-file-contents");
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);
4189 staticpro (&Qfile_name_directory); 4198 staticpro (&Qfile_name_directory);
4190 staticpro (&Qfile_name_nondirectory); 4199 staticpro (&Qfile_name_nondirectory);
4208 staticpro (&Qset_file_modes); 4217 staticpro (&Qset_file_modes);
4209 staticpro (&Qfile_newer_than_file_p); 4218 staticpro (&Qfile_newer_than_file_p);
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);
4216 staticpro (&Qfile_name_history); 4226 staticpro (&Qfile_name_history);
4217 4227