aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/msdos.c63
1 files changed, 38 insertions, 25 deletions
diff --git a/src/msdos.c b/src/msdos.c
index fd9ae23efee..0b738c4a050 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -657,6 +657,21 @@ sleep_or_kbd_hit (secs, kbdok)
657 while (clnow < clthen); 657 while (clnow < clthen);
658} 658}
659 659
660/* The Emacs root directory as determined by init_environment. */
661static char emacsroot[MAXPATHLEN];
662
663char *
664rootrelativepath (rel)
665 char *rel;
666{
667 static char result[MAXPATHLEN + 10];
668
669 strcpy (result, emacsroot);
670 strcat (result, "/");
671 strcat (result, rel);
672 return result;
673}
674
660/* Define a lot of environment variables if not already defined. Don't 675/* Define a lot of environment variables if not already defined. Don't
661 remove anything unless you know what you're doing -- lots of code will 676 remove anything unless you know what you're doing -- lots of code will
662 break if one or more of these are missing. */ 677 break if one or more of these are missing. */
@@ -666,32 +681,30 @@ init_environment (argc, argv, skip_args)
666 char **argv; 681 char **argv;
667 int skip_args; 682 int skip_args;
668{ 683{
669 char *s, *t; 684 char *s, *t, *root;
670 685 int len;
671 /* We default HOME to the directory from which Emacs was started, but with 686
672 a "/bin" suffix removed. */ 687 /* Find our root from argv[0]. Assuming argv[0] is, say,
673 s = argv[0]; 688 "c:/emacs/bin/emacs.exe" our root will be "c:/emacs". */
674 t = alloca (strlen (s) + 1); 689 len = strlen (argv[0]);
675 strcpy (t, s); 690 root = alloca (len + 10); /* A little extra space for the stuff below. */
676 s = t + strlen (t); 691 strcpy (root, argv[0]);
677 while (s != t && *s != '/' && *s != ':') s--; 692 while (len > 0 && root[len] != '/' && root[len] != ':')
678 if (s == t) 693 len--;
679 t = "c:/emacs"; /* When run under debug32. */ 694 root[len] = '\0';
695 if (len > 4 && strcmp (root + len - 4, "/bin") == 0)
696 root[len - 4] = '\0';
680 else 697 else
681 { 698 strcpy (root, "c:/emacs"); /* Only under debuggers, I think. */
682 if (*s == ':') s++; 699 len = strlen (root);
683 *s = 0; 700 strcpy (emacsroot, root);
684 if (s - 4 >= t && strcmp (s - 4, "/bin") == 0) 701
685 s[strlen (s) - 4] = 0; 702 /* We default HOME to our root. */
686 } 703 setenv ("HOME", root, 0);
687 setenv ("HOME", t, 0); 704
688 705 /* We default EMACSPATH to root + "/bin". */
689 /* We set EMACSPATH to ~/bin (expanded) */ 706 strcpy (root + len, "/bin");
690 s = getenv ("HOME"); 707 setenv ("EMACSPATH", root, 0);
691 t = strcpy (alloca (strlen (s) + 6), s);
692 if (s[strlen (s) - 1] != '/') strcat (t, "/");
693 strcat (t, "bin");
694 setenv ("EMACSPATH", t, 0);
695 708
696 /* I don't expect anybody to ever use other terminals so the internal 709 /* I don't expect anybody to ever use other terminals so the internal
697 terminal is the default. */ 710 terminal is the default. */