Commit 213d0b1f authored by Richard M. Stallman's avatar Richard M. Stallman

(decode_env_path): Add /: to dir names that could be magic.

(init_cmdargs): Add /: to argv[0] if it could be magic.
parent 477c388f
...@@ -91,6 +91,8 @@ Lisp_Object Vsystem_configuration; ...@@ -91,6 +91,8 @@ Lisp_Object Vsystem_configuration;
for use when reporting bugs. */ for use when reporting bugs. */
Lisp_Object Vsystem_configuration_options; Lisp_Object Vsystem_configuration_options;
Lisp_Object Qfile_name_handler_alist;
/* If non-zero, emacs should not attempt to use an window-specific code, /* 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 */ but instead should use the virtual terminal under which it was started */
int inhibit_window_system; int inhibit_window_system;
...@@ -210,13 +212,24 @@ init_cmdargs (argc, argv, skip_args) ...@@ -210,13 +212,24 @@ init_cmdargs (argc, argv, skip_args)
int skip_args; int skip_args;
{ {
register int i; 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_argv = argv;
initial_argc = argc; initial_argc = argc;
Vinvocation_name = Ffile_name_nondirectory (build_string (argv[0])); raw_name = build_string (argv[0]);
Vinvocation_directory = Ffile_name_directory (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 /* If we got no directory in argv[0], search PATH to find where
Emacs actually came from. */ Emacs actually came from. */
if (NILP (Vinvocation_directory)) if (NILP (Vinvocation_directory))
...@@ -225,12 +238,20 @@ init_cmdargs (argc, argv, skip_args) ...@@ -225,12 +238,20 @@ init_cmdargs (argc, argv, skip_args)
int yes = openp (Vexec_path, Vinvocation_name, int yes = openp (Vexec_path, Vinvocation_name,
EXEC_SUFFIXES, &found, 1); EXEC_SUFFIXES, &found, 1);
if (yes == 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) if (!NILP (Vinvocation_directory)
&& NILP (Ffile_name_absolute_p (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); Vinvocation_directory = Fexpand_file_name (Vinvocation_directory, Qnil);
Vinstallation_directory = Qnil; Vinstallation_directory = Qnil;
...@@ -298,6 +319,8 @@ init_cmdargs (argc, argv, skip_args) ...@@ -298,6 +319,8 @@ init_cmdargs (argc, argv, skip_args)
Vcommand_line_args Vcommand_line_args
= Fcons (build_string (argv[i]), 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, DEFUN ("invocation-name", Finvocation_name, Sinvocation_name, 0, 0, 0,
...@@ -1466,8 +1489,7 @@ decode_env_path (evarname, defalt) ...@@ -1466,8 +1489,7 @@ decode_env_path (evarname, defalt)
char *evarname, *defalt; char *evarname, *defalt;
{ {
register char *path, *p; register char *path, *p;
Lisp_Object lpath, element, tem;
Lisp_Object lpath;
/* It's okay to use getenv here, because this function is only used /* It's okay to use getenv here, because this function is only used
to initialize variables when Emacs starts up, and isn't called to initialize variables when Emacs starts up, and isn't called
...@@ -1483,9 +1505,16 @@ decode_env_path (evarname, defalt) ...@@ -1483,9 +1505,16 @@ decode_env_path (evarname, defalt)
{ {
p = index (path, SEPCHAR); p = index (path, SEPCHAR);
if (!p) p = path + strlen (path); if (!p) p = path + strlen (path);
lpath = Fcons (p - path ? make_string (path, p - path) element = (p - path ? make_string (path, p - path)
: build_string ("."), : build_string ("."));
lpath);
/* 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) if (*p)
path = p + 1; path = p + 1;
else else
...@@ -1496,6 +1525,9 @@ decode_env_path (evarname, defalt) ...@@ -1496,6 +1525,9 @@ decode_env_path (evarname, defalt)
syms_of_emacs () syms_of_emacs ()
{ {
Qfile_name_handler_alist = intern ("file-name-handler-alist");
staticpro (&Qfile_name_handler_alist);
#ifndef CANNOT_DUMP #ifndef CANNOT_DUMP
#ifdef HAVE_SHM #ifdef HAVE_SHM
defsubr (&Sdump_emacs_data); defsubr (&Sdump_emacs_data);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment