date and time created 88/09/12 11:06:39 by bostic
[unix-history] / usr / src / sys / stand.att / gets.c
CommitLineData
3f62363f
KB
1/*
2 * Copyright (c) 1988 Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms are permitted
9c50374f
KB
6 * provided that the above copyright notice and this paragraph are
7 * duplicated in all such forms and that any documentation,
8 * advertising materials, and other materials related to such
9 * distribution and use acknowledge that the software was developed
10 * by the University of California, Berkeley. The name of the
11 * University may not be used to endorse or promote products derived
12 * from this software without specific prior written permission.
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
3f62363f 16 *
9c50374f 17 * @(#)gets.c 7.3 (Berkeley) %G%
3f62363f
KB
18 */
19
20gets(buf)
21 char *buf;
22{
23 register int c;
24 register char *lp;
25
26 for (lp = buf;;)
27 switch(c = getchar() & 0177) {
28 case '\n':
29 case '\r':
30 *lp = '\0';
31 return;
32 case '\b':
33 if (lp > buf) {
34 lp--;
35 putchar('\b');
36 putchar(' ');
37 putchar('\b');
38 }
39 break;
40 case '#':
41 case '\177':
42 if (lp > buf)
43 --lp;
44 break;
efd2fb19
KB
45 case 'r'&037: {
46 register char *p;
47
48 putchar('\n');
49 for (p = buf; p < lp; ++p)
50 putchar(*p);
51 break;
52 }
3f62363f
KB
53 case '@':
54 case 'u'&037:
efd2fb19 55 case 'w'&037:
3f62363f
KB
56 lp = buf;
57 putchar('\n');
58 break;
59 default:
60 *lp++ = c;
61 }
62 /*NOTREACHED*/
63}