I have always been a proponent of generalizing /dev/zero such that it supports both block
and character mode, and the minor node number specifies the byte you get mapped into
memory or read from a file.
So then you could just make a character device /dev/backspace whose minor node number was
8, and /dev/beep whose minor node number was 7!
-Don
On 7 Nov 2017, at 05:21, Will Senn
<will.senn(a)gmail.com> wrote:
I wrote a snippet from my K&R C studies to convert tabs and backspaces to \t \b to
display them, the code looks like this:
/* ex 1-8 */
main()
{
int c, sf;
while((c = getchar()) != EOF) {
if(c == '\t')
printf("\\t");
if(c == '\b')
printf("\\b");
else
putchar(c);
}
}
I'm not looking for code review, but the code is intended to replace the tabs and
backspaces with \t and \b respectively, but I haven't been able to test it because I
can't seem to make a backspace character appear in input. In later unices, ^V
followed by the backspace would work, but that's not part of v7. Backspace itself is
my erase character, so anytime I just type it, it backspaces :).
Thanks,
Will
--
GPG Fingerprint: 68F4 B3BD 1730 555A 4462 7D45 3EAA 5B6D A982 BAAF