Mercurial > hg > xemacs-beta
diff src/emacs.c @ 233:52952cbfc5b5 r20-5b15
Import from CVS: tag r20-5b15
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:14:14 +0200 |
parents | 557eaa0339bf |
children | 85a06df23a9a |
line wrap: on
line diff
--- a/src/emacs.c Mon Aug 13 10:13:49 2007 +0200 +++ b/src/emacs.c Mon Aug 13 10:14:14 2007 +0200 @@ -460,7 +460,7 @@ #define main_1 STACK_TRACE_EYE_CATCHER static DOESNT_RETURN -main_1 (int argc, char **argv, char **envp) +main_1 (int argc, char **argv, char **envp, int restart) { char stack_bottom_variable; int skip_args = 0; @@ -1438,8 +1438,14 @@ init_console_stream (); /* Create the first console */ /* try to get the actual pathname of the exec file we are running */ + if (!restart) { Vinvocation_name = Fcar (Vcommand_line_args); + if (XSTRING_DATA(Vinvocation_name)[0] == '-') + { + /* XEmacs as a login shell, oh goody! */ + Vinvocation_name = build_string(getenv("SHELL")); + } Vinvocation_directory = Vinvocation_name; if (!NILP (Ffile_name_directory (Vinvocation_name))) @@ -1796,6 +1802,29 @@ int volatile vol_argc = argc; char ** volatile vol_argv = argv; char ** volatile vol_envp = envp; + /* This is hairy. We need to compute where the XEmacs binary was invoked */ + /* from because temacs initialization requires it to find the lisp */ + /* directories. The code that recomputes the path is guarded by the */ + /* restarted flag. There are three possible paths I've found so far */ + /* through this: */ + /* temacs -- When running temacs for basic build stuff, the first main_1 */ + /* will be the only one invoked. It must compute the path else there */ + /* will be a very ugly bomb in startup.el (can't find obvious location */ + /* for doc-directory data-directory, etc.). */ + /* temacs w/ run-temacs on the command line -- This is run to bytecompile */ + /* all the out of date dumped lisp. It will execute both of the main_1 */ + /* calls and the second one must not touch the first computation because */ + /* argc/argv are hosed the second time through. */ + /* xemacs -- Only the second main_1 is executed. The invocation path must */ + /* computed but this only matters when running in place or when running */ + /* as a login shell. */ + /* As a bonus for straightening this out, XEmacs can now be run in place */ + /* as a login shell. This never used to work. */ + /* As another bonus, we can now guarantee that */ + /* (concat invocation-directory invocation-name) contains the filename */ + /* of the XEmacs binary we are running. This can now be used in a */ + /* definite test for out of date dumped files. -slb */ + int restarted = 0; #ifdef QUANTIFY quantify_stop_recording_data (); quantify_clear_data (); @@ -1811,8 +1840,11 @@ { run_temacs_argc = 0; if (! SETJMP (run_temacs_catch)) - main_1 (vol_argc, vol_argv, vol_envp); + { + main_1 (vol_argc, vol_argv, vol_envp, 0); + } /* run-emacs-from-temacs called */ + restarted = 1; vol_argc = run_temacs_argc; vol_argv = run_temacs_argv; #ifdef _SCO_DS @@ -1839,7 +1871,7 @@ } run_temacs_argc = -1; - main_1 (vol_argc, vol_argv, vol_envp); + main_1 (vol_argc, vol_argv, vol_envp, restarted); return 0; /* unreached */ }