#endif
#ifdef HAVE_SETPGID
-#if !defined (USG) || defined (BSD_PGRPS)
+#if !defined (USG)
#undef setpgrp
#define setpgrp setpgid
#endif
#endif
-extern void malloc_warning P_ ((char *));
-extern void set_time_zone_rule P_ ((char *));
-#ifdef HAVE_INDEX
-extern char *index P_ ((const char *, int));
-#endif
+const char emacs_copyright[] = "Copyright (C) 2010 Free Software Foundation, Inc.";
+const char emacs_version[] = "24.0.50";
/* Make these values available in GDB, which doesn't see macros. */
static data inside glibc's malloc. */
void *malloc_state_ptr;
/* From glibc, a routine that returns a copy of the malloc internal state. */
-extern void *malloc_get_state ();
+extern void *malloc_get_state (void);
/* From glibc, a routine that overwrites the malloc internal state. */
-extern int malloc_set_state ();
+extern int malloc_set_state (void*);
/* Non-zero if the MALLOC_CHECK_ environment variable was set while
dumping. Used to work around a bug in glibc's malloc. */
int malloc_using_checking;
Lisp_Object Vsystem_time_locale;
Lisp_Object Vprevious_system_time_locale;
+/* Copyright and version info. The version number may be updated by
+ Lisp code. */
+Lisp_Object Vemacs_copyright, Vemacs_version;
+
/* If non-zero, emacs should not attempt to use a window-specific code,
but instead should use the virtual terminal under which it was started. */
int inhibit_window_system;
data on the first attempt to change it inside asynchronous code. */
int running_asynch_code;
-#ifdef BSD_PGRPS
-/* See sysdep.c. */
-extern int inherited_pgroup;
-#endif
-
#if defined(HAVE_X_WINDOWS) || defined(HAVE_NS)
/* If non-zero, -d was specified, meaning we're using some window system. */
int display_arg;
char **initial_argv;
int initial_argc;
-static void sort_args ();
-void syms_of_emacs ();
+static void sort_args (int argc, char **argv);
+void syms_of_emacs (void);
/* MSVC needs each string be shorter than 2048 bytes, so the usage
strings below are split to not overflow this limit. */
Initialization options:\n\
\n\
--batch do not do interactive display; implies -q\n\
+--chdir DIR change to directory DIR\n\
--daemon start a server in the background\n\
--debug-init enable Emacs Lisp debugger for init file\n\
--display, -d DISPLAY use X server DISPLAY\n\
/* If non-null, call this function from fatal_error_signal before
committing suicide. */
-void (*fatal_error_signal_hook) P_ ((void));
+void (*fatal_error_signal_hook) (void);
#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD
/* When compiled with GTK and running under Gnome,
/* Handle bus errors, invalid instruction, etc. */
SIGTYPE
-fatal_error_signal (sig)
- int sig;
+fatal_error_signal (int sig)
{
SIGNAL_THREAD_CHECK (sig);
fatal_error_code = sig;
{
fatal_error_in_progress = 1;
+ if (sig == SIGTERM || sig == SIGHUP)
+ Fkill_emacs (make_number (sig));
+
shut_down_emacs (sig, 0, Qnil);
}
#if ! defined (DOS_NT) && ! defined (NO_ABORT)
void
-abort ()
+abort (void)
{
kill (getpid (), SIGABRT);
/* This shouldn't be executed, but it prevents a warning. */
/* Code for dealing with Lisp access to the Unix command line. */
static void
-init_cmdargs (argc, argv, skip_args)
- int argc;
- char **argv;
- int skip_args;
+init_cmdargs (int argc, char **argv, int skip_args)
{
register int i;
Lisp_Object name, dir, tem;
DEFUN ("invocation-name", Finvocation_name, Sinvocation_name, 0, 0, 0,
doc: /* Return the program name that was used to run Emacs.
Any directory names are omitted. */)
- ()
+ (void)
{
return Fcopy_sequence (Vinvocation_name);
}
DEFUN ("invocation-directory", Finvocation_directory, Sinvocation_directory,
0, 0, 0,
doc: /* Return the directory name in which the Emacs executable was located. */)
- ()
+ (void)
{
return Fcopy_sequence (Vinvocation_directory);
}
(We don't have any real constructors or destructors.) */
#ifdef __GNUC__
#ifndef GCC_CTORS_IN_LIBC
-void __do_global_ctors ()
+void __do_global_ctors (void)
{}
-void __do_global_ctors_aux ()
+void __do_global_ctors_aux (void)
{}
-void __do_global_dtors ()
+void __do_global_dtors (void)
{}
/* GNU/Linux has a bug in its library; avoid an error. */
#ifndef GNU_LINUX
#endif
char * __DTOR_LIST__[2] = { (char *) (-1), 0 };
#endif /* GCC_CTORS_IN_LIBC */
-void __main ()
+void __main (void)
{}
#endif /* __GNUC__ */
#endif /* ORDINARY_LINK */
enough information to do it right. */
static int
-argmatch (argv, argc, sstr, lstr, minlen, valptr, skipptr)
- char **argv;
- int argc;
- char *sstr;
- char *lstr;
- int minlen;
- char **valptr;
- int *skipptr;
+argmatch (char **argv, int argc, char *sstr, char *lstr, int minlen, char **valptr, int *skipptr)
{
char *p = NULL;
int arglen;
*skipptr += 1;
return 1;
}
- arglen = (valptr != NULL && (p = index (arg, '=')) != NULL
+ arglen = (valptr != NULL && (p = strchr (arg, '=')) != NULL
? p - arg : strlen (arg));
if (lstr == 0 || arglen < minlen || strncmp (arg, lstr, arglen) != 0)
return 0;
possible using this special hook. */
static void
-malloc_initialize_hook ()
+malloc_initialize_hook (void)
{
#ifndef USE_CRT_DLL
extern char **environ;
}
}
-void (*__malloc_initialize_hook) () = malloc_initialize_hook;
+void (*__malloc_initialize_hook) (void) = malloc_initialize_hook;
#endif /* DOUG_LEA_MALLOC */
#ifdef NS_IMPL_COCOA
char dname_arg2[80];
#endif
+ char *ch_to_dir;
#if GC_MARK_STACK
- extern Lisp_Object *stack_base;
stack_base = &dummy;
#endif
argc = 0;
while (argv[argc]) argc++;
- if (argmatch (argv, argc, "-version", "--version", 3, NULL, &skip_args)
- /* We don't know the version number unless this is a dumped Emacs.
- So ignore --version otherwise. */
- && initialized)
+ if (argmatch (argv, argc, "-version", "--version", 3, NULL, &skip_args))
{
- Lisp_Object tem, tem2;
- tem = Fsymbol_value (intern_c_string ("emacs-version"));
- tem2 = Fsymbol_value (intern_c_string ("emacs-copyright"));
- if (!STRINGP (tem))
- {
- fprintf (stderr, "Invalid value of `emacs-version'\n");
- exit (1);
- }
- if (!STRINGP (tem2))
+ const char *version, *copyright;
+ if (initialized)
{
- fprintf (stderr, "Invalid value of `emacs-copyright'\n");
- exit (1);
+ Lisp_Object tem, tem2;
+ tem = Fsymbol_value (intern_c_string ("emacs-version"));
+ tem2 = Fsymbol_value (intern_c_string ("emacs-copyright"));
+ if (!STRINGP (tem))
+ {
+ fprintf (stderr, "Invalid value of `emacs-version'\n");
+ exit (1);
+ }
+ if (!STRINGP (tem2))
+ {
+ fprintf (stderr, "Invalid value of `emacs-copyright'\n");
+ exit (1);
+ }
+ else
+ {
+ version = SDATA (tem);
+ copyright = SDATA (tem2);
+ }
}
else
{
- printf ("GNU Emacs %s\n", SDATA (tem));
- printf ("%s\n", SDATA(tem2));
- printf ("GNU Emacs comes with ABSOLUTELY NO WARRANTY.\n");
- printf ("You may redistribute copies of Emacs\n");
- printf ("under the terms of the GNU General Public License.\n");
- printf ("For more information about these matters, ");
- printf ("see the file named COPYING.\n");
- exit (0);
+ version = emacs_version;
+ copyright = emacs_copyright;
}
+ printf ("GNU Emacs %s\n", version);
+ printf ("%s\n", copyright);
+ printf ("GNU Emacs comes with ABSOLUTELY NO WARRANTY.\n");
+ printf ("You may redistribute copies of Emacs\n");
+ printf ("under the terms of the GNU General Public License.\n");
+ printf ("For more information about these matters, ");
+ printf ("see the file named COPYING.\n");
+ exit (0);
}
+ if (argmatch (argv, argc, "-chdir", "--chdir", 2, &ch_to_dir, &skip_args))
+ if (chdir (ch_to_dir) == -1)
+ {
+ fprintf (stderr, "%s: Can't chdir to %s: %s\n",
+ argv[0], ch_to_dir, strerror (errno));
+ exit (1);
+ }
+
#ifdef HAVE_PERSONALITY_LINUX32
if (!initialized
}
#endif /* MSDOS */
-#ifdef SET_EMACS_PRIORITY
- if (emacs_priority)
- nice (emacs_priority);
- setuid (getuid ());
-#endif /* SET_EMACS_PRIORITY */
-
/* Skip initial setlocale if LC_ALL is "C", as it's not needed in that case.
The build procedure uses this while dumping, to ensure that the
dumped Emacs does not have its system locale tables initialized,
if (! noninteractive)
{
-#ifdef BSD_PGRPS
- if (initialized)
- {
- inherited_pgroup = EMACS_GETPGRP (0);
- setpgrp (0, getpid ());
- }
-#else
#if defined (USG5) && defined (INTERRUPT_INPUT)
setpgrp ();
#endif
-#endif
#if defined (HAVE_GTK_AND_PTHREAD) && !defined (SYSTEM_MALLOC) && !defined (DOUG_LEA_MALLOC)
{
- extern void malloc_enable_thread P_ ((void));
+ extern void malloc_enable_thread (void);
malloc_enable_thread ();
}
ns_init_paths ();
#endif
+ /* Initialize and GC-protect Vinitial_environment and
+ Vprocess_environment before set_initial_environment fills them
+ in. */
+ if (!initialized)
+ syms_of_callproc ();
/* egetenv is a pretty low-level facility, which may get called in
many circumstances; it seems flimsy to put off initializing it
until calling init_callproc. */
syms_of_callint ();
syms_of_casefiddle ();
syms_of_casetab ();
- syms_of_callproc ();
syms_of_category ();
syms_of_ccl ();
syms_of_character ();
syms_of_cmds ();
-#ifndef NO_DIR_LIBRARY
syms_of_dired ();
-#endif /* not NO_DIR_LIBRARY */
syms_of_display ();
syms_of_doc ();
syms_of_editfns ();
#ifdef MSDOS
syms_of_xmenu ();
+ syms_of_dosfns();
+ syms_of_msdos();
+ syms_of_win16select();
#endif /* MSDOS */
#ifdef HAVE_NS
syms_of_dbusbind ();
#endif /* HAVE_DBUS */
-#ifdef SYMS_SYSTEM
- SYMS_SYSTEM;
-#endif
-
-#ifdef SYMS_MACHINE
- SYMS_MACHINE;
-#endif
+#ifdef WINDOWSNT
+ syms_of_ntterm ();
+#endif /* WINDOWSNT */
keys_of_casefiddle ();
keys_of_cmds ();
#endif
init_window ();
init_font ();
-
+
if (!initialized)
{
char *file;
#else
extern char etext;
#endif
+#ifdef HAVE___EXECUTABLE_START
+ /* This symbol is defined by GNU ld to the start of the text
+ segment. */
+ extern char __executable_start[];
+#else
extern void safe_bcopy ();
- extern void dump_opcode_frequencies ();
+#endif
atexit (_mcleanup);
+#ifdef HAVE___EXECUTABLE_START
+ monstartup (__executable_start, &etext);
+#else
/* This uses safe_bcopy because that function comes first in the
Emacs executable. It might be better to use something that
gives the start of the text segment, but start_of_text is not
defined on all systems now. */
+ /* FIXME: Does not work on architectures with function
+ descriptors. */
monstartup (safe_bcopy, &etext);
+#endif
}
else
moncontrol (0);
const struct standard_args standard_args[] =
{
{ "-version", "--version", 150, 0 },
+ { "-chdir", "--chdir", 130, 1 },
{ "-t", "--terminal", 120, 1 },
{ "-nw", "--no-window-system", 110, 0 },
{ "-nw", "--no-windows", 110, 0 },
than once, eliminate all but one copy of it. */
static void
-sort_args (argc, argv)
- int argc;
- char **argv;
+sort_args (int argc, char **argv)
{
char **new = (char **) xmalloc (sizeof (char *) * argc);
/* For each element of argv,
{
match = -1;
thislen = strlen (argv[from]);
- equals = index (argv[from], '=');
+ equals = strchr (argv[from], '=');
if (equals != 0)
thislen = equals - argv[from];
while (to < argc)
new[to++] = 0;
- bcopy (new, argv, sizeof (char *) * argc);
+ memcpy (argv, new, sizeof (char *) * argc);
xfree (options);
xfree (new);
The value of `kill-emacs-hook', if not void,
is a list of functions (of no args),
all of which are called before Emacs is actually killed. */)
- (arg)
- Lisp_Object arg;
+ (Lisp_Object arg)
{
struct gcpro gcpro1;
unlink (SDATA (Vauto_save_list_file_name));
exit (INTEGERP (arg) ? XINT (arg) : EXIT_SUCCESS);
- /* NOTREACHED */
- return Qnil;
}
and Fkill_emacs. */
void
-shut_down_emacs (sig, no_x, stuff)
- int sig, no_x;
- Lisp_Object stuff;
+shut_down_emacs (int sig, int no_x, Lisp_Object stuff)
{
/* Prevent running of hooks from now on. */
Vrun_hooks = Qnil;
stuff_buffered_input (stuff);
-#ifdef subprocesses
inhibit_sentinels = 1;
-#endif
kill_buffer_processes (Qnil);
Fdo_auto_save (Qt, Qnil);
This is used in the file `loadup.el' when building Emacs.
You must run Emacs in batch mode in order to dump it. */)
- (filename, symfile)
- Lisp_Object filename, symfile;
+ (Lisp_Object filename, Lisp_Object symfile)
{
extern char my_edata[];
Lisp_Object tem;
#if HAVE_SETLOCALE
/* Recover from setlocale (LC_ALL, ""). */
void
-fixup_locale ()
+fixup_locale (void)
{
/* The Emacs Lisp reader needs LC_NUMERIC to be "C",
so that numbers are read and printed properly for Emacs Lisp. */
/* Set system locale CATEGORY, with previous locale *PLOCALE, to
DESIRED_LOCALE. */
static void
-synchronize_locale (category, plocale, desired_locale)
- int category;
- Lisp_Object *plocale;
- Lisp_Object desired_locale;
+synchronize_locale (int category, Lisp_Object *plocale, Lisp_Object desired_locale)
{
if (! EQ (*plocale, desired_locale))
{
/* Set system time locale to match Vsystem_time_locale, if possible. */
void
-synchronize_system_time_locale ()
+synchronize_system_time_locale (void)
{
synchronize_locale (LC_TIME, &Vprevious_system_time_locale,
Vsystem_time_locale);
/* Set system messages locale to match Vsystem_messages_locale, if
possible. */
void
-synchronize_system_messages_locale ()
+synchronize_system_messages_locale (void)
{
#ifdef LC_MESSAGES
synchronize_locale (LC_MESSAGES, &Vprevious_system_messages_locale,
#endif
Lisp_Object
-decode_env_path (evarname, defalt)
- char *evarname, *defalt;
+decode_env_path (const char *evarname, const char *defalt)
{
- register char *path, *p;
+ const char *path, *p;
Lisp_Object lpath, element, tem;
/* It's okay to use getenv here, because this function is only used
to initialize variables when Emacs starts up, and isn't called
after that. */
if (evarname != 0)
- path = (char *) getenv (evarname);
+ path = getenv (evarname);
else
path = 0;
if (!path)
/* Ensure values from the environment use the proper directory separator. */
if (path)
{
- p = alloca (strlen (path) + 1);
- strcpy (p, path);
- path = p;
-
- if ('/' == DIRECTORY_SEP)
- dostounix_filename (path);
- else
- unixtodos_filename (path);
+ char *path_copy = alloca (strlen (path) + 1);
+ strcpy (path_copy, path);
+ dostounix_filename (path_copy);
+ path = path_copy;
}
#endif
lpath = Qnil;
while (1)
{
- p = index (path, SEPCHAR);
- if (!p) p = path + strlen (path);
+ p = strchr (path, SEPCHAR);
+ if (!p)
+ p = path + strlen (path);
element = (p - path ? make_string (path, p - path)
: build_string ("."));
DEFUN ("daemonp", Fdaemonp, Sdaemonp, 0, 0, 0,
doc: /* Return non-nil if the current emacs process is a daemon.
If the daemon was given a name argument, return that name. */)
- ()
+ (void)
{
if (IS_DAEMON)
if (daemon_name)
doc: /* Mark the Emacs daemon as being initialized.
This finishes the daemonization process by doing the other half of detaching
from the parent process and its tty file descriptors. */)
- ()
+ (void)
{
int nfd;
}
void
-syms_of_emacs ()
+syms_of_emacs (void)
{
Qfile_name_handler_alist = intern_c_string ("file-name-handler-alist");
staticpro (&Qfile_name_handler_alist);
doc: /* If non-nil, X resources, Windows Registry settings, and NS defaults are not used. */);
inhibit_x_resources = 0;
+ DEFVAR_LISP ("emacs-copyright", &Vemacs_copyright,
+ doc: /* Short copyright string for this version of Emacs. */);
+ Vemacs_copyright = build_string (emacs_copyright);
+
+ DEFVAR_LISP ("emacs-version", &Vemacs_version,
+ doc: /* Version numbers of this version of Emacs. */);
+ Vemacs_version = build_string (emacs_version);
+
/* Make sure IS_DAEMON starts up as false. */
daemon_pipe[1] = 0;
}