From e11ed9187f9825c657637120a57bf5972dc09c10 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Tue, 23 Jul 2019 21:04:50 +0800 Subject: [PATCH] Remove V7, MSC, TURBO conditional code. Partial remove of MSDOS. --- defines.h | 2 +- ebind.c | 71 ------------------------- estruct.h | 64 +++++------------------ file.c | 2 +- fileio.c | 17 +----- flook.c | 14 +---- input.c | 8 +-- main.c | 9 ---- search.c | 2 +- spawn.c | 154 ++++-------------------------------------------------- termio.c | 60 +++------------------ 11 files changed, 34 insertions(+), 369 deletions(-) diff --git a/defines.h b/defines.h index 4564237..b6074ed 100644 --- a/defines.h +++ b/defines.h @@ -5,7 +5,7 @@ /* Must define one of - V7 | USG | BSD | MSDOS + USG | BSD */ #define USG 1 diff --git a/ebind.c b/ebind.c index b3f6bec..d3747e4 100644 --- a/ebind.c +++ b/ebind.c @@ -318,77 +318,6 @@ struct key_tab keytab[NBINDS] = { {META | 0x7F, delbword} , -#if MSDOS - {SPEC | CONTROL | '_', forwhunt} - , - {SPEC | CONTROL | 'S', backhunt} - , - {SPEC | 71, (fn_t) gotobol} - , - {SPEC | 72, (fn_t) backline} - , - {SPEC | 73, (fn_t) backpage} - , - {SPEC | 75, (fn_t) backchar} - , - {SPEC | 77, (fn_t) forwchar} - , - {SPEC | 79, (fn_t) gotoeol} - , - {SPEC | 80, (fn_t) forwline} - , - {SPEC | 81, (fn_t) forwpage} - , - {SPEC | 82, insspace} - , - {SPEC | 83, forwdel} - , - {SPEC | 115, backword} - , - {SPEC | 116, forwword} - , -#if WORDPRO - {SPEC | 132, gotobop} - , - {SPEC | 118, gotoeop} - , -#endif - {SPEC | 84, cbuf1} - , - {SPEC | 85, cbuf2} - , - {SPEC | 86, cbuf3} - , - {SPEC | 87, cbuf4} - , - {SPEC | 88, cbuf5} - , - {SPEC | 89, cbuf6} - , - {SPEC | 90, cbuf7} - , - {SPEC | 91, cbuf8} - , - {SPEC | 92, cbuf9} - , - {SPEC | 93, cbuf10} - , -#if PKCODE - {SPEC | 117, (fn_t) gotoeob} - , - {SPEC | 119, (fn_t) gotobob} - , - {SPEC | 141, gotobop} - , - {SPEC | 145, gotoeop} - , - {SPEC | 146, yank} - , - {SPEC | 147, killregion} - , -#endif -#endif - #if VT220 {SPEC | '1', (fn_t) gotobob /* fisearch */} , /* VT220 keys */ diff --git a/estruct.h b/estruct.h index 39cbef6..ed95fd7 100644 --- a/estruct.h +++ b/estruct.h @@ -17,22 +17,13 @@ #ifdef MSDOS #undef MSDOS #endif -#ifdef EGA -#undef EGA -#endif /* Machine/OS definitions. */ -#if defined(AUTOCONF) || defined(MSDOS) || defined(BSD) || defined(SYSV) +#if defined(AUTOCONF) || defined(BSD) || defined(SYSV) /* Make an intelligent guess about the target system. */ -#if defined(__TURBOC__) -#define MSDOS 1 /* MS/PC DOS 3.1-4.0 with Turbo C 2.0 */ -#else -#define MSDOS 0 -#endif - #if defined(BSD) || defined(sun) || defined(ultrix) || defined(__osf__) #ifndef BSD #define BSD 1 /* Berkeley UNIX */ @@ -53,31 +44,19 @@ #define USG 0 #endif -#define V7 0 /* No more. */ - #else +# define BSD 0 /* UNIX BSD 4.2 and ULTRIX */ +# define USG 1 /* UNIX system V */ +#endif /*autoconf */ -#define MSDOS 1 /* MS-DOS */ -#define V7 0 /* V7 UNIX or Coherent or BSD4.2 */ -#define BSD 0 /* UNIX BSD 4.2 and ULTRIX */ -#define USG 0 /* UNIX system V */ - -#endif /*autoconf */ +#define MSDOS 0 /* MS-DOS */ +/* Compiler definitions */ #ifndef AUTOCONF - -/* Compiler definitions */ -#define UNIX 0 /* a random UNIX compiler */ -#define MSC 0 /* MicroSoft C compiler, versions 3 up */ -#define TURBO 1 /* Turbo C/MSDOS */ - +# define UNIX 1 /* a random UNIX compiler */ #else - -#define UNIX (V7 | BSD | USG) -#define MSC 0 -#define TURBO MSDOS - -#endif /*autoconf */ +# define UNIX (BSD | USG) +#endif /*autoconf */ /* Debugging options */ @@ -164,25 +143,6 @@ #define IBMCHR MSDOS /* use IBM PC character set P.K. */ #define SCROLLCODE 1 /* scrolling code P.K. */ -/* System dependant library redefinitions, structures and includes. */ - -#if TURBO -#include -#include -#undef peek -#undef poke -#define peek(a,b,c,d) movedata(a,b,FP_SEG(c),FP_OFF(c),d) -#define poke(a,b,c,d) movedata(FP_SEG(c),FP_OFF(c),a,b,d) -#endif - -#if MSDOS & MSC -#include -#include -#define peek(a,b,c,d) movedata(a,b,FP_SEG(c),FP_OFF(c),d) -#define poke(a,b,c,d) movedata(FP_SEG(c),FP_OFF(c),a,b,d) -#define movmem(a, b, c) memcpy(b, a, c) -#endif - /* Define some ability flags. */ #if IBMPC @@ -191,10 +151,10 @@ #define MEMMAP 0 #endif -#if MSDOS | V7 | USG | BSD -#define ENVFUNC 1 +#if USG | BSD +# define ENVFUNC 1 #else -#define ENVFUNC 0 +# define ENVFUNC 0 #endif /* DIFCASE represents the integer difference between upper diff --git a/file.c b/file.c index 8da71e3..25ca2a2 100644 --- a/file.c +++ b/file.c @@ -395,7 +395,7 @@ void makename( bname_t bname, const char *fname) && cp1[-1] != '/') --cp1; #endif -#if V7 | USG | BSD +#if USG | BSD while (cp1 != &fname[0] && cp1[-1] != '/') --cp1; #endif diff --git a/fileio.c b/fileio.c index 6d83b83..9c46487 100644 --- a/fileio.c +++ b/fileio.c @@ -2,11 +2,6 @@ #include "fileio.h" -#ifdef CTRLZ -#undef CTRLZ -#endif -#define CTRLZ 0 /* add a ^Z at end of files under MSDOS only */ - /* FILEIO.C * * The routines in this file read and write ASCII files from the disk. All of @@ -70,17 +65,7 @@ fio_code ffclose(void) ftype = FTYPE_NONE ; fcode = FCODE_ASCII ; -#if MSDOS & CTRLZ - fputc(26, ffp); /* add a ^Z at the end of the file */ -#endif - -#if V7 | USG | BSD | (MSDOS & (MSC | TURBO)) - if (fclose(ffp) != FALSE) - return FIOERR; -#else - fclose(ffp); -#endif - return FIOSUC; + return (fclose( ffp) != FALSE) ? FIOERR : FIOSUC ; } /* diff --git a/flook.c b/flook.c index da0ff28..055aa44 100644 --- a/flook.c +++ b/flook.c @@ -13,17 +13,7 @@ /* possible names and paths of help files under different OSs */ const char *pathname[] = { -#if MSDOS - "emacs.rc", - "emacs.hlp", - "\\sys\\public\\", - "\\usr\\bin\\", - "\\bin\\", - "\\", - "" -#endif - -#if V7 | BSD | USG +#if BSD | USG ".emacsrc", "emacs.hlp", #if PKCODE @@ -107,7 +97,7 @@ char *flook( const char *fname, boolean hflag) } #if ENVFUNC -#if V7 | USG | BSD +#if USG | BSD #define PATHCHR ':' #else #define PATHCHR ';' diff --git a/input.c b/input.c index b56c836..c368406 100644 --- a/input.c +++ b/input.c @@ -24,13 +24,7 @@ #include "utf8.h" #include "wrapper.h" -#if PKCODE -#if MSDOS && TURBO -#include -#endif -#endif - -#if PKCODE && (UNIX || (MSDOS && TURBO)) +#if PKCODE && UNIX #define COMPLC 1 #else #define COMPLC 0 diff --git a/main.c b/main.c index 4aca7cb..b696561 100644 --- a/main.c +++ b/main.c @@ -92,15 +92,6 @@ #include "version.h" #include "window.h" -/* For MSDOS, increase the default stack space. */ -#if MSDOS & TURBO -#if PKCODE -extern unsigned _stklen = 20000; -#else -extern unsigned _stklen = 32766; -#endif -#endif - #if UNIX static void emergencyexit(int signr) { diff --git a/search.c b/search.c index 9840cec..38498ca 100644 --- a/search.c +++ b/search.c @@ -1287,7 +1287,7 @@ static int mcstr(void) if (status) { rtpcm = &tapcm[0]; while (--mj >= 0) { -#if MSC | TURBO | USG | BSD | V7 +#if USG | BSD *rtpcm++ = *--mcptr; #endif } diff --git a/spawn.c b/spawn.c index 90a84e8..3ae6a19 100644 --- a/spawn.c +++ b/spawn.c @@ -5,7 +5,7 @@ * * Various operating system access commands. * - * @@ -26,16 +26,12 @@ #include "window.h" -#if V7 | USG | BSD +#if USG | BSD #include #ifdef SIGWINCH #endif #endif -#if MSDOS & (MSC | TURBO) -#include -#endif - /* * Create a subjob with a copy of the command intrepreter in it. When the @@ -44,7 +40,7 @@ */ int spawncli(int f, int n) { -#if V7 | USG | BSD +#if USG | BSD char *cp; #endif @@ -52,16 +48,7 @@ int spawncli(int f, int n) if (restflag) return resterr(); -#if MSDOS & (MSC | TURBO) - movecursor(term.t_nrow, 0); /* Seek to last line. */ - TTflush(); - TTkclose(); - shellprog(""); - TTkopen(); - sgarbf = TRUE; - return TRUE; -#endif -#if V7 | USG | BSD +#if USG | BSD movecursor(term.t_nrow, 0); /* Seek to last line. */ TTflush(); TTclose(); /* stty to old settings */ @@ -128,7 +115,7 @@ int spawn( int f, int n) { if( restflag) return resterr(); -#if V7 | USG | BSD +#if USG | BSD s = newmlarg( &line, "!", 0) ; if( s != TRUE) return s ; @@ -167,7 +154,7 @@ int execprg( int f, int n) { if( restflag) return resterr() ; -#if V7 | USG | BSD +#if USG | BSD s = newmlarg( &line, "$", 0) ; if( s != TRUE) return s ; @@ -244,7 +231,7 @@ int pipecmd( int f, int n) { return FALSE ; } } -#if V7 | USG | BSD +#if USG | BSD TTflush(); TTclose(); /* stty to old modes */ TTkclose(); @@ -332,7 +319,7 @@ int filter_buffer( int f, int n) { return FALSE ; } -#if V7 | USG | BSD +#if USG | BSD TTputc('\n'); /* Already have '\r' */ TTflush(); TTclose(); /* stty to old modes */ @@ -366,127 +353,4 @@ int filter_buffer( int f, int n) { return TRUE; } - -#if MSDOS & (TURBO | MSC) - -/* - * SHELLPROG: Execute a command in a subshell - * - * char *cmd; Incoming command line to execute - */ -int shellprog(char *cmd) -{ - char *shell; /* Name of system command processor */ - char *p; /* Temporary pointer */ - char swchar; /* switch character to use */ - union REGS regs; /* parameters for dos call */ - char comline[NSTRING]; /* constructed command line */ - - /* detect current switch character and set us up to use it */ - regs.h.ah = 0x37; /* get setting data */ - regs.h.al = 0x00; /* get switch character */ - intdos(®s, ®s); - swchar = (char) regs.h.dl; - - /* get name of system shell */ - if ((shell = getenv("COMSPEC")) == NULL) { - return FALSE; /* No shell located */ - } - - /* trim leading whitespace off the command */ - while (*cmd == ' ' || *cmd == '\t') /* find out if null command */ - cmd++; - - /** If the command line is not empty, bring up the shell **/ - /** and execute the command. Otherwise, bring up the **/ - /** shell in interactive mode. **/ - - if (*cmd) { - strcpy(comline, shell); - strcat(comline, " "); - comline[strlen(comline) + 1] = 0; - comline[strlen(comline)] = swchar; - strcat(comline, "c "); - strcat(comline, cmd); - return execprog(comline); - } else - return execprog(shell); -} - -/* - * EXECPROG: - * A function to execute a named program - * with arguments - * - * char *cmd; Incoming command line to execute - */ -int execprog(char *cmd) -{ - char *sp; /* temporary string pointer */ - char f1[38]; /* FCB1 area (not initialized */ - char f2[38]; /* FCB2 area (not initialized */ - char prog[NSTRING]; /* program filespec */ - char tail[NSTRING]; /* command tail with length byte */ - union REGS regs; /* parameters for dos call */ - struct SREGS segreg; /* segment registers for dis call */ - struct pblock { /* EXEC parameter block */ - short envptr; /* 2 byte pointer to environment string */ - char *cline; /* 4 byte pointer to command line */ - char *fcb1; /* 4 byte pointer to FCB at PSP+5Ch */ - char *fcb2; /* 4 byte pointer to FCB at PSP+6Ch */ - } pblock; - - /* parse the command name from the command line */ - sp = prog; - while (*cmd && (*cmd != ' ') && (*cmd != '\t')) - *sp++ = *cmd++; - *sp = 0; - - /* and parse out the command tail */ - while (*cmd && ((*cmd == ' ') || (*cmd == '\t'))) - ++cmd; - *tail = (char) (strlen(cmd)); /* record the byte length */ - strcpy(&tail[1], cmd); - strcat(&tail[1], "\r"); - - /* look up the program on the path trying various extentions */ - if ((sp = flook(prog, TRUE)) == NULL) - if ((sp = flook(strcat(prog, ".exe"), TRUE)) == NULL) { - strcpy(&prog[strlen(prog) - 4], ".com"); - if ((sp = flook(prog, TRUE)) == NULL) - return FALSE; - } - strcpy(prog, sp); - - /* get a pointer to this PSPs environment segment number */ - segread(&segreg); - - /* set up the EXEC parameter block */ - pblock.envptr = 0; /* make the child inherit the parents env */ - pblock.fcb1 = f1; /* point to a blank FCB */ - pblock.fcb2 = f2; /* point to a blank FCB */ - pblock.cline = tail; /* parameter line pointer */ - - /* and make the call */ - regs.h.ah = 0x4b; /* EXEC Load or Execute a Program */ - regs.h.al = 0x00; /* load end execute function subcode */ - segreg.ds = ((unsigned long) (prog) >> 16); /* program name ptr */ - regs.x.dx = (unsigned int) (prog); - segreg.es = ((unsigned long) (&pblock) >> 16); /* set up param block ptr */ - regs.x.bx = (unsigned int) (&pblock); -#if TURBO | MSC - intdosx(®s, ®s, &segreg); - if (regs.x.cflag == 0) { - regs.h.ah = 0x4d; /* get child process return code */ - intdos(®s, ®s); /* go do it */ - rval = regs.x.ax; /* save child's return code */ - } else -#if MSC - rval = -1; -#else - rval = -_doserrno; /* failed child call */ -#endif -#endif - return (rval < 0) ? FALSE : TRUE; -} -#endif +/* end of spawn.c */ diff --git a/termio.c b/termio.c index 16adce7..20962bd 100644 --- a/termio.c +++ b/termio.c @@ -27,11 +27,6 @@ int ttrow = HUGE ; /* Row location of HW cursor */ int ttcol = HUGE ; /* Column location of HW cursor */ -#if MSDOS & (MSC | TURBO) -union REGS rg; /* cpu register for use of DOS calls */ -int nxtchar = -1; /* character held from type ahead */ -#endif - #if USG /* System V */ #include #include @@ -47,7 +42,7 @@ static struct termio ntermio ; /* characteristics to use inside */ #endif #endif -#if V7 | BSD +#if BSD #include /* for stty/gtty functions */ #include struct sgttyb ostate; /* saved tty state */ @@ -89,14 +84,6 @@ char tobuf[TBUFSIZ]; /* terminal output buffer */ */ void ttopen(void) { -#if MSDOS & (TURBO | (PKCODE & MSC)) - /* kill the CONTROL-break interupt */ - rg.h.ah = 0x33; /* control-break check dos call */ - rg.h.al = 1; /* set the current state */ - rg.h.dl = 0; /* set it OFF */ - intdos(&rg, &rg); /* go for it! */ -#endif - #if USG ioctl(0, TCGETA, &otermio); /* save old settings */ ntermio.c_iflag = 0; /* setup new settings */ @@ -118,7 +105,7 @@ void ttopen(void) kbdpoll = FALSE; #endif -#if V7 | BSD +#if BSD gtty(0, &ostate); /* save old state */ gtty(0, &nstate); /* get base of new state */ #if XONXOFF @@ -165,14 +152,6 @@ void ttopen(void) */ void ttclose(void) { -#if MSDOS & (TURBO | (PKCODE & MSC)) - /* restore the CONTROL-break interupt */ - rg.h.ah = 0x33; /* control-break check dos call */ - rg.h.al = 1; /* set the current state */ - rg.h.dl = 1; /* set it ON */ - intdos(&rg, &rg); /* go for it! */ -#endif - #if USG #if PKCODE ioctl(0, TCSETAW, &otermio); /* restore terminal settings */ @@ -182,7 +161,7 @@ void ttclose(void) fcntl(0, F_SETFL, kbdflgs); #endif -#if V7 | BSD +#if BSD stty(0, &ostate); ioctl(0, TIOCSETC, &otchars); /* Place old character into K */ #if BSD & PKCODE @@ -208,10 +187,7 @@ int ttputc( unicode_t c) { * up. A no-operation on systems where byte at a time terminal I/O is done. */ void ttflush( void) { -#if MSDOS -#endif - -#if V7 | USG | BSD +#if USG | BSD /* * Add some terminal output success checking, sometimes an orphaned * process may be left looping on SunOS 4.1. @@ -240,24 +216,7 @@ void ttflush( void) { * Very simple on CPM, because the system can do exactly what you want. */ int ttgetc( void) { -#if MSDOS & (MSC | TURBO) - int c; /* character read */ - - /* if a char already is ready, return it */ - if (nxtchar >= 0) { - c = nxtchar; - nxtchar = -1; - return c; - } - - /* call the dos to get a char */ - rg.h.ah = 7; /* dos Direct Console Input call */ - intdos(&rg, &rg); - c = rg.h.al; /* grab the char */ - return c & 255; -#endif - -#if V7 | BSD +#if BSD return 255 & fgetc(stdin); /* 8BIT P.K. */ #endif @@ -281,13 +240,6 @@ int ttgetc( void) { int typahead( void) { -#if MSDOS & (MSC | TURBO) - if (kbhit() != 0) - return TRUE; - else - return FALSE; -#endif - #if BSD int x; /* holds # of pending chars */ @@ -306,7 +258,7 @@ int typahead( void) return kbdqp; #endif -#if !UNIX & !MSDOS +#if !UNIX return FALSE; #endif }