From f33305f8949c11bd4839360a28781d565bcc3656 Mon Sep 17 00:00:00 2001 From: Serge Vakulenko Date: Tue, 6 Jan 2015 13:42:43 -0800 Subject: [PATCH] Levee editor compiled for RetroBSD. --- rootfs.manifest | 2 + src/cmd/Makefile | 2 +- src/cmd/levee/.gitignore | 2 +- src/cmd/levee/Makefile | 56 +++++++++++++------------- src/cmd/levee/Makefile-linux | 56 ++++++++++++++++++++++++++ src/cmd/levee/config.h | 9 ++--- src/cmd/levee/termcap.i | 6 ++- src/cmd/levee/unixcall.c | 77 ++++++++++++++++++++++++++++++------ 8 files changed, 161 insertions(+), 49 deletions(-) create mode 100644 src/cmd/levee/Makefile-linux diff --git a/rootfs.manifest b/rootfs.manifest index ab93532..f3e5130 100644 --- a/rootfs.manifest +++ b/rootfs.manifest @@ -241,6 +241,7 @@ file /bin/login mode 04755 file /bin/lol file /bin/ls +file /bin/lv file /bin/mail mode 04755 file /bin/make @@ -781,6 +782,7 @@ file /share/man/cat1/id.0 file /share/man/cat1/la.0 file /share/man/cat1/lcc.0 file /share/man/cat1/ld.0 +file /share/man/cat1/lv.0 file /share/man/cat1/passwd.0 file /share/man/cat1/printf.0 file /share/man/cat1/ranlib.0 diff --git a/src/cmd/Makefile b/src/cmd/Makefile index 5d1484f..48a8d88 100644 --- a/src/cmd/Makefile +++ b/src/cmd/Makefile @@ -12,7 +12,7 @@ CFLAGS += -Werror # /bin SUBDIR = adb adc-demo aout ar as awk basic cc chflags chpass \ cpp dc diff emg env fdisk find forth fstat glcdtest \ - hostname id la lcc lcpp ld ls login make man med \ + hostname id la lcc lcpp ld levee ls login make man med \ more nm passwd picoc portio printf pwm \ rdprof ranlib re renice retroforth scm setty sl \ sed sh smallc smlrc stty sysctl test uname wiznet xargs \ diff --git a/src/cmd/levee/.gitignore b/src/cmd/levee/.gitignore index 49f759e..c39f21e 100644 --- a/src/cmd/levee/.gitignore +++ b/src/cmd/levee/.gitignore @@ -1 +1 @@ -lev +lv diff --git a/src/cmd/levee/Makefile b/src/cmd/levee/Makefile index 4c65fa0..b1ec20f 100644 --- a/src/cmd/levee/Makefile +++ b/src/cmd/levee/Makefile @@ -1,40 +1,40 @@ -# makefile for Levee +# +# Public Domain. 1995/03/13 - Steven Schultz +# +TOPSRC = $(shell cd ../../..; pwd) +include $(TOPSRC)/target.mk -exedir=/usr/local/bin -mandir=/usr/local/man -CC=cc +#CFLAGS += -Werror +LIBS += -ltermcap -CFLAGS=-g -LDFLAGS=-g +OBJS = blockio.o display.o editcor.o exec.o find.o \ + unixcall.o globals.o insert.o main.o misc.o \ + modify.o move.o ucsd.o undo.o wildargs.o \ + version.o +MAN = lv.0 -OBJS = blockio.o display.o editcor.o exec.o find.o \ - unixcall.o globals.o insert.o main.o misc.o \ - modify.o move.o ucsd.o undo.o wildargs.o \ - version.o +all: lv ${MAN} -lev: $(OBJS) - $(CC) $(LDFLAGS) -o lev $(OBJS) -lcurses +lv: ${OBJS} + ${CC} ${LDFLAGS} -o lv.elf ${OBJS} ${LIBS} + ${OBJDUMP} -S lv.elf > lv.dis + ${SIZE} lv.elf + ${ELF2AOUT} lv.elf $@ && rm lv.elf version.o: version.c VERSION - $(CC) $(CFLAGS) -c -DVERSION=\"`cat VERSION`\" version.c + $(CC) $(CFLAGS) -c -DVERSION=\"`cat VERSION`\" version.c + +.SUFFIXES: .0 .1 + +.1.0: + ${MANROFF} $*.1 > $@ clean: - rm -f *.o lev + rm -f *.o *.elf ${MAN} lv *.elf *.dis tags *~ -distclean spotless: clean - rm -f Makefile config.cmd config.sub config.h config.mak config.log config.md - -install: install.bin install.man - -install.bin: lev - /home/sergev/Daily/workdir-2015-01-06/levee-3.5a/config.md $(PREFIX)$(exedir) - /usr/bin/install -s -m 755 lev $(PREFIX)$(exedir)/levee - /bin/ln -s -f levee $(PREFIX)$(exedir)/lv - -install.man: - /home/sergev/Daily/workdir-2015-01-06/levee-3.5a/config.md $(PREFIX)$(mandir)/man1 - /usr/bin/install -m 444 lv.1 $(PREFIX)$(mandir)/man1/levee.1 - echo ".so man1/levee.1" > $(PREFIX)$(mandir)/man1/lv.1 +install: all + install lv ${DESTDIR}/bin/ + cp lv.0 ${DESTDIR}/share/man/cat1/ # Dependencies diff --git a/src/cmd/levee/Makefile-linux b/src/cmd/levee/Makefile-linux new file mode 100644 index 0000000..4c65fa0 --- /dev/null +++ b/src/cmd/levee/Makefile-linux @@ -0,0 +1,56 @@ +# makefile for Levee + +exedir=/usr/local/bin +mandir=/usr/local/man +CC=cc + +CFLAGS=-g +LDFLAGS=-g + +OBJS = blockio.o display.o editcor.o exec.o find.o \ + unixcall.o globals.o insert.o main.o misc.o \ + modify.o move.o ucsd.o undo.o wildargs.o \ + version.o + +lev: $(OBJS) + $(CC) $(LDFLAGS) -o lev $(OBJS) -lcurses + +version.o: version.c VERSION + $(CC) $(CFLAGS) -c -DVERSION=\"`cat VERSION`\" version.c + +clean: + rm -f *.o lev + +distclean spotless: clean + rm -f Makefile config.cmd config.sub config.h config.mak config.log config.md + +install: install.bin install.man + +install.bin: lev + /home/sergev/Daily/workdir-2015-01-06/levee-3.5a/config.md $(PREFIX)$(exedir) + /usr/bin/install -s -m 755 lev $(PREFIX)$(exedir)/levee + /bin/ln -s -f levee $(PREFIX)$(exedir)/lv + +install.man: + /home/sergev/Daily/workdir-2015-01-06/levee-3.5a/config.md $(PREFIX)$(mandir)/man1 + /usr/bin/install -m 444 lv.1 $(PREFIX)$(mandir)/man1/levee.1 + echo ".so man1/levee.1" > $(PREFIX)$(mandir)/man1/lv.1 + +# Dependencies + +blockio.o : levee.h extern.h blockio.c config.h +display.o : levee.h extern.h termcap.i display.c config.h +editcor.o : levee.h extern.h editcor.c config.h +exec.o : levee.h extern.h exec.c config.h +find.o : levee.h extern.h grep.h find.c config.h +globals.o : levee.h globals.c config.h +insert.o : levee.h extern.h insert.c config.h +main.o : levee.h extern.h main.c config.h +misc.o : levee.h extern.h misc.c config.h +modify.o : levee.h extern.h grep.h modify.c config.h +move.o : levee.h extern.h move.c config.h +rmxcall.o : levee.h rmxcall.c config.h +ucsd.o : levee.h extern.h ucsd.c config.h +undo.o : levee.h extern.h undo.c config.h +unixcall.o : levee.h extern.h unixcall.c config.h +wildargs.o : levee.h extern.h wildargs.c config.h diff --git a/src/cmd/levee/config.h b/src/cmd/levee/config.h index ba6ffe2..0187ecb 100644 --- a/src/cmd/levee/config.h +++ b/src/cmd/levee/config.h @@ -5,25 +5,22 @@ #ifndef __AC_LEVEE_D #define __AC_LEVEE_D 1 +// Size of editor data buffer. +#define SIZE 16000 -#define OS_LINUX 1 -//#define SIZE 256000 #define OS_UNIX 1 #define HAVE_STRING_H 1 #define HAVE_MEMSET 1 #define HAVE_STRCHR 1 #define HAVE_BASENAME 1 -#define HAVE_LIBGEN_H 1 #define HAVE_SIGNAL_H 1 #define HAVE_SIGNAL 1 #define HAVE_TGETENT 1 -#define HAVE_TERMCAP_H 1 #define USE_TERMCAP 1 #define HAVE_MVCUR 1 #define mvcur __mvcur -#define HAVE_TERMIOS_H 1 #define HAVE_TCGETATTR 1 -#define PATH_FIND "/usr/bin/find" +#define PATH_FIND "/bin/find" #define PATH_SED "/bin/sed" #endif/* __AC_LEVEE_D */ diff --git a/src/cmd/levee/termcap.i b/src/cmd/levee/termcap.i index 4e2ce9e..6781408 100644 --- a/src/cmd/levee/termcap.i +++ b/src/cmd/levee/termcap.i @@ -216,7 +216,11 @@ tc_init() #else #include -#include +#ifdef HAVE_TERMCAP_H +# include +#else +# include +#endif #include #include diff --git a/src/cmd/levee/unixcall.c b/src/cmd/levee/unixcall.c index 26a2d77..f94b765 100644 --- a/src/cmd/levee/unixcall.c +++ b/src/cmd/levee/unixcall.c @@ -25,17 +25,15 @@ #ifdef OS_UNIX #include "extern.h" -#include +#ifdef HAVE_TERMIOS_H +# include +#endif #include #include #include #include #include -#if USE_TERMCAP -#include -#endif - int min(a,b) int a, b; @@ -53,13 +51,8 @@ int a, b; void strput(s) char *s; { -#if USE_TERMCAP - if (s) - tputs(s, 1, putchar); -#else if (s) write(1, s, strlen(s)); -#endif } #if !HAVE_BASENAME @@ -76,6 +69,9 @@ char *s; } #endif +static int ioset = 0; + +#ifdef HAVE_TERMIOS_H #if !HAVE_TCGETATTR #define tcgetattr(fd,t) ioctl(fd, TCGETS, t) @@ -83,8 +79,6 @@ char *s; #define TCSANOW TCSETAF #endif - -static int ioset = 0; static struct termios old; void @@ -118,6 +112,65 @@ fixcon() } } +#else /* HAVE_TERMIOS_H */ + +static struct sgttyb old; +static struct tchars oldtchars; +static struct ltchars oldltchars; + +void +initcon() +{ + struct tchars new_tc; + struct ltchars new_ltc; + struct sgttyb new; + + if (!ioset) { + ioctl(0, TIOCGETC, &oldtchars); + ioctl(0, TIOCGLTC, &oldltchars); + + /* get editing keys */ + Erasechar = 0177; + eraseline = 'U' & 037; + + new_tc = oldtchars; + new_tc.t_eofc = -1; /* end-of-file */ + new_tc.t_quitc = -1; /* quit */ + new_tc.t_intrc = -1; /* interrupt */ + new_ltc = oldltchars; + new_ltc.t_suspc = -1; /* stop process */ + new_ltc.t_dsuspc = -1; /* delayed stop process */ + new_ltc.t_rprntc = -1; /* reprint line */ + new_ltc.t_flushc = -1; /* flush output */ + new_ltc.t_werasc = -1; /* word erase */ + new_ltc.t_lnextc = -1; /* literal next character */ + ioctl(0, TIOCSETC, &new_tc); + ioctl(0, TIOCSLTC, &new_ltc); + + ioctl(0, TIOCGETP, &old); + new = old; + + new.sg_flags &= ~(ECHO | CRMOD | XTABS | RAW); + new.sg_flags |= CBREAK; + + ioctl(0, TIOCSETP, &new); + ioset = 1; + } +} + +void +fixcon() +{ + if (ioset) { + ioctl(0, TIOCSETP, &old); + ioctl(0, TIOCSETC, &oldtchars); + ioctl(0, TIOCSLTC, &oldltchars); + ioset = 0; + } +} + +#endif /* HAVE_TERMIOS_H */ + int getKey() {