diff src/emacs.c @ 16386:e7e295c6add2

(decode_env_path): Add /: to dir names that could be magic. (init_cmdargs): Add /: to argv[0] if it could be magic.
author Richard M. Stallman <rms@gnu.org>
date Fri, 04 Oct 1996 05:08:44 +0000
parents 37408c6b96fd
children 65c729d461c3
line wrap: on
line diff
--- a/src/emacs.c	Fri Oct 04 04:43:42 1996 +0000
+++ b/src/emacs.c	Fri Oct 04 05:08:44 1996 +0000
@@ -91,6 +91,8 @@
    for use when reporting bugs.  */
 Lisp_Object Vsystem_configuration_options;
 
+Lisp_Object Qfile_name_handler_alist;
+
 /* If non-zero, emacs should not attempt to use an window-specific code,
    but instead should use the virtual terminal under which it was started */
 int inhibit_window_system;
@@ -210,13 +212,24 @@
      int skip_args;
 {
   register int i;
-  Lisp_Object name, dir;
+  Lisp_Object name, dir, tem;
+  int count = specpdl_ptr - specpdl;
+  Lisp_Object raw_name;
 
   initial_argv = argv;
   initial_argc = argc;
 
-  Vinvocation_name = Ffile_name_nondirectory (build_string (argv[0]));
-  Vinvocation_directory = Ffile_name_directory (build_string (argv[0]));
+  raw_name = build_string (argv[0]);
+
+  /* Add /: to the front of the name
+     if it would otherwise be treated as magic.  */
+  tem = Ffind_file_name_handler (raw_name, Qt);
+  if (! NILP (tem))
+    raw_name = concat2 (build_string ("/:"), raw_name);
+
+  Vinvocation_name = Ffile_name_nondirectory (raw_name);
+  Vinvocation_directory = Ffile_name_directory (raw_name);
+
   /* If we got no directory in argv[0], search PATH to find where
      Emacs actually came from.  */
   if (NILP (Vinvocation_directory))
@@ -225,12 +238,20 @@
       int yes = openp (Vexec_path, Vinvocation_name,
 		       EXEC_SUFFIXES, &found, 1);
       if (yes == 1)
-	Vinvocation_directory = Ffile_name_directory (found);
+	{
+	  /* Add /: to the front of the name
+	     if it would otherwise be treated as magic.  */
+	  tem = Ffind_file_name_handler (found, Qt);
+	  if (! NILP (tem))
+	    found = concat2 (build_string ("/:"), found);
+	  Vinvocation_directory = Ffile_name_directory (found);
+	}
     }
 
   if (!NILP (Vinvocation_directory)
       && NILP (Ffile_name_absolute_p (Vinvocation_directory)))
-    /* Emacs was started with relative path, like ./emacs  */
+    /* Emacs was started with relative path, like ./emacs.
+       Make it absolute.  */
     Vinvocation_directory = Fexpand_file_name (Vinvocation_directory, Qnil);
 
   Vinstallation_directory = Qnil;
@@ -298,6 +319,8 @@
 	Vcommand_line_args
 	  = Fcons (build_string (argv[i]), Vcommand_line_args);
     }
+
+  unbind_to (count, Qnil);
 }
 
 DEFUN ("invocation-name", Finvocation_name, Sinvocation_name, 0, 0, 0,
@@ -1466,8 +1489,7 @@
      char *evarname, *defalt;
 {
   register char *path, *p;
-
-  Lisp_Object lpath;
+  Lisp_Object lpath, element, tem;
 
   /* It's okay to use getenv here, because this function is only used
      to initialize variables when Emacs starts up, and isn't called
@@ -1483,9 +1505,16 @@
     {
       p = index (path, SEPCHAR);
       if (!p) p = path + strlen (path);
-      lpath = Fcons (p - path ? make_string (path, p - path)
-		     : build_string ("."),
-		     lpath);
+      element = (p - path ? make_string (path, p - path)
+		 : build_string ("."));
+
+      /* Add /: to the front of the name
+	 if it would otherwise be treated as magic.  */
+      tem = Ffind_file_name_handler (element, Qt);
+      if (! NILP (tem))
+	element = concat2 (build_string ("/:"), element);
+
+      lpath = Fcons (element, lpath);
       if (*p)
 	path = p + 1;
       else
@@ -1496,6 +1525,9 @@
 
 syms_of_emacs ()
 {
+  Qfile_name_handler_alist = intern ("file-name-handler-alist");
+  staticpro (&Qfile_name_handler_alist);
+
 #ifndef CANNOT_DUMP
 #ifdef HAVE_SHM
   defsubr (&Sdump_emacs_data);