xref: /original-bsd/usr.bin/more/vecho.c (revision c02b9ad6)
1 /*
2  * Copyright (c) 1988 Mark Nudleman
3  * Copyright (c) 1988 Regents of the University of California.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms are permitted
7  * provided that the above copyright notice and this paragraph are
8  * duplicated in all such forms and that any documentation,
9  * advertising materials, and other materials related to such
10  * distribution and use acknowledge that the software was developed
11  * by Mark Nudleman and the University of California, Berkeley.  The
12  * name of Mark Nudleman or the
13  * University may not be used to endorse or promote products derived
14  * from this software without specific prior written permission.
15  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
17  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18  */
19 
20 #ifndef lint
21 char copyright[] =
22 "@(#) Copyright (c) 1988 Mark Nudleman.\n\
23 @(#) Copyright (c) 1988 Regents of the University of California.\n\
24  All rights reserved.\n";
25 #endif /* not lint */
26 
27 #ifndef lint
28 static char sccsid[] = "@(#)vecho.c	5.2 (Berkeley) 07/25/88";
29 #endif /* not lint */
30 
31 /*
32  * This dumb little program emulates the System V "echo" command,
33  * to accomodate BSD systems which don't understand the \c escape,
34  * meaning don't echo a newline.  BSD uses "echo -n".
35  */
36 
37 #include <stdio.h>
38 
39 int putnl;
40 
41 main(argc, argv)
42 	int argc;
43 	char *argv[];
44 {
45 	putnl = 1;
46 	while (--argc > 0)
47 	{
48 		vecho(*++argv);
49 		if (argc > 1)
50 			putchar(' ');
51 	}
52 	if (putnl)
53 		putchar('\n');
54 }
55 
56 vecho(str)
57 	char *str;
58 {
59 	register char *s;
60 
61 	for (s = str;  *s != '\0';  s++)
62 	{
63 		if (*s == '\\' && s[1] == 'c')
64 		{
65 			putnl = 0;
66 			return;
67 		}
68 		putchar(*s);
69 	}
70 }
71