Line editing

From: Andrew Valencia <vandys_at_nospam.org>
Date: Tue Oct 11 1994 - 14:25:56 PDT

As an amusing test of shared libraries, I took the "getline" library off the
net and ported it into the VSTa C library in place of the current canonical
input processing. My old Bourne shell binary now does line editing, as does
anything else which uses canonical (i.e., line input) TTY mode!

There were a couple interesting issues in making this work. First,
getline() wanted (and needed) the "prompt". Of course, any existing binary
write()'s the prompt and then read()'s a line. I wanted existing binaries
to work, so changing them to call getline() was out.

I did this by recording the canonical-mode write()'s data, and then riffling
through it when a read() happened to see what was left on the last line.
Gross, yes. It seems to work.

Second, I had problems in that per-file-descriptor state wasn't going to
help me--stdin and stdout are distinct file descriptors, each with its own
state. I tweaked up vsta/libc/tty.c so the prompt state can be shared
between the two.

As another nice side effect of all this, ^D now does the right thing as EOF.

                                                        Andy
Received on Tue Oct 11 13:12:28 1994

This archive was generated by hypermail 2.1.8 : Thu Sep 22 2005 - 15:11:46 PDT