⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 emacs.c

📁 早期freebsd实现
💻 C
📖 第 1 页 / 共 2 页
字号:
/* Fully extensible Emacs, running on Unix, intended for GNU.   Copyright (C) 1985, 1986, 1987, 1990 Free Software Foundation, Inc.This file is part of GNU Emacs.GNU Emacs is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 1, or (at your option)any later version.GNU Emacs is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU Emacs; see the file COPYING.  If not, write tothe Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */#include <signal.h>#include <errno.h>#include "config.h"#include <stdio.h>#undef NULL#include "lisp.h"#include "commands.h"#include <sys/types.h>#include <sys/file.h>#ifdef VMS#include <ssdef.h>#endif#ifdef USG5#include <fcntl.h>#endif#ifdef BSD#include <sys/ioctl.h>#endif#ifdef APOLLO#ifndef APOLLO_SR10#include <default_acl.h>#endif#endif#ifndef O_RDWR#define O_RDWR 2#endif#define PRIO_PROCESS 0/* Command line args from shell, as list of strings */Lisp_Object Vcommand_line_args;/* Hook run by `kill-emacs' before it does really anything.  */Lisp_Object Vkill_emacs_hook;/* Set nonzero after Emacs has started up the first time.  Prevents reinitialization of the Lisp world and keymaps  on subsequent starts.  */int initialized;/* Variable whose value is symbol giving operating system type */Lisp_Object Vsystem_type;  /* If non-zero, emacs should not attempt to use an window-specific code,   but instead should use the virtual terminal under which it was started */int inhibit_window_system;#ifdef HAVE_X_WINDOWS/* If -d option is used, this variable points to the name of   the display to use.  */char *alternate_display;char **xargv;int xargc;#endif /* HAVE_X_WINDOWS */#ifdef USG_SHARED_LIBRARIES/* If nonzero, this is the place to put the end of the writable segment   at startup.  */unsigned int bss_end = 0;#endif/* Nonzero means running Emacs without interactive terminal.  */int noninteractive;/* Value of Lisp variable `noninteractive'.   Normally same as C variable `noninteractive'   but nothing terrible happens if user sets this one.  */int noninteractive1;/* Signal code for the fatal signal that was received */int fatal_error_code;/* Nonzero if handling a fatal error already */int fatal_error_in_progress;/* Handle bus errors, illegal instruction, etc. */fatal_error_signal (sig)     int sig;{#ifdef BSD  int tpgrp;#endif /* BSD */  fatal_error_code = sig;  signal (sig, SIG_DFL);  /* If fatal error occurs in code below, avoid infinite recursion.  */  if (fatal_error_in_progress)    kill (getpid (), fatal_error_code);  fatal_error_in_progress = 1;  /* If we are controlling the terminal, reset terminal modes */#ifdef BSD  if (ioctl(0, TIOCGPGRP, &tpgrp) == 0      && tpgrp == getpgrp (0))#endif /* BSD */    {      reset_sys_modes ();      if (sig != SIGTERM)	fprintf (stderr, "Fatal error (%d).", sig);    }  /* Clean up */#ifdef subprocesses  kill_buffer_processes (Qnil);#endif  Fdo_auto_save (Qt);#ifdef CLASH_DETECTION  unlock_all_files ();#endif /* CLASH_DETECTION */#ifdef VMS  kill_vms_processes ();  LIB$STOP (SS$_ABORT);#else  /* Signal the same code; this time it will really be fatal.  */  kill (getpid (), fatal_error_code);#endif /* not VMS */}/* Code for dealing with Lisp access to the Unix command line */staticinit_cmdargs (argc, argv, skip_args)     int argc;     char **argv;     int skip_args;{  register int i;  Vcommand_line_args = Qnil;  for (i = argc - 1; i >= 0; i--)    {      if (i == 0 || i > skip_args)	Vcommand_line_args	  = Fcons (build_string (argv[i]), Vcommand_line_args);    }}#ifdef VMS#ifdef LINK_CRTL_SHARE#ifdef SHAREABLE_LIB_BUGextern noshare char **environ;#endif /* SHAREABLE_LIB_BUG */#endif /* LINK_CRTL_SHARE */#endif /* VMS *//* We don't include crtbegin.o and crtend.o in the link,   so these functions and variables might be missed.   Provide dummy definitions to avoid error.   (We don't have any real constructors or destructors.)  */#ifdef __GNUC__#ifndef ORDINARY_LINK__do_clobal_ctors (){}__do_clobal_ctors_aux (){}__do_global_dtors (){}char * __CTOR_LIST__[2] = { (char *) (-1), 0 };char * __DTOR_LIST__[2] = { (char *) (-1), 0 };__main (){}#endif /* not ORDINARY_LINK */#endif /* __GNUC__ *//* ARGSUSED */main (argc, argv, envp)     int argc;     char **argv;     char **envp;{  int skip_args = 0;  extern int errno;  extern void malloc_warning ();/* Map in shared memory, if we are using that.  */#ifdef HAVE_SHM  if (argc > 1 && !strcmp (argv[1], "-nl"))    {      map_in_data (0);      /* The shared momory was just restored, which clobbered this.  */      skip_args = 1;    }  else    {      map_in_data (1);      /* The shared momory was just restored, which clobbered this.  */      skip_args = 0;    }#endif#ifdef VMS  /* If -map specified, map the data file in */  if (argc > 2 && ! strcmp (argv[1], "-map"))    {      skip_args = 2;      mapin_data (argv[2]);    }#ifdef LINK_CRTL_SHARE#ifdef SHAREABLE_LIB_BUG  /* Bletcherous shared libraries! */  if (!stdin)    stdin = fdopen (0, "r");  if (!stdout)    stdout = fdopen (1, "w");  if (!stderr)    stderr = fdopen (2, "w");  if (!environ)    environ = envp;#endif /* SHAREABLE_LIB_BUG */#endif /* LINK_CRTL_SHARE */#endif /* VMS */#ifdef USG_SHARED_LIBRARIES  if (bss_end)    brk (bss_end);#endif  clearerr (stdin);#ifdef APOLLO#ifndef APOLLO_SR10  /* If USE_DOMAIN_ACLS environment variable exists,     use ACLs rather than UNIX modes. */  if (egetenv ("USE_DOMAIN_ACLS"))    default_acl (USE_DEFACL);#endif#endif /* APOLLO */#ifndef SYSTEM_MALLOC  /* Arrange for warnings when nearly out of space.  */  malloc_init (0, malloc_warning);#endif#ifdef HIGHPRI  setpriority (PRIO_PROCESS, getpid (), HIGHPRI);  setuid (getuid ());#endif HIGHPRI  inhibit_window_system = 0;#ifdef HAVE_X_WINDOWS  xargv = argv;  xargc = argc;#endif/* Handle the -t switch, which specifies filename to use as terminal */  if (skip_args + 2 < argc && !strcmp (argv[skip_args + 1], "-t"))    {      skip_args += 2;      close (0);      close (1);      open (argv[skip_args], O_RDWR, 2 );      dup (0);      fprintf (stderr, "Using %s\n", argv[skip_args]);#ifdef HAVE_X_WINDOWS      inhibit_window_system = 1;	/* -t => -nw */#endif    }#ifdef HAVE_X_WINDOWS/* Handle the -d switch, which means use a different display for X */  if (skip_args + 2 < argc && (!strcmp (argv[skip_args + 1], "-d") ||			       !strcmp (argv[skip_args + 1], "-display")))    {      skip_args += 2;      alternate_display = argv[skip_args];    }   else    alternate_display = 0;#endif	/* HAVE_X_WINDOWS */  if (skip_args + 1 < argc      && (!strcmp (argv[skip_args + 1], "-nw")))    {      skip_args += 1;      inhibit_window_system = 1;    }/* Handle the -batch switch, which means don't do interactive display.  */  noninteractive = 0;  if (skip_args + 1 < argc && !strcmp (argv[skip_args + 1], "-batch"))    {      skip_args += 1;      noninteractive = 1;    }  if (#ifndef CANNOT_DUMP      ! noninteractive || initialized#else      1#endif      )    {      /* Don't catch these signals in batch mode if not initialized.	 On some machines, this sets static data that would make	 signal fail to work right when the dumped Emacs is run.  */      signal (SIGHUP, fatal_error_signal);      signal (SIGQUIT, fatal_error_signal);      signal (SIGILL, fatal_error_signal);      signal (SIGTRAP, fatal_error_signal);      signal (SIGIOT, fatal_error_signal);#ifdef SIGEMT      signal (SIGEMT, fatal_error_signal);#endif      signal (SIGFPE, fatal_error_signal);      signal (SIGBUS, fatal_error_signal);      signal (SIGSEGV, fatal_error_signal);      signal (SIGSYS, fatal_error_signal);      signal (SIGTERM, fatal_error_signal);#ifdef SIGXCPU      signal (SIGXCPU, fatal_error_signal);#endif#ifdef SIGXFSZ      signal (SIGXFSZ, fatal_error_signal);#endif SIGXFSZ#ifdef AIX      signal (SIGDANGER, fatal_error_signal);      signal (20, fatal_error_signal);      signal (21, fatal_error_signal);      signal (22, fatal_error_signal);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -