Old UNIX V6 ed, lightly ported to modern systems.

The old UNIX version of 'ed', the line editor.  This is
intended to be for academic interest more than anything and
perhaps shouldn't be used for any serious editing of system
files etc.  You have been warned! :)

The binary is named 'ed-v6' so as not to clobber gnu ed.

There are some major differences between this and POSIX ed
(see the notes at the end for more info.)

NOTE: The linked sources are redistributed on github
with no associated license.

OPTIONS

Build a 32 bit binary on x86_64 (Multilib needed):

  M32=yes

Build a static binary (size is ~ 800k vs. ~ 18k for the
dynamic):

  STATIC=yes


DEVELOPER'S NOTES

 1. compile with a K&R compiler (not even ansified);
    replacing =+ with += and using "=" for default
    assignment
 2. assume 32-bits or better (ldiv and ldivr, increasing the
    sbrk to 4096)
 3. use setjmp+longjmp instead of sysexit+reset
 4. use lseek() instead of seek() (although still assumes
    512 bytes)
 5. copies the tempfilename to work on systems without
    writable strings
 6. use SIG_IGN instead of the numeric value "1"
 7. remove the goto errlab since that doesn't work in ANSI C
 8. commented out getpid() in favor of a local copy
 9. renamed unix() to run_unix() because some systems (at
    least some linux) annoyingly do a -Dunix=1
10. use sizeof(buf) instead of buf
11. renamed putchar() to putc() because gcc and clang
    generate errors if you create a function called putchar()
    with a different signature.
12. added a prototype for errfunc() because clang refuses to
    honor `-ansi`

I've tried to keep these modifications as minimal as
possible in an effort to preserve the editor that I learned
unix on.

`ed.c.orig` is included so you can verify how minimal my
changes were.


MAINTAINER'S NOTES

Compilation:

Added -D_XOPEN_SOURCE=500 to compile with fcntl.h in
glibc-2.23.

Manual page:

If you are unfamiliar with ed then gnu ed has a very good
info page.

This is the closest I can find to the original man page:

https://freebsd.org/cgi/man.cgi?query=ed&manpath=Unix+Seventh+Edition

Among other things, there is no -p option, single , or ;
will throw errors, no G//, and r does not support shell
commands.  H and h are also unsupported, so errors will lack
any explanation.

Using with rlwrap:

This does work with rlwrap, however it repeats every
command.  This doesn't affect the functionality, but it can
look quite confusing to have everything repeated.
