xref: /csrg-svn/usr.bin/more/vecho.c (revision 35283)
135209Sbostic /*
235209Sbostic  * Copyright (c) 1988 Mark Nudleman
335209Sbostic  * Copyright (c) 1988 Regents of the University of California.
435209Sbostic  * All rights reserved.
535209Sbostic  *
635209Sbostic  * Redistribution and use in source and binary forms are permitted
735209Sbostic  * provided that the above copyright notice and this paragraph are
835209Sbostic  * duplicated in all such forms and that any documentation,
935209Sbostic  * advertising materials, and other materials related to such
1035209Sbostic  * distribution and use acknowledge that the software was developed
11*35283Sbostic  * by Mark Nudleman and the University of California, Berkeley.  The
12*35283Sbostic  * name of Mark Nudleman or the
1335209Sbostic  * University may not be used to endorse or promote products derived
1435209Sbostic  * from this software without specific prior written permission.
1535209Sbostic  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
1635209Sbostic  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
1735209Sbostic  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1835209Sbostic  */
1935209Sbostic 
2035209Sbostic #ifndef lint
2135209Sbostic char copyright[] =
2235209Sbostic "@(#) Copyright (c) 1988 Mark Nudleman.\n\
23*35283Sbostic @(#) Copyright (c) 1988 Regents of the University of California.\n\
2435209Sbostic  All rights reserved.\n";
2535209Sbostic #endif /* not lint */
2635209Sbostic 
2735209Sbostic #ifndef lint
28*35283Sbostic static char sccsid[] = "@(#)vecho.c	5.2 (Berkeley) 07/25/88";
2935209Sbostic #endif /* not lint */
3035209Sbostic 
3135209Sbostic /*
3235209Sbostic  * This dumb little program emulates the System V "echo" command,
3335209Sbostic  * to accomodate BSD systems which don't understand the \c escape,
3435209Sbostic  * meaning don't echo a newline.  BSD uses "echo -n".
3535209Sbostic  */
3635209Sbostic 
3735209Sbostic #include <stdio.h>
3835209Sbostic 
3935209Sbostic int putnl;
4035209Sbostic 
main(argc,argv)4135209Sbostic main(argc, argv)
4235209Sbostic 	int argc;
4335209Sbostic 	char *argv[];
4435209Sbostic {
4535209Sbostic 	putnl = 1;
4635209Sbostic 	while (--argc > 0)
4735209Sbostic 	{
4835209Sbostic 		vecho(*++argv);
4935209Sbostic 		if (argc > 1)
5035209Sbostic 			putchar(' ');
5135209Sbostic 	}
5235209Sbostic 	if (putnl)
5335209Sbostic 		putchar('\n');
5435209Sbostic }
5535209Sbostic 
vecho(str)5635209Sbostic vecho(str)
5735209Sbostic 	char *str;
5835209Sbostic {
5935209Sbostic 	register char *s;
6035209Sbostic 
6135209Sbostic 	for (s = str;  *s != '\0';  s++)
6235209Sbostic 	{
6335209Sbostic 		if (*s == '\\' && s[1] == 'c')
6435209Sbostic 		{
6535209Sbostic 			putnl = 0;
6635209Sbostic 			return;
6735209Sbostic 		}
6835209Sbostic 		putchar(*s);
6935209Sbostic 	}
7035209Sbostic }
71