2013-10-11 02:09:29 -04:00
|
|
|
/* main.c -- */
|
|
|
|
|
2021-08-15 04:05:31 -04:00
|
|
|
/* µEMACS 4.2
|
2015-02-12 00:15:45 -05:00
|
|
|
*
|
|
|
|
* Based on:
|
|
|
|
*
|
2005-05-31 11:50:56 -04:00
|
|
|
* uEmacs/PK 4.0
|
|
|
|
*
|
2010-08-12 23:19:22 -04:00
|
|
|
* Based on:
|
2005-05-31 11:50:56 -04:00
|
|
|
*
|
|
|
|
* MicroEMACS 3.9
|
2010-08-12 23:19:22 -04:00
|
|
|
* Written by Dave G. Conroy.
|
2010-09-13 05:18:00 -04:00
|
|
|
* Substantially modified by Daniel M. Lawrence
|
2010-08-12 23:19:22 -04:00
|
|
|
* Modified by Petri Kutvonen
|
|
|
|
*
|
|
|
|
* MicroEMACS 3.9 (c) Copyright 1987 by Daniel M. Lawrence
|
2005-05-31 11:50:56 -04:00
|
|
|
*
|
|
|
|
* Original statement of copying policy:
|
|
|
|
*
|
|
|
|
* MicroEMACS 3.9 can be copied and distributed freely for any
|
|
|
|
* non-commercial purposes. MicroEMACS 3.9 can only be incorporated
|
|
|
|
* into commercial software with the permission of the current author.
|
|
|
|
*
|
|
|
|
* No copyright claimed for modifications made by Petri Kutvonen.
|
|
|
|
*
|
|
|
|
* This file contains the main driving routine, and some keyboard
|
|
|
|
* processing code.
|
|
|
|
*
|
|
|
|
* REVISION HISTORY:
|
|
|
|
*
|
|
|
|
* 1.0 Steve Wilhite, 30-Nov-85
|
|
|
|
*
|
|
|
|
* 2.0 George Jones, 12-Dec-85
|
|
|
|
*
|
|
|
|
* 3.0 Daniel Lawrence, 29-Dec-85
|
|
|
|
*
|
|
|
|
* 3.2-3.6 Daniel Lawrence, Feb...Apr-86
|
|
|
|
*
|
|
|
|
* 3.7 Daniel Lawrence, 14-May-86
|
|
|
|
*
|
|
|
|
* 3.8 Daniel Lawrence, 18-Jan-87
|
|
|
|
*
|
|
|
|
* 3.9 Daniel Lawrence, 16-Jul-87
|
|
|
|
*
|
|
|
|
* 3.9e Daniel Lawrence, 16-Nov-87
|
|
|
|
*
|
|
|
|
* After that versions 3.X and Daniel Lawrence went their own ways.
|
|
|
|
* A modified 3.9e/PK was heavily used at the University of Helsinki
|
|
|
|
* for several years on different UNIX, VMS, and MSDOS platforms.
|
|
|
|
*
|
|
|
|
* This modified version is now called eEmacs/PK.
|
|
|
|
*
|
|
|
|
* 4.0 Petri Kutvonen, 1-Sep-91
|
|
|
|
*
|
2015-02-12 00:15:45 -05:00
|
|
|
* This modified version is now called uEMACS.
|
2013-04-30 21:21:16 -04:00
|
|
|
*
|
|
|
|
* 4.1 Renaud Fivet, 1-May-13
|
|
|
|
*
|
2015-02-12 00:15:45 -05:00
|
|
|
* Renamed as µEMACS to emphasize UTF-8 support.
|
|
|
|
*
|
|
|
|
* 4.2 Renaud Fivet, 2015-02-12
|
|
|
|
*
|
2005-05-31 11:50:56 -04:00
|
|
|
*/
|
|
|
|
|
2010-08-12 23:19:22 -04:00
|
|
|
#include <stdio.h>
|
2013-10-08 21:43:15 -04:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2005-05-31 11:50:56 -04:00
|
|
|
|
2021-08-18 04:54:35 -04:00
|
|
|
#include "defines.h" /* OS specific customization */
|
2013-10-09 02:56:43 -04:00
|
|
|
#if UNIX
|
2021-08-18 04:54:35 -04:00
|
|
|
# include <signal.h>
|
2013-10-09 02:56:43 -04:00
|
|
|
#endif
|
|
|
|
|
2013-05-30 03:05:19 -04:00
|
|
|
#include "basic.h"
|
|
|
|
#include "bind.h"
|
2013-06-04 23:48:40 -04:00
|
|
|
#include "bindable.h"
|
2013-05-30 03:05:19 -04:00
|
|
|
#include "buffer.h"
|
2013-06-05 21:28:34 -04:00
|
|
|
#include "display.h"
|
2013-05-30 03:05:19 -04:00
|
|
|
#include "eval.h"
|
2013-06-03 23:52:28 -04:00
|
|
|
#include "execute.h"
|
2013-05-30 03:05:19 -04:00
|
|
|
#include "file.h"
|
2013-06-01 01:42:09 -04:00
|
|
|
#include "lock.h"
|
2015-02-12 23:31:59 -05:00
|
|
|
#include "mlout.h"
|
2013-05-30 03:05:19 -04:00
|
|
|
#include "random.h"
|
|
|
|
#include "search.h"
|
2013-09-25 09:45:05 -04:00
|
|
|
#include "terminal.h"
|
2013-06-05 21:28:34 -04:00
|
|
|
#include "termio.h"
|
2019-06-19 07:49:20 -04:00
|
|
|
#include "util.h"
|
2013-06-05 21:28:34 -04:00
|
|
|
#include "version.h"
|
2013-09-20 06:10:30 -04:00
|
|
|
#include "window.h"
|
2013-05-30 03:05:19 -04:00
|
|
|
|
2010-08-12 23:19:22 -04:00
|
|
|
#if UNIX
|
2021-08-18 04:54:35 -04:00
|
|
|
static void emergencyexit( int signr) {
|
|
|
|
quickexit( FALSE, 0) ;
|
2015-07-16 22:48:17 -04:00
|
|
|
quit( TRUE, 0) ; /* If quickexit fails (to save changes), do a force quit */
|
2013-06-04 23:48:40 -04:00
|
|
|
}
|
2005-05-31 11:50:56 -04:00
|
|
|
#endif
|
|
|
|
|
2013-05-31 23:18:29 -04:00
|
|
|
static void edinit( char *bname) ;
|
|
|
|
|
2013-04-30 21:21:16 -04:00
|
|
|
static void version( void) {
|
2019-08-12 21:14:08 -04:00
|
|
|
fputs( PROGRAM_NAME_UTF8 " version " VERSION "\n", stdout) ;
|
2013-04-30 21:21:16 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void usage( void) {
|
2017-05-03 00:11:09 -04:00
|
|
|
fputs( "Usage: " PROGRAM_NAME " [OPTION|FILE]..\n\n"
|
2013-06-07 02:00:56 -04:00
|
|
|
" + start at the end of file\n"
|
|
|
|
" +<n> start at line <n>\n"
|
|
|
|
" --help display this help and exit\n"
|
|
|
|
" --version output version information and exit\n"
|
|
|
|
" -a|A process error file\n"
|
|
|
|
" -e|E edit file\n"
|
|
|
|
" -g|G<n> go to line <n>\n"
|
|
|
|
" -r|R restrictive use\n"
|
|
|
|
" -s|S<string> search string\n"
|
|
|
|
" -v|V view file\n"
|
2015-08-19 03:42:16 -04:00
|
|
|
" -x|Xcmdfile\n"
|
|
|
|
" -x|X cmdfile execute command file\n"
|
2017-05-03 00:11:09 -04:00
|
|
|
" @cmdfile execute startup file\n"
|
2013-06-07 02:00:56 -04:00
|
|
|
, stdout) ;
|
2010-08-14 23:11:27 -04:00
|
|
|
}
|
|
|
|
|
2013-05-16 22:34:01 -04:00
|
|
|
|
2021-08-18 04:54:35 -04:00
|
|
|
int main( int argc, char *argv[]) {
|
|
|
|
buffer_p bp; /* temp buffer pointer */
|
2010-02-27 05:38:22 -05:00
|
|
|
int firstfile; /* first file flag */
|
|
|
|
int carg; /* current arg to scan */
|
|
|
|
int startflag; /* startup executed flag */
|
2021-08-18 04:54:35 -04:00
|
|
|
buffer_p firstbp = NULL; /* ptr to first buffer in cmd line */
|
2005-09-30 18:26:09 -04:00
|
|
|
int viewflag; /* are we starting in view mode? */
|
|
|
|
int gotoflag; /* do we need to goto a line at start? */
|
2010-08-28 18:38:52 -04:00
|
|
|
int gline = 0; /* if so, what line? */
|
2005-09-30 18:26:09 -04:00
|
|
|
int searchflag; /* Do we need to search at start? */
|
|
|
|
int errflag; /* C error processing? */
|
2014-05-30 06:08:58 -04:00
|
|
|
bname_t bname ; /* buffer name of file to read */
|
2005-05-31 11:50:56 -04:00
|
|
|
|
|
|
|
#if PKCODE & BSD
|
2010-08-14 23:11:27 -04:00
|
|
|
sleep(1); /* Time for window manager. */
|
2005-05-31 11:50:56 -04:00
|
|
|
#endif
|
|
|
|
|
2013-04-30 21:21:16 -04:00
|
|
|
if( argc == 2) {
|
|
|
|
if( strcmp( argv[ 1], "--help") == 0) {
|
|
|
|
usage() ;
|
|
|
|
exit( EXIT_SUCCESS) ;
|
2010-08-14 23:11:27 -04:00
|
|
|
}
|
2013-04-30 21:21:16 -04:00
|
|
|
|
|
|
|
if( strcmp( argv[ 1], "--version") == 0) {
|
|
|
|
version() ;
|
|
|
|
exit( EXIT_SUCCESS) ;
|
2010-08-12 23:19:22 -04:00
|
|
|
}
|
|
|
|
}
|
2005-05-31 11:50:56 -04:00
|
|
|
|
2021-07-29 21:30:12 -04:00
|
|
|
vtinit() ; /* Display */
|
2015-02-12 23:31:59 -05:00
|
|
|
mloutfmt = mlwrite ;
|
2021-07-29 21:30:12 -04:00
|
|
|
edinit( "main") ; /* Bindings, buffers, windows */
|
|
|
|
varinit() ; /* user variables */
|
2005-05-31 11:50:56 -04:00
|
|
|
|
|
|
|
viewflag = FALSE; /* view mode defaults off in command line */
|
|
|
|
gotoflag = FALSE; /* set to off to begin with */
|
|
|
|
searchflag = FALSE; /* set to off to begin with */
|
|
|
|
firstfile = TRUE; /* no file to edit yet */
|
|
|
|
startflag = FALSE; /* startup file not executed yet */
|
|
|
|
errflag = FALSE; /* not doing C error parsing */
|
|
|
|
|
2015-01-23 09:13:21 -05:00
|
|
|
/* Insure screen is initialized before startup and goto/search */
|
|
|
|
update( FALSE) ;
|
|
|
|
|
2005-05-31 11:50:56 -04:00
|
|
|
/* Parse the command line */
|
|
|
|
for (carg = 1; carg < argc; ++carg) {
|
|
|
|
/* Process Switches */
|
|
|
|
#if PKCODE
|
|
|
|
if (argv[carg][0] == '+') {
|
|
|
|
gotoflag = TRUE;
|
|
|
|
gline = atoi(&argv[carg][1]);
|
|
|
|
} else
|
|
|
|
#endif
|
|
|
|
if (argv[carg][0] == '-') {
|
|
|
|
switch (argv[carg][1]) {
|
|
|
|
/* Process Startup macroes */
|
2005-09-30 18:26:09 -04:00
|
|
|
case 'a': /* process error file */
|
|
|
|
case 'A':
|
|
|
|
errflag = TRUE;
|
|
|
|
break;
|
|
|
|
case 'e': /* -e for Edit file */
|
|
|
|
case 'E':
|
|
|
|
viewflag = FALSE;
|
|
|
|
break;
|
|
|
|
case 'g': /* -g for initial goto */
|
|
|
|
case 'G':
|
|
|
|
gotoflag = TRUE;
|
|
|
|
gline = atoi(&argv[carg][2]);
|
|
|
|
break;
|
|
|
|
case 'r': /* -r restrictive use */
|
|
|
|
case 'R':
|
|
|
|
restflag = TRUE;
|
|
|
|
break;
|
|
|
|
case 's': /* -s for initial search string */
|
|
|
|
case 'S':
|
|
|
|
searchflag = TRUE;
|
2019-06-19 07:49:20 -04:00
|
|
|
mystrscpy( pat, &argv[ carg][ 2], sizeof pat) ;
|
2005-09-30 18:26:09 -04:00
|
|
|
break;
|
|
|
|
case 'v': /* -v for View File */
|
|
|
|
case 'V':
|
|
|
|
viewflag = TRUE;
|
|
|
|
break;
|
2015-08-19 03:42:16 -04:00
|
|
|
case 'x':
|
|
|
|
case 'X':
|
|
|
|
if( argv[ carg][ 2]) { /* -Xfilename */
|
|
|
|
if( startup( &argv[ carg][ 2]) == TRUE)
|
|
|
|
startflag = TRUE ; /* don't execute emacs.rc */
|
|
|
|
} else if( argv[ carg + 1]) { /* -X filename */
|
|
|
|
if( startup( &argv[ carg + 1][ 0]) == TRUE)
|
|
|
|
startflag = TRUE ; /* don't execute emacs.rc */
|
2020-06-24 04:38:03 -04:00
|
|
|
|
2015-08-19 03:42:16 -04:00
|
|
|
carg += 1 ;
|
|
|
|
}
|
|
|
|
|
|
|
|
break ;
|
2005-09-30 18:26:09 -04:00
|
|
|
default: /* unknown switch */
|
|
|
|
/* ignore this for now */
|
|
|
|
break;
|
2005-05-31 11:50:56 -04:00
|
|
|
}
|
|
|
|
|
2005-09-30 18:26:09 -04:00
|
|
|
} else if (argv[carg][0] == '@') {
|
2005-05-31 11:50:56 -04:00
|
|
|
|
|
|
|
/* Process Startup macroes */
|
|
|
|
if (startup(&argv[carg][1]) == TRUE)
|
|
|
|
/* don't execute emacs.rc */
|
|
|
|
startflag = TRUE;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
/* Process an input file */
|
|
|
|
|
|
|
|
/* set up a buffer for this file */
|
2005-09-30 18:26:09 -04:00
|
|
|
makename(bname, argv[carg]);
|
2005-05-31 11:50:56 -04:00
|
|
|
unqname(bname);
|
|
|
|
|
|
|
|
/* set this to inactive */
|
2015-03-24 05:49:12 -04:00
|
|
|
bp = bfind( bname, TRUE, 0) ;
|
|
|
|
if( bp == NULL) {
|
|
|
|
fputs( "Buffer creation failed!\n", stderr) ;
|
|
|
|
exit( EXIT_FAILURE) ;
|
|
|
|
}
|
|
|
|
|
2019-06-19 07:49:20 -04:00
|
|
|
mystrscpy( bp->b_fname, argv[ carg], sizeof bp->b_fname) ; /* max filename length limited to NFILEN - 1 */
|
2005-05-31 11:50:56 -04:00
|
|
|
bp->b_active = FALSE;
|
|
|
|
if (firstfile) {
|
|
|
|
firstbp = bp;
|
|
|
|
firstfile = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set the modes appropriatly */
|
|
|
|
if (viewflag)
|
|
|
|
bp->b_mode |= MDVIEW;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if UNIX
|
2014-06-18 02:59:40 -04:00
|
|
|
#ifdef SIGHUP
|
2005-09-30 18:26:09 -04:00
|
|
|
signal(SIGHUP, emergencyexit);
|
2014-06-18 02:59:40 -04:00
|
|
|
#endif
|
2005-05-31 11:50:56 -04:00
|
|
|
signal(SIGTERM, emergencyexit);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* if we are C error parsing... run it! */
|
|
|
|
if (errflag) {
|
|
|
|
if (startup("error.cmd") == TRUE)
|
|
|
|
startflag = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if invoked with no other startup files,
|
|
|
|
run the system startup file here */
|
2016-05-18 23:20:21 -04:00
|
|
|
if( (startflag == FALSE) && (startup( "") != TRUE))
|
|
|
|
mloutstr( "Default startup failed!") ;
|
2015-10-05 05:42:57 -04:00
|
|
|
|
2005-09-30 18:26:09 -04:00
|
|
|
discmd = TRUE; /* P.K. */
|
2005-05-31 11:50:56 -04:00
|
|
|
|
|
|
|
/* if there are any files to read, read the first one! */
|
|
|
|
bp = bfind("main", FALSE, 0);
|
2015-03-23 23:59:10 -04:00
|
|
|
if( bp == NULL) {
|
|
|
|
/* "main" buffer has been created during early initialisation */
|
|
|
|
fputs( "Initialisation failure!\n", stderr) ;
|
|
|
|
exit( EXIT_FAILURE) ;
|
|
|
|
}
|
|
|
|
|
2015-01-10 03:23:19 -05:00
|
|
|
if (firstfile == FALSE && readfirst_f()) {
|
2005-05-31 11:50:56 -04:00
|
|
|
swbuffer(firstbp);
|
|
|
|
zotbuf(bp);
|
2015-01-27 07:22:47 -05:00
|
|
|
} else {
|
2005-05-31 11:50:56 -04:00
|
|
|
bp->b_mode |= gmode;
|
2015-01-27 07:22:47 -05:00
|
|
|
upmode() ;
|
|
|
|
}
|
2005-05-31 11:50:56 -04:00
|
|
|
|
2005-09-30 18:26:09 -04:00
|
|
|
/* Deal with startup gotos and searches */
|
2015-01-23 09:13:21 -05:00
|
|
|
if( gotoflag && searchflag)
|
2015-02-12 23:31:59 -05:00
|
|
|
mloutstr( "(Can not search and goto at the same time!)") ;
|
2015-01-23 09:13:21 -05:00
|
|
|
else if( gotoflag) {
|
|
|
|
if( gotoline( TRUE, gline) == FALSE)
|
2015-02-12 23:31:59 -05:00
|
|
|
mloutstr( "(Bogus goto argument)") ;
|
2015-01-23 09:13:21 -05:00
|
|
|
} else if( searchflag)
|
|
|
|
if( forwhunt( FALSE, 0))
|
2015-02-12 23:31:59 -05:00
|
|
|
mloutfmt( "Found on line %d", getcline()) ;
|
2005-05-31 11:50:56 -04:00
|
|
|
|
2016-03-02 08:37:43 -05:00
|
|
|
kbd_loop() ;
|
2016-03-03 08:17:23 -05:00
|
|
|
return EXIT_SUCCESS ; /* never reached */
|
2005-05-31 11:50:56 -04:00
|
|
|
}
|
|
|
|
|
2016-03-02 08:37:43 -05:00
|
|
|
|
2005-05-31 11:50:56 -04:00
|
|
|
/*
|
|
|
|
* Initialize all of the buffers and windows. The buffer name is passed down
|
|
|
|
* as an argument, because the main routine may have been told to read in a
|
|
|
|
* file by default, and we want the buffer name to be right.
|
|
|
|
*/
|
2021-07-29 21:30:12 -04:00
|
|
|
static void edinit( char *bname) {
|
|
|
|
buffer_p bp;
|
2021-08-18 04:54:35 -04:00
|
|
|
window_p wp;
|
2005-05-31 11:50:56 -04:00
|
|
|
|
2021-07-29 21:30:12 -04:00
|
|
|
if( !init_bindings() /* initialize mapping of function to name and key */
|
|
|
|
|| NULL == (bp = bfind( bname, TRUE, 0)) /* First buffer */
|
|
|
|
|| NULL == (blistp = bfind( "*List*", TRUE, BFINVS)) /* Buffer list */
|
|
|
|
|| NULL == (wp = malloc( sizeof *wp))) { /* First window */
|
2015-03-23 23:59:10 -04:00
|
|
|
fputs( "First initialisation failed!\n", stderr) ;
|
|
|
|
exit( EXIT_FAILURE) ;
|
|
|
|
}
|
|
|
|
|
2005-09-30 18:26:09 -04:00
|
|
|
curbp = bp; /* Make this current */
|
|
|
|
wheadp = wp;
|
|
|
|
curwp = wp;
|
|
|
|
wp->w_wndp = NULL; /* Initialize window */
|
|
|
|
wp->w_bufp = bp;
|
|
|
|
bp->b_nwnd = 1; /* Displayed. */
|
|
|
|
wp->w_linep = bp->b_linep;
|
|
|
|
wp->w_dotp = bp->b_linep;
|
|
|
|
wp->w_doto = 0;
|
|
|
|
wp->w_markp = NULL;
|
|
|
|
wp->w_marko = 0;
|
|
|
|
wp->w_toprow = 0;
|
2005-05-31 11:50:56 -04:00
|
|
|
#if COLOR
|
|
|
|
/* initalize colors to global defaults */
|
|
|
|
wp->w_fcolor = gfcolor;
|
|
|
|
wp->w_bcolor = gbcolor;
|
|
|
|
#endif
|
2005-09-30 18:26:09 -04:00
|
|
|
wp->w_ntrows = term.t_nrow - 1; /* "-1" for mode line. */
|
|
|
|
wp->w_force = 0;
|
|
|
|
wp->w_flag = WFMODE | WFHARD; /* Full. */
|
2005-05-31 11:50:56 -04:00
|
|
|
}
|
|
|
|
|
2021-08-24 00:17:40 -04:00
|
|
|
|
2005-05-31 11:50:56 -04:00
|
|
|
/***** Compiler specific Library functions ****/
|
|
|
|
|
2021-08-24 00:17:40 -04:00
|
|
|
#if RAMSIZE
|
2005-05-31 11:50:56 -04:00
|
|
|
|
2021-08-24 00:17:40 -04:00
|
|
|
/* These routines will allow me to track memory usage by placing a layer on
|
|
|
|
top of the standard system malloc() and free() calls. with this code
|
|
|
|
defined, the environment variable, $RAM, will report on the number of
|
|
|
|
bytes allocated via malloc.
|
2005-05-31 11:50:56 -04:00
|
|
|
|
2021-08-24 00:17:40 -04:00
|
|
|
with SHOWRAM defined, the number is also posted on the end of the bottom
|
|
|
|
mode line and is updated whenever it is changed.
|
|
|
|
*/
|
2013-10-11 03:36:36 -04:00
|
|
|
|
2021-08-24 00:17:40 -04:00
|
|
|
#if RAMSHOW
|
|
|
|
static void dspram( void) ;
|
2013-10-11 03:36:36 -04:00
|
|
|
#endif
|
2021-08-24 00:17:40 -04:00
|
|
|
|
|
|
|
void *allocate( size_t nbytes) {
|
|
|
|
nbytes += sizeof nbytes ; /* add overhead to track allocation */
|
|
|
|
size_t *mp = (malloc)( nbytes) ; /* call the function not the macro */
|
|
|
|
if( mp) {
|
|
|
|
*mp++ = nbytes ;
|
|
|
|
envram += nbytes ;
|
2005-05-31 11:50:56 -04:00
|
|
|
#if RAMSHOW
|
2021-08-24 00:17:40 -04:00
|
|
|
dspram() ;
|
2005-05-31 11:50:56 -04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-08-24 00:17:40 -04:00
|
|
|
return mp ;
|
2005-05-31 11:50:56 -04:00
|
|
|
}
|
|
|
|
|
2021-08-24 00:17:40 -04:00
|
|
|
void release( void *mp) {
|
|
|
|
if( mp) {
|
|
|
|
size_t *sp = mp ;
|
|
|
|
sp-- ;
|
2005-05-31 11:50:56 -04:00
|
|
|
/* update amount of ram currently malloced */
|
2021-08-24 00:17:40 -04:00
|
|
|
envram -= *sp ;
|
|
|
|
(free)( sp) ; /* call the function not the macro */
|
2005-05-31 11:50:56 -04:00
|
|
|
#if RAMSHOW
|
2021-08-24 00:17:40 -04:00
|
|
|
dspram() ;
|
2005-05-31 11:50:56 -04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if RAMSHOW
|
2021-08-24 00:17:40 -04:00
|
|
|
static void dspram( void) { /* display the amount of RAM currently malloced */
|
|
|
|
char mbuf[ 20] ;
|
2005-05-31 11:50:56 -04:00
|
|
|
|
2021-08-24 00:17:40 -04:00
|
|
|
TTmove( term.t_nrow, term.t_ncol - 12) ;
|
2005-05-31 11:50:56 -04:00
|
|
|
#if COLOR
|
2021-08-24 00:17:40 -04:00
|
|
|
TTforg( 7) ;
|
|
|
|
TTbacg(0) ;
|
2005-05-31 11:50:56 -04:00
|
|
|
#endif
|
2021-08-24 00:17:40 -04:00
|
|
|
sprintf( mbuf, "[%10u]", envram) ;
|
|
|
|
char *sp = mbuf ;
|
|
|
|
while( *sp)
|
|
|
|
TTputc( *sp++) ;
|
|
|
|
|
|
|
|
TTmove( term.t_nrow, 0) ;
|
|
|
|
movecursor( term.t_nrow, 0) ;
|
2005-05-31 11:50:56 -04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2021-08-15 04:05:31 -04:00
|
|
|
/* On some primitive operation systems, and when emacs is used as
|
2005-05-31 11:50:56 -04:00
|
|
|
a subprogram to a larger project, emacs needs to de-alloc its
|
|
|
|
own used memory
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if CLEAN
|
|
|
|
|
2021-08-18 04:54:35 -04:00
|
|
|
/* cexit()
|
2005-09-30 19:34:11 -04:00
|
|
|
*
|
|
|
|
* int status; return status of emacs
|
|
|
|
*/
|
2015-02-15 01:41:35 -05:00
|
|
|
void cexit( int status) {
|
2021-08-18 04:54:35 -04:00
|
|
|
/* first clean up the windows */
|
|
|
|
window_p wp = wheadp ;
|
|
|
|
while( wp) {
|
|
|
|
window_p tp = wp->w_wndp ;
|
|
|
|
free( wp) ;
|
|
|
|
wp = tp ;
|
2005-05-31 11:50:56 -04:00
|
|
|
}
|
2021-08-18 04:54:35 -04:00
|
|
|
|
|
|
|
wheadp = NULL ;
|
|
|
|
|
|
|
|
/* then the buffers */
|
|
|
|
buffer_p bp ;
|
|
|
|
while( (bp = bheadp) != NULL) {
|
|
|
|
bp->b_nwnd = 0 ;
|
|
|
|
bp->b_flag = 0 ; /* don't say anything about a changed buffer! */
|
|
|
|
zotbuf( bp) ;
|
2005-05-31 11:50:56 -04:00
|
|
|
}
|
|
|
|
|
2021-08-18 04:54:35 -04:00
|
|
|
/* and the kill buffer */
|
|
|
|
kdelete() ;
|
2005-05-31 11:50:56 -04:00
|
|
|
|
2021-08-18 04:54:35 -04:00
|
|
|
/* and the video buffers */
|
|
|
|
vtfree() ;
|
2005-05-31 11:50:56 -04:00
|
|
|
|
2021-08-24 00:17:40 -04:00
|
|
|
(exit)( status) ; /* call the function, not the macro */
|
2005-05-31 11:50:56 -04:00
|
|
|
}
|
|
|
|
#endif
|
2021-08-15 04:05:31 -04:00
|
|
|
|
|
|
|
/* end of main.c */
|