aboutsummaryrefslogtreecommitdiff
path: root/academic/ed-v6/README
blob: 373767752c84a0c37cb3ab7b428dde617b4faa6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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://www.freebsd.org/cgi/man.cgi?query=ed&apropos=0&sektion=0&manpath=Unix%20Seventh%20Edition&arch=default&format=html

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.