diff options
-rw-r--r-- | usr.bin/mg/Makefile | 134 | ||||
-rw-r--r-- | usr.bin/mg/fileio.c | 8 | ||||
-rw-r--r-- | usr.bin/mg/main.c | 2 | ||||
-rw-r--r-- | usr.bin/mg/ttyio.c | 15 |
4 files changed, 28 insertions, 131 deletions
diff --git a/usr.bin/mg/Makefile b/usr.bin/mg/Makefile index af0fca401aa..7bfc53659b9 100644 --- a/usr.bin/mg/Makefile +++ b/usr.bin/mg/Makefile @@ -2,11 +2,9 @@ # Is there a better way to do the rebuilds, other than using # the links? -SYS = sysv -LIBS = -# CDEFS gets defines, and gets passed to lint. CFLAGS gets flags, and doesn't -# get passed to lint. -# +LDADD+= -lcurses +DPADD+= ${LIBCURSES} + # (Common) compile-time options: # # DO_METAKEY -- if bit 7 is set for a key, treat like a META key @@ -17,117 +15,15 @@ LIBS = # PREFIXREGION -- enable function "prefix-region" # REGEX -- create regular expression functions # -#CDEFS = -DDO_METAKEY -CDEFS = -DDO_METAKEY -DPREFIXREGION -CFLAGS = $(CDEFS) -CFLAGSNOO = $(CDEFS) - -# Objects which only depend on the "standard" includes -OBJS = basic.o dir.o dired.o file.o line.o match.o paragraph.o \ - random.o region.o search.o version.o window.o word.o - -# Those with unique requirements -IND = buffer.o display.o echo.o extend.o help.o kbd.o keymap.o \ - macro.o main.o modes.o regex.o re_search.o - -# System dependent objects -OOBJS = cinfo.o spawn.o ttyio.o tty.o ttykbd.o - -OBJ = $(OBJS) $(IND) $(OOBJS) fileio.o - -OSRCS = cinfo.c fileio.c spawn.c ttyio.c tty.c ttykbd.c -SRCS = basic.c dir.c dired.c file.c line.c match.c paragraph.c \ - random.c region.c search.c version.c window.c word.c \ - buffer.c display.c echo.c extend.c help.c kbd.c keymap.c \ - macro.c main.c modes.c regex.c re_search.c - -OINCS = ttydef.h sysdef.h chrdef.h -INCS = def.h - -mg: $(OBJ) - cc $(CFLAGS) -o mg $(OBJ) $(LIBS) - -tar: - tar -c -X tar.exclude -f mg.tar . - -# strip mg once you're satisfied it'll run -- makes it much smaller -strip: - strip mg - -lint: $(SRCS) $(OSRCS) $(INCS) $(OINCS) - lint -ahbz $(CDEFS) $(SRCS) $(OSRCS) - -# routines that can't be compiled optimized -# region causes the optimizer to blow up -# region.o: region.c -# cc $(CFLAGSNOO) -c region.c - -# echo blows up when compiled optimized. -# echo.o: echo.c -# cc $(CFLAGSNOO) -c echo.c - -$(OBJ): $(INCS) $(OINCS) - - -dir.r search.o: $(INCS) $(OINCS) - -regex.o re_search.o: $(INCS) $(OINCS) regex.h - -kbd.o: $(INCS) $(OINCS) macro.h kbd.h key.h - -macro.o main.o: $(INCS) $(OINCS) macro.h - -buffer.o display.o keymap.o help.o modes.o dired.o fileio.o: \ - $(INCS) $(OINCS) kbd.h - -extend.o: $(INCS) $(OINCS) kbd.h macro.h key.h - -help.o: $(INCS) $(OINCS) kbd.h key.h macro.h - -echo.o: $(INCS) $(OINCS) key.h macro.h - -$(OOBJS): $(INCS) $(OINCS) - -# sysdef.h: sys/$(SYS)/sysdef.h # Update links, if needed. -# rm -f sysdef.h -# ln sys/$(SYS)/sysdef.h . - -# ttydef.h: sys/default/ttydef.h -# rm -f ttydef.h -# ln sys/default/ttydef.h . - -# chrdef.h: sys/default/chrdef.h -# rm -f chrdef.h -# ln sys/default/chrdef.h . - -# fileio.c: sys/$(SYS)/fileio.c -# rm -f fileio.c -# ln sys/$(SYS)/fileio.c . - -# spawn.c: sys/$(SYS)/spawn.c -# rm -f spawn.c -# ln sys/$(SYS)/spawn.c . - -# tty.c: sys/default/tty.c -# rm -f tty.c -# ln sys/default/tty.c . - -# ttyio.c: sys/$(SYS)/ttyio.c -# rm -f ttyio.c -# ln sys/$(SYS)/ttyio.c . - -# ttykbd.c: sys/default/ttykbd.c -# rm -f ttykbd.c -# ln sys/default/ttykbd.c . - -# cinfo.c: sys/default/cinfo.c -# rm -f cinfo.c -# ln sys/default/cinfo.c . - -# port: $(SRCS) $(INCS) -# rm -f port -# tar cfb port 1 $? - -# clean:; rm -f $(OBJ) $(OSRCS) $(OINCS) -clean:; rm -f $(OBJ) - +CDEFS = -DDO_METAKEY +CDEFS+= -DDO_METAKEY -DPREFIXREGION -DXKEYS -DBACKUP +CFLAGS+=$(CDEFS) + +SRCS= cinfo.c fileio.c spawn.c ttyio.c tty.c ttykbd.c \ + basic.c dir.c dired.c file.c line.c match.c paragraph.c \ + random.c region.c search.c version.c window.c word.c \ + buffer.c display.c echo.c extend.c help.c kbd.c keymap.c \ + macro.c main.c modes.c regex.c re_search.c +PROG= mg + +.include <bsd.prog.mk> diff --git a/usr.bin/mg/fileio.c b/usr.bin/mg/fileio.c index 7f5ab6c34c4..300ecce18b4 100644 --- a/usr.bin/mg/fileio.c +++ b/usr.bin/mg/fileio.c @@ -306,7 +306,9 @@ register char *fn; #ifndef NO_STARTUP #include <sys/file.h> +#ifndef F_OK #define F_OK 04 /* for stupid Sys V */ +#endif /* * Find a startup file for the user and return its name. As a service @@ -568,9 +570,9 @@ len = strlen(cp); * SV files are fairly short. For BSD, something more general * would be required. */ -if ((preflen + DIRSIZ) > NFILEN) +if ((preflen + MAXNAMLEN) > NFILEN) return(NULL); -if ((strlen(dir) + DIRSIZ) > NFILEN) +if ((strlen(dir) + MAXNAMLEN) > NFILEN) listing = 0; /* loop over the specified directory, making up the list of files */ @@ -589,7 +591,7 @@ if (fp < 0) { last = NULL; /* clear entry after last so we can treat d_name as ASCIZ */ -dirbuf.d_name[DIRSIZ] = 0; +dirbuf.d_name[MAXNAMLEN] = 0; while (1) { if (read(fp, &dirbuf, sizeof(struct direct)) <= 0) { break; diff --git a/usr.bin/mg/main.c b/usr.bin/mg/main.c index 6b5625af0b7..e14fb6095f1 100644 --- a/usr.bin/mg/main.c +++ b/usr.bin/mg/main.c @@ -20,7 +20,7 @@ extern char prompt[], *promptp; /* delayed prompting */ static VOID edinit(); -VOID +int main(argc, argv) int argc; char **argv; diff --git a/usr.bin/mg/ttyio.c b/usr.bin/mg/ttyio.c index c3ddf420ef9..7cd8c7978b7 100644 --- a/usr.bin/mg/ttyio.c +++ b/usr.bin/mg/ttyio.c @@ -19,15 +19,15 @@ #include <sys/types.h> #include <fcntl.h> -#include <termio.h> +#include <termios.h> #define NOBUF 512 /* Output buffer size. */ char obuf[NOBUF]; /* Output buffer. */ int nobuf; /* buffer count */ -static struct termio ot; /* entry state of the terminal */ -static struct termio nt; /* editor's terminal state */ +static struct termios ot; /* entry state of the terminal */ +static struct termios nt; /* editor's terminal state */ static int ttyactivep = FALSE; /* terminal in editor mode? */ static int ttysavedp = FALSE; /* terminal state saved? */ @@ -58,7 +58,7 @@ ttopen() if( !ttysavedp ) { - if (ioctl(0, TCGETA, &ot) < 0) + if (tcgetattr(0, &ot) < 0) abort(); nt = ot; /* save entry state */ nt.c_cc[VMIN] = 1; /* one character read is OK */ @@ -75,7 +75,7 @@ ttopen() ttysavedp = TRUE; } - if (ioctl(0, TCSETAF, &nt) < 0) + if (tcsetattr(0, TCSAFLUSH, &nt) < 0) abort(); /* This really belongs in tty/termcap... */ @@ -126,7 +126,8 @@ ttclose() if(!ttysavedp || !ttyactivep) return; ttflush(); - if (ioctl(0, TCSETAF, &ot) < 0 || fcntl( 0, F_SETFL, kbdflgs ) < 0) + if (tcsetattr(0, TCSAFLUSH, &ot) < 0 || + fcntl( 0, F_SETFL, kbdflgs ) < 0) abort(); ttyactivep = FALSE; } @@ -251,8 +252,6 @@ static void alrm() ttwait() { - int alrm(); - if (kbdqp) return FALSE; /* already pending input */ if (setjmp(tohere)) |