Fix typo on include guard for term.h
[sxemacs] / src / emacs.c
index 58970a2..49fa20d 100644 (file)
@@ -3,7 +3,7 @@
    Free Software Foundation, Inc.
    Copyright (C) 1995 Sun Microsystems, Inc.
    Copyright (C) 2000, 2002 Ben Wing.
-   Copyright (C) 2004 Steve Youngs.
+   Copyright (C) 2004, 2015 Steve Youngs.
 
 This file is part of SXEmacs
 
@@ -309,7 +309,7 @@ Lisp_Object Vconfigure_info_directory;
 Lisp_Object Vconfigure_info_path;
 Lisp_Object Vinternal_error_checking;
 Lisp_Object Vmail_lock_methods, Vconfigure_mail_lock_method;
-Lisp_Object Vpath_separator;
+Lisp_Object Vpath_separator, Vuser_packages_topdir;
 
 /* The default base directory SXEmacs is installed under. */
 Lisp_Object Vconfigure_exec_prefix_directory, Vconfigure_prefix_directory;
@@ -333,6 +333,12 @@ int display_arg;
    variable. */
 const char *display_use;
 
+/* Directory specified on the command line for user packages
+   (early-packages).  We cannot use a Lisp symbol here because Lisp
+   symbols may not be initialised at the time that we set this. */
+const char *user_pkgd;
+int upkgd = 0;
+
 /* If non-zero, then the early error handler will only print the error
    message and exit. */
 int suppress_early_error_handler_backtrace;
@@ -1018,9 +1024,9 @@ DOESNT_RETURN main_1(int argc, char **argv, char **envp, int restart)
 
        /* Handle the -sd/--show-dump-id switch, which means show the hex
           dump_id and quit */
