|
|
1.1 root 1: /*
2: * Copyright (c) 1988 Regents of the University of California.
3: * All rights reserved.
4: *
5: * Redistribution is only permitted until one year after the first shipment
6: * of 4.4BSD by the Regents. Otherwise, redistribution and use in source and
7: * binary forms are permitted provided that: (1) source distributions retain
8: * this entire copyright notice and comment, and (2) distributions including
9: * binaries display the following acknowledgement: This product includes
10: * software developed by the University of California, Berkeley and its
11: * contributors'' in the documentation or other materials provided with the
12: * distribution and in all advertising materials mentioning features or use
13: * of this software. Neither the name of the University nor the names of
14: * its contributors may be used to endorse or promote products derived from
15: * this software without specific prior written permission.
16: * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
17: * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
18: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19: *
20: * @(#)gets.c 7.5 (Berkeley) 6/28/90
21: */
22:
23: gets(buf)
24: char *buf;
25: {
26: register int c;
27: register char *lp;
28:
29: for (lp = buf;;)
30: switch(c = getchar() & 0177) {
31: case '\n':
32: case '\r':
33: *lp = '\0';
34: return;
35: case '\b':
36: case '\177':
37: if (lp > buf) {
38: lp--;
39: putchar('\b');
40: putchar(' ');
41: putchar('\b');
42: }
43: break;
44: case '#':
45: if (lp > buf)
46: --lp;
47: break;
48: case 'r'&037: {
49: register char *p;
50:
51: putchar('\n');
52: for (p = buf; p < lp; ++p)
53: putchar(*p);
54: break;
55: }
56: case '@':
57: case 'u'&037:
58: case 'w'&037:
59: lp = buf;
60: putchar('\n');
61: break;
62: default:
63: *lp++ = c;
64: }
65: /*NOTREACHED*/
66: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.