Formatting and typos.

This commit is contained in:
Renaud 2021-08-15 16:05:31 +08:00
parent 79c3dfa4d9
commit 731ea754bb
2 changed files with 58 additions and 59 deletions

9
main.c
View File

@ -1,9 +1,6 @@
/* main.c -- */ /* main.c -- */
/* /* µEMACS 4.2
* main.c
*
* µEMACS 4.2
* *
* Based on: * Based on:
* *
@ -438,7 +435,7 @@ static void dspram( void)
#endif #endif
#endif #endif
/* On some primitave operation systems, and when emacs is used as /* On some primitive operation systems, and when emacs is used as
a subprogram to a larger project, emacs needs to de-alloc its a subprogram to a larger project, emacs needs to de-alloc its
own used memory own used memory
*/ */
@ -483,3 +480,5 @@ void cexit( int status) {
exit(status); exit(status);
} }
#endif #endif
/* end of main.c */

108
tcap.c
View File

@ -1,9 +1,7 @@
/* tcap.c -- implements terminal.h */ /* tcap.c -- implements terminal.h */
#include "terminal.h" #include "terminal.h"
/* tcap.c /* Unix V7 SysV and BS4 Termcap video driver
*
* Unix V7 SysV and BS4 Termcap video driver
* *
* modified by Petri Kutvonen * modified by Petri Kutvonen
*/ */
@ -35,9 +33,9 @@ boolean sgarbf = TRUE ; /* TRUE if screen is garbage */
char sres[ 16] ; /* current screen resolution */ char sres[ 16] ; /* current screen resolution */
/* NORMAL, CGA, EGA, VGA */ /* NORMAL, CGA, EGA, VGA */
#if UNIX # if UNIX
#include <signal.h> # include <signal.h>
#endif # endif
#define MARGIN 8 #define MARGIN 8
#define SCRSIZ 64 #define SCRSIZ 64
@ -57,33 +55,33 @@ static void tcapscrollregion(int top, int bot);
static void putpad(char *str); static void putpad(char *str);
static void tcapopen(void); static void tcapopen(void);
#if PKCODE # if PKCODE
static void tcapclose(void); static void tcapclose(void);
#endif # endif
#if COLOR # if COLOR
static void tcapfcol(void); static void tcapfcol(void);
static void tcapbcol(void); static void tcapbcol(void);
#endif # endif
#if SCROLLCODE # if SCROLLCODE
static void tcapscroll_reg(int from, int to, int linestoscroll); static void tcapscroll_reg(int from, int to, int linestoscroll);
static void tcapscroll_delins(int from, int to, int linestoscroll); static void tcapscroll_delins(int from, int to, int linestoscroll);
#endif # endif
#define TCAPSLEN 315 #define TCAPSLEN 315
static char tcapbuf[TCAPSLEN]; static char tcapbuf[TCAPSLEN];
static char *_UP, _PC, *CM, *CE, *CL, *SO, *SE; static char *_UP, _PC, *CM, *CE, *CL, *SO, *SE;
#if PKCODE # if PKCODE
static char *TI, *TE; static char *TI, *TE;
#if USE_BROKEN_OPTIMIZATION # if USE_BROKEN_OPTIMIZATION
static int term_init_ok = 0; static int term_init_ok = 0;
#endif # endif
#endif # endif
#if SCROLLCODE # if SCROLLCODE
static char *CS, *DL, *AL, *SF, *SR; static char *CS, *DL, *AL, *SF, *SR;
#endif # endif
struct terminal term = { struct terminal term = {
480, /* actual 479 on 2560x1440 landscape terminal window */ 480, /* actual 479 on 2560x1440 landscape terminal window */
@ -96,11 +94,11 @@ struct terminal term = {
SCRSIZ, SCRSIZ,
NPAUSE, NPAUSE,
tcapopen, tcapopen,
#if PKCODE # if PKCODE
tcapclose, tcapclose,
#else # else
ttclose, ttclose,
#endif # endif
tcapkopen, tcapkopen,
tcapkclose, tcapkclose,
ttgetc, ttgetc,
@ -112,14 +110,14 @@ struct terminal term = {
tcapbeep, tcapbeep,
tcaprev, tcaprev,
tcapcres tcapcres
#if COLOR # if COLOR
, tcapfcol, , tcapfcol,
tcapbcol tcapbcol
#endif # endif
#if SCROLLCODE # if SCROLLCODE
, NULL /* set dynamically at open time */ , NULL /* set dynamically at open time */
#endif # endif
}; } ;
static void tcapopen(void) static void tcapopen(void)
{ {
@ -128,9 +126,9 @@ static void tcapopen(void)
char *tv_stype; char *tv_stype;
int int_col, int_row; int int_col, int_row;
#if PKCODE && USE_BROKEN_OPTIMIZATION # if PKCODE && USE_BROKEN_OPTIMIZATION
if (!term_init_ok) { if (!term_init_ok) {
#endif # endif
if ((tv_stype = getenv("TERM")) == NULL) { if ((tv_stype = getenv("TERM")) == NULL) {
fputs( "Environment variable TERM not defined!\n", stderr) ; fputs( "Environment variable TERM not defined!\n", stderr) ;
exit( EXIT_FAILURE) ; exit( EXIT_FAILURE) ;
@ -177,7 +175,7 @@ static void tcapopen(void)
SO = tgetstr("so", &p); SO = tgetstr("so", &p);
if (SO != NULL) if (SO != NULL)
revexist = TRUE; revexist = TRUE;
#if PKCODE # if PKCODE
if (tgetnum("sg") > 0) { /* can reverse be used? P.K. */ if (tgetnum("sg") > 0) { /* can reverse be used? P.K. */
revexist = FALSE; revexist = FALSE;
SE = NULL; SE = NULL;
@ -185,7 +183,7 @@ static void tcapopen(void)
} }
TI = tgetstr("ti", &p); /* terminal init and exit */ TI = tgetstr("ti", &p); /* terminal init and exit */
TE = tgetstr("te", &p); TE = tgetstr("te", &p);
#endif # endif
if (CL == NULL || CM == NULL || _UP == NULL) { if (CL == NULL || CM == NULL || _UP == NULL) {
fputs( "Incomplete termcap entry\n", stderr) ; fputs( "Incomplete termcap entry\n", stderr) ;
@ -194,7 +192,7 @@ static void tcapopen(void)
if (CE == NULL) /* will we be able to use clear to EOL? */ if (CE == NULL) /* will we be able to use clear to EOL? */
eolexist = FALSE; eolexist = FALSE;
#if SCROLLCODE # if SCROLLCODE
CS = tgetstr("cs", &p); CS = tgetstr("cs", &p);
SF = tgetstr("sf", &p); SF = tgetstr("sf", &p);
SR = tgetstr("sr", &p); SR = tgetstr("sr", &p);
@ -210,20 +208,20 @@ static void tcapopen(void)
} else { } else {
term.t_scroll = NULL; term.t_scroll = NULL;
} }
#endif # endif
if (p >= &tcapbuf[TCAPSLEN]) { if (p >= &tcapbuf[TCAPSLEN]) {
fputs( "Terminal description too big!\n", stderr) ; fputs( "Terminal description too big!\n", stderr) ;
exit( EXIT_FAILURE) ; exit( EXIT_FAILURE) ;
} }
#if PKCODE && USE_BROKEN_OPTIMIZATION # if PKCODE && USE_BROKEN_OPTIMIZATION
term_init_ok = 1; term_init_ok = 1;
} }
#endif # endif
ttopen(); ttopen();
} }
#if PKCODE # if PKCODE
static void tcapclose(void) static void tcapclose(void)
{ {
putpad(tgoto(CM, 0, term.t_nrow)); putpad(tgoto(CM, 0, term.t_nrow));
@ -231,26 +229,26 @@ static void tcapclose(void)
ttflush(); ttflush();
ttclose(); ttclose();
} }
#endif # endif
static void tcapkopen(void) static void tcapkopen(void)
{ {
#if PKCODE # if PKCODE
putpad(TI); putpad(TI);
ttflush(); ttflush();
ttrow = 999; ttrow = 999;
ttcol = 999; ttcol = 999;
sgarbf = TRUE; sgarbf = TRUE;
#endif # endif
strcpy(sres, "NORMAL"); strcpy(sres, "NORMAL");
} }
static void tcapkclose(void) static void tcapkclose(void)
{ {
#if PKCODE # if PKCODE
putpad(TE); putpad(TE);
ttflush(); ttflush();
#endif # endif
} }
static void tcapmove(int row, int col) static void tcapmove(int row, int col)
@ -288,7 +286,7 @@ static int tcapcres(char *res)
return TRUE; return TRUE;
} }
#if SCROLLCODE # if SCROLLCODE
/* move howmanylines lines starting at from to to */ /* move howmanylines lines starting at from to to */
static void tcapscroll_reg(int from, int to, int howmanylines) static void tcapscroll_reg(int from, int to, int howmanylines)
@ -340,9 +338,9 @@ static void tcapscrollregion(int top, int bot)
putpad(tgoto(CS, bot, top)); putpad(tgoto(CS, bot, top));
} }
#endif # endif
#if COLOR # if COLOR
/* No colors here, ignore this. */ /* No colors here, ignore this. */
static void tcapfcol(void) static void tcapfcol(void)
{ {
@ -351,7 +349,7 @@ static void tcapfcol(void)
static void tcapbcol(void) static void tcapbcol(void)
{ {
} }
#endif # endif
static void tcapbeep(void) static void tcapbeep(void)
{ {
@ -363,3 +361,5 @@ static void putpad(char *str)
tputs( str, 1, (int (*)( int)) ttputc) ; tputs( str, 1, (int (*)( int)) ttputc) ;
} }
#endif /* TERMCAP */ #endif /* TERMCAP */
/* end of tcap.c */