Mercurial > emacs
changeset 7821:f96225d8c3eb
(init_environment): Clean up code and make the default
EMACSPATH equal to the directory from which Emacs was started.
(emacsroot): New variable.
(rootrelativepath): New function.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 07 Jun 1994 15:24:57 +0000 |
parents | 128950f29e66 |
children | 17b96e349369 |
files | src/msdos.c |
diffstat | 1 files changed, 36 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/src/msdos.c Tue Jun 07 15:19:33 1994 +0000 +++ b/src/msdos.c Tue Jun 07 15:24:57 1994 +0000 @@ -657,6 +657,21 @@ while (clnow < clthen); } +/* The Emacs root directory as determined by init_environment. */ +static char emacsroot[MAXPATHLEN]; + +char * +rootrelativepath (rel) + char *rel; +{ + static char result[MAXPATHLEN + 10]; + + strcpy (result, emacsroot); + strcat (result, "/"); + strcat (result, rel); + return result; +} + /* Define a lot of environment variables if not already defined. Don't remove anything unless you know what you're doing -- lots of code will break if one or more of these are missing. */ @@ -666,32 +681,30 @@ char **argv; int skip_args; { - char *s, *t; + char *s, *t, *root; + int len; - /* We default HOME to the directory from which Emacs was started, but with - a "/bin" suffix removed. */ - s = argv[0]; - t = alloca (strlen (s) + 1); - strcpy (t, s); - s = t + strlen (t); - while (s != t && *s != '/' && *s != ':') s--; - if (s == t) - t = "c:/emacs"; /* When run under debug32. */ + /* Find our root from argv[0]. Assuming argv[0] is, say, + "c:/emacs/bin/emacs.exe" our root will be "c:/emacs". */ + len = strlen (argv[0]); + root = alloca (len + 10); /* A little extra space for the stuff below. */ + strcpy (root, argv[0]); + while (len > 0 && root[len] != '/' && root[len] != ':') + len--; + root[len] = '\0'; + if (len > 4 && strcmp (root + len - 4, "/bin") == 0) + root[len - 4] = '\0'; else - { - if (*s == ':') s++; - *s = 0; - if (s - 4 >= t && strcmp (s - 4, "/bin") == 0) - s[strlen (s) - 4] = 0; - } - setenv ("HOME", t, 0); + strcpy (root, "c:/emacs"); /* Only under debuggers, I think. */ + len = strlen (root); + strcpy (emacsroot, root); - /* We set EMACSPATH to ~/bin (expanded) */ - s = getenv ("HOME"); - t = strcpy (alloca (strlen (s) + 6), s); - if (s[strlen (s) - 1] != '/') strcat (t, "/"); - strcat (t, "bin"); - setenv ("EMACSPATH", t, 0); + /* We default HOME to our root. */ + setenv ("HOME", root, 0); + + /* We default EMACSPATH to root + "/bin". */ + strcpy (root + len, "/bin"); + setenv ("EMACSPATH", root, 0); /* I don't expect anybody to ever use other terminals so the internal terminal is the default. */