-       if (argmatch(argv, argc,
-                    "-sd", "--show-dump-id",
-                    9, NULL, &skip_args)) {
+       if (argmatch(argv, argc, "-show-dump-id", "--show-dump-id", 9,
+                    NULL, &skip_args)
+           || argmatch(argv, argc, "-sd", 0, 3, NULL, &skip_args)) {
 #ifdef PDUMP
                printf("%08x\n", dump_id);
 #else
@@ -1034,7 +1040,8 @@ DOESNT_RETURN main_1(int argc, char **argv, char **envp, int restart)
        {
                char *term;
                if (argmatch
-                   (argv, argc, "-t", "--terminal", 4, &term, &skip_args)) {
+                   (argv, argc, "-terminal", "--terminal", 4, &term, &skip_args)
+                   || argmatch(argv, argc, "-t", 0, 2, &term, &skip_args)) {
                        int tdesc = -1;
 #ifdef HAVE_TTYNAME
                        stderr_out("Opening for terminal usage %s (current: %s)\n", term, ttyname(0));
@@ -1083,19 +1090,24 @@ DOESNT_RETURN main_1(int argc, char **argv, char **envp, int restart)
 
        /* Handle the --no-dump-file/-nd switch, which means don't
         * load the dump file (ignored when not using pdump) */
-       if (argmatch(argv, argc, "-nd", "--no-dump-file", 7,
-                    NULL, &skip_args)) {
+       if (argmatch(argv, argc, "-no-dump-file", "--no-dump-file", 7,
+                    NULL, &skip_args)
+           || argmatch(argv, argc, "-nd", 0, 3, NULL, &skip_args)) {
                nodumpfile = 1;
        }
 
-       if (argmatch(argv, argc, "-ct", "--color-terminal", 5,
-                    NULL, &skip_args)) {
+       if (argmatch(argv, argc, "-color-terminal", "--color-terminal", 5,
+                    NULL, &skip_args)
+           || argmatch(argv, argc, "-ct", 0, 3, NULL, &skip_args)) {
                assume_colorterm = 1;
        }
 
        /* Handle -nw switch */
-       if (argmatch(argv, argc, "-nw", "--no-windows", 6, NULL, &skip_args))
+       if (argmatch(argv, argc, "-no-windows", "--no-windows", 6, NULL,
+                    &skip_args)
+           || argmatch(argv, argc, "-nw", 0, 3, NULL, &skip_args)) {
                inhibit_window_system = 1;
+       }
 
        /* Handle the -batch switch, which means don't do interactive display */
        if (argmatch(argv, argc, "-batch", "--batch", 5, NULL, &skip_args)) {
@@ -1109,6 +1121,14 @@ DOESNT_RETURN main_1(int argc, char **argv, char **envp, int restart)
                     11, NULL, &skip_args))
                debug_paths = 1;
 
+       /* Handle -user-pkgs-directory */
+       char *pkgd;
+       if (argmatch(argv, argc, "-user-pkgs-directory", "--user-pkgs-directory",
+                    11, &pkgd, &skip_args)) {
+               user_pkgd = pkgd;
+               upkgd = 1;
+       }
+
        /* Partially handle -no-autoloads, -no-early-packages and -vanilla.
           Packages */
        /* are searched prior to the rest of the command line being parsed in */
@@ -1147,7 +1167,8 @@ DOESNT_RETURN main_1(int argc, char **argv, char **envp, int restart)
 
        /* Partially handle the -version and -help switches: they imply -batch,
           but are not removed from the list. */
-       if (argmatch(argv, argc, "-help", "--help", 3, NULL, &skip_args))
+       if (argmatch(argv, argc, "-help", "--help", 3, NULL, &skip_args)
+           || argmatch(argv, argc, "-h", 0, 2, NULL, &skip_args))
                noninteractive = 1, skip_args--;
 
        if (argmatch(argv, argc, "-version", "--version", 3, NULL, &skip_args)
@@ -2169,6 +2190,14 @@ DOESNT_RETURN main_1(int argc, char **argv, char **envp, int restart)
           of this stuff involves querying the current environment and needs
           to be done both at dump time and at run time. */
 
+       /* user-packages-topdir (early-packages) */
+       if (upkgd == 0) {
+               Vuser_packages_topdir = Qnil;
+       } else {
+               Vuser_packages_topdir = Ffile_name_as_directory
+                       (build_string(user_pkgd));
+       }
+
        init_initial_directory();       /* get the directory to use for the
                                           "*scratch*" buffer, etc. */
 
@@ -2323,6 +2352,10 @@ static const struct standard_args standard_args[] = {
        {"-no-autoloads", "--no-autoloads", 50, 0},
        {"-no-site-file", "--no-site-file", 40, 0},
        {"-no-early-packages", "--no-early-packages", 35, 0},
+       /* -user-pkgs-directory is actually handled in main_1() and
+          not in startup.el.  It is listed here because of the
+          priority given to this arg. */
+       {"-user-pkgs-directory", "--user-pkgs-directory", 30, 1},
        {"-u", "--user", 30, 1},
        {"-user", 0, 30, 1},
        {"-debug-init", "--debug-init", 20, 0},
@@ -2745,8 +2778,15 @@ main(int argc, char **argv, char **envp)
 /* various system shared libraries have been built and linked with */
 /* GCC >= 2.8.  -slb */
 #if defined(GNU_MALLOC)
+#if defined(HAVE_MORECORE_HOOK)
 static void voodoo_free_hook(void *mem)
 {
+  /* If it no longer works, we'll know about it. For now there is really no
+     good alternatic. Shut the warning off
+  */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+
        /* Disable all calls to free() when SXEmacs is exiting and it doesn't */
        /* matter. */
        __free_hook =
@@ -2755,7 +2795,9 @@ static void voodoo_free_hook(void *mem)
            (__typeof__(__free_hook))
 #endif
            voodoo_free_hook;
+#pragma GCC diagnostic pop
 }
+#endif
 #endif                         /* GNU_MALLOC */
 
 DEFUN("kill-emacs", Fkill_emacs, 0, 1, "P", /*
@@ -2810,12 +2852,17 @@ all of which are called before SXEmacs is actually killed.
        shut_down_emacs(0, STRINGP(arg) ? arg : Qnil, 0);
 
 #if defined(GNU_MALLOC)
+#if defined(HAVE_MORECORE_HOOK)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
        __free_hook =
 #if defined __GNUC__ || defined __INTEL_COMPILER
 /* prototype of __free_hook varies with glibc version */
            (__typeof__(__free_hook))
 #endif
            voodoo_free_hook;
+#pragma GCC diagnostic pop
+#endif
 #endif
 
        exit(INTP(arg) ? XINT(arg) : 0);
@@ -3031,6 +3078,7 @@ and announce itself normally when it is run.
                garbage_collect_1();
 
 #ifdef PDUMP
+               SXE_SET_UNUSED(symfile_ext);
                pdump(filename_ext);
 #else
 
@@ -3180,6 +3228,8 @@ static int assertions_dont_abort = 0;
 
 #define enter_debugger()
 
+void debug_backtrace();
+
 void
 assert_failed(const char *file, int line, const char *expr)
 {
@@ -3458,6 +3508,12 @@ Set to non-nil when site-modules should not be searched at startup.
        inhibit_site_modules = 1;
 #endif
 
+       DEFVAR_LISP("user-packages-topdir", &Vuser_packages_topdir /*
+Top of the user's local package hierarchy.
+This is normally computed at run-time, but may be set via the
+`-user-pkgs-directory' command line argument.
+                                                                  */ );
+
        DEFVAR_INT("emacs-priority", &emacs_priority /*
 Priority for SXEmacs to run at.
 This value is effective only if set before SXEmacs is dumped,