home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / SRC / less.v177.lzh / less / vecho.c < prev    next >
C/C++ Source or Header  |  1991-07-16  |  572b  |  42 lines

  1. /*
  2.  * This dumb little program emulates the System V "echo" command,
  3.  * to accommodate BSD systems which don't understand the \c escape,
  4.  * meaning don't echo a newline.  BSD uses "echo -n".
  5.  */
  6.  
  7. #include <stdio.h>
  8.  
  9. int putnl;
  10.  
  11. main(argc, argv)
  12.     int argc;
  13.     char *argv[];
  14. {
  15.     putnl = 1;
  16.     while (--argc > 0)
  17.     {
  18.         vecho(*++argv);
  19.         if (argc > 1)
  20.             putchar(' ');
  21.     }
  22.     if (putnl)
  23.         putchar('\n');
  24.     exit(0);
  25. }
  26.  
  27. vecho(str)
  28.     char *str;
  29. {
  30.     register char *s;
  31.  
  32.     for (s = str;  *s != '\0';  s++)
  33.     {
  34.         if (*s == '\\' && s[1] == 'c')
  35.         {
  36.             putnl = 0;
  37.             return;
  38.         }
  39.         putchar(*s);
  40.     }
  41. }
  42.