comparison 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
comparison
equal deleted inserted replaced
16385:2b768a1e4f5f 16386:e7e295c6add2
88 Lisp_Object Vsystem_configuration; 88 Lisp_Object Vsystem_configuration;
89 89
90 /* Variable whose value is string giving configuration options, 90 /* Variable whose value is string giving configuration options,
91 for use when reporting bugs. */ 91 for use when reporting bugs. */
92 Lisp_Object Vsystem_configuration_options; 92 Lisp_Object Vsystem_configuration_options;
93
94 Lisp_Object Qfile_name_handler_alist;
93 95
94 /* If non-zero, emacs should not attempt to use an window-specific code, 96 /* If non-zero, emacs should not attempt to use an window-specific code,
95 but instead should use the virtual terminal under which it was started */ 97 but instead should use the virtual terminal under which it was started */
96 int inhibit_window_system; 98 int inhibit_window_system;
97 99
208 int argc; 210 int argc;
209 char **argv; 211 char **argv;
210 int skip_args; 212 int skip_args;
211 { 213 {
212 register int i; 214 register int i;
213 Lisp_Object name, dir; 215 Lisp_Object name, dir, tem;
216 int count = specpdl_ptr - specpdl;
217 Lisp_Object raw_name;
214 218
215 initial_argv = argv; 219 initial_argv = argv;
216 initial_argc = argc; 220 initial_argc = argc;
217 221
218 Vinvocation_name = Ffile_name_nondirectory (build_string (argv[0])); 222 raw_name = build_string (argv[0]);
219 Vinvocation_directory = Ffile_name_directory (build_string (argv[0])); 223
224 /* Add /: to the front of the name
225 if it would otherwise be treated as magic. */
226 tem = Ffind_file_name_handler (raw_name, Qt);
227 if (! NILP (tem))
228 raw_name = concat2 (build_string ("/:"), raw_name);
229
230 Vinvocation_name = Ffile_name_nondirectory (raw_name);
231 Vinvocation_directory = Ffile_name_directory (raw_name);
232
220 /* If we got no directory in argv[0], search PATH to find where 233 /* If we got no directory in argv[0], search PATH to find where
221 Emacs actually came from. */ 234 Emacs actually came from. */
222 if (NILP (Vinvocation_directory)) 235 if (NILP (Vinvocation_directory))
223 { 236 {
224 Lisp_Object found; 237 Lisp_Object found;
225 int yes = openp (Vexec_path, Vinvocation_name, 238 int yes = openp (Vexec_path, Vinvocation_name,
226 EXEC_SUFFIXES, &found, 1); 239 EXEC_SUFFIXES, &found, 1);
227 if (yes == 1) 240 if (yes == 1)
228 Vinvocation_directory = Ffile_name_directory (found); 241 {
242 /* Add /: to the front of the name
243 if it would otherwise be treated as magic. */
244 tem = Ffind_file_name_handler (found, Qt);
245 if (! NILP (tem))
246 found = concat2 (build_string ("/:"), found);
247 Vinvocation_directory = Ffile_name_directory (found);
248 }
229 } 249 }
230 250
231 if (!NILP (Vinvocation_directory) 251 if (!NILP (Vinvocation_directory)
232 && NILP (Ffile_name_absolute_p (Vinvocation_directory))) 252 && NILP (Ffile_name_absolute_p (Vinvocation_directory)))
233 /* Emacs was started with relative path, like ./emacs */ 253 /* Emacs was started with relative path, like ./emacs.
254 Make it absolute. */
234 Vinvocation_directory = Fexpand_file_name (Vinvocation_directory, Qnil); 255 Vinvocation_directory = Fexpand_file_name (Vinvocation_directory, Qnil);
235 256
236 Vinstallation_directory = Qnil; 257 Vinstallation_directory = Qnil;
237 258
238 if (!NILP (Vinvocation_directory)) 259 if (!NILP (Vinvocation_directory))
296 { 317 {
297 if (i == 0 || i > skip_args) 318 if (i == 0 || i > skip_args)
298 Vcommand_line_args 319 Vcommand_line_args
299 = Fcons (build_string (argv[i]), Vcommand_line_args); 320 = Fcons (build_string (argv[i]), Vcommand_line_args);
300 } 321 }
322
323 unbind_to (count, Qnil);
301 } 324 }
302 325
303 DEFUN ("invocation-name", Finvocation_name, Sinvocation_name, 0, 0, 0, 326 DEFUN ("invocation-name", Finvocation_name, Sinvocation_name, 0, 0, 0,
304 "Return the program name that was used to run Emacs.\n\ 327 "Return the program name that was used to run Emacs.\n\
305 Any directory names are omitted.") 328 Any directory names are omitted.")
1464 Lisp_Object 1487 Lisp_Object
1465 decode_env_path (evarname, defalt) 1488 decode_env_path (evarname, defalt)
1466 char *evarname, *defalt; 1489 char *evarname, *defalt;
1467 { 1490 {
1468 register char *path, *p; 1491 register char *path, *p;
1469 1492 Lisp_Object lpath, element, tem;
1470 Lisp_Object lpath;
1471 1493
1472 /* It's okay to use getenv here, because this function is only used 1494 /* It's okay to use getenv here, because this function is only used
1473 to initialize variables when Emacs starts up, and isn't called 1495 to initialize variables when Emacs starts up, and isn't called
1474 after that. */ 1496 after that. */
1475 if (evarname != 0) 1497 if (evarname != 0)
1481 lpath = Qnil; 1503 lpath = Qnil;
1482 while (1) 1504 while (1)
1483 { 1505 {
1484 p = index (path, SEPCHAR); 1506 p = index (path, SEPCHAR);
1485 if (!p) p = path + strlen (path); 1507 if (!p) p = path + strlen (path);
1486 lpath = Fcons (p - path ? make_string (path, p - path) 1508 element = (p - path ? make_string (path, p - path)
1487 : build_string ("."), 1509 : build_string ("."));
1488 lpath); 1510
1511 /* Add /: to the front of the name
1512 if it would otherwise be treated as magic. */
1513 tem = Ffind_file_name_handler (element, Qt);
1514 if (! NILP (tem))
1515 element = concat2 (build_string ("/:"), element);
1516
1517 lpath = Fcons (element, lpath);
1489 if (*p) 1518 if (*p)
1490 path = p + 1; 1519 path = p + 1;
1491 else 1520 else
1492 break; 1521 break;
1493 } 1522 }
1494 return Fnreverse (lpath); 1523 return Fnreverse (lpath);
1495 } 1524 }
1496 1525
1497 syms_of_emacs () 1526 syms_of_emacs ()
1498 { 1527 {
1528 Qfile_name_handler_alist = intern ("file-name-handler-alist");
1529 staticpro (&Qfile_name_handler_alist);
1530
1499 #ifndef CANNOT_DUMP 1531 #ifndef CANNOT_DUMP
1500 #ifdef HAVE_SHM 1532 #ifdef HAVE_SHM
1501 defsubr (&Sdump_emacs_data); 1533 defsubr (&Sdump_emacs_data);
1502 #else 1534 #else
1503 defsubr (&Sdump_emacs); 1535 defsubr (&Sdump_emacs);