~sircmpwn/sbase

ee0336bc3b6f55839785427d6184e6f897055e31 — Drew DeVault 4 months ago 7ef4038 master
Port ed to mercury
2 files changed, 0 insertions(+), 83 deletions(-)

M Makefile
M ed.c
M Makefile => Makefile +0 -8
@@ 46,27 46,19 @@ LIBUTFSRC =\
LIBUTIL = libutil.a
LIBUTILSRC =\
	libutil/concat.c\
	libutil/cp.c\
	libutil/crypt.c\
	libutil/ealloc.c\
	libutil/enmasse.c\
	libutil/eprintf.c\
	libutil/eregcomp.c\
	libutil/estrtod.c\
	libutil/fnck.c\
	libutil/fshut.c\
	libutil/getlines.c\
	libutil/human.c\
	libutil/linecmp.c\
	libutil/md5.c\
	libutil/memmem.c\
	libutil/mkdirp.c\
	libutil/mode.c\
	libutil/parseoffset.c\
	libutil/putword.c\
	libutil/reallocarray.c\
	libutil/recurse.c\
	libutil/rm.c\
	libutil/sha1.c\
	libutil/sha224.c\
	libutil/sha256.c\

M ed.c => ed.c +0 -75
@@ 1,6 1,4 @@
/* See LICENSE file for copyright and license details. */
#include <sys/stat.h>
#include <fcntl.h>
#include <regex.h>
#include <unistd.h>



@@ 902,44 900,6 @@ quit(void)
}

static void
execsh(void)
{
	static String cmd;
	char *p;
	int c, repl = 0;

	skipblank();
	if ((c = input()) != '!') {
		back(c);
		cmd.siz = 0;
	} else if (cmd.siz) {
		--cmd.siz;
		repl = 1;
	} else {
		error("no previous command");
	}

	while ((c = input()) != EOF && c != '\n') {
		if (c == '%' && (cmd.siz == 0 || cmd.str[cmd.siz - 1] != '\\')) {
			if (savfname[0] == '\0')
				error("no current filename");
			repl = 1;
			for (p = savfname; *p; ++p)
				addchar(*p, &cmd);
		} else {
			addchar(c, &cmd);
		}
	}
	addchar('\0', &cmd);

	if (repl)
		puts(cmd.str);
	system(cmd.str);
	if (optdiag)
		puts("!");
}

static void
getrhs(int delim)
{
	int c;


@@ 1095,9 1055,6 @@ repeat:
		repidx = 0;
		getlst();
		goto repeat;
	case '!':
		execsh();
		break;
	case EOF:
		if (cmdline.siz == 0)
			quit();


@@ 1380,35 1337,6 @@ usage(void)
}

static void
sigintr(int n)
{
	signal(SIGINT, sigintr);
	error("interrupt");
}

static void
sighup(int dummy)
{
	int n;
	char *home = getenv("HOME"), fname[FILENAME_MAX];

	if (modflag) {
		line1 = nextln(0);
		line2 = lastln;
		if (!setjmp(savesp)) {
			dowrite("ed.hup", 1);
		} else if (home && !setjmp(savesp)) {
			n = snprintf(fname,
			             sizeof(fname), "%s/%s", home, "ed.hup");
			if (n < sizeof(fname) && n > 0)
				dowrite(fname, 1);
		}
	}
	exstatus = 1;
	quit();
}

static void
edit(void)
{
	for (;;) {


@@ 1460,9 1388,6 @@ main(int argc, char *argv[])
		usage();

	if (!setjmp(savesp)) {
		signal(SIGINT, sigintr);
		signal(SIGHUP, sighup);
		signal(SIGQUIT, SIG_IGN);
		init(*argv);
	}
	edit();