home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume20 / opcom / detab.c < prev    next >
C/C++ Source or Header  |  1989-10-22  |  1KB  |  55 lines

  1. /*++
  2. /* NAME
  3. /*    detab 1
  4. /* SUMMARY
  5. /*    expand tabs to blanks
  6. /* PROJECT
  7. /*    documentation
  8. /* SYNOPSIS
  9. /*    detab
  10. /* DESCRIPTION
  11. /*    Detab is a filter that expands tab stops in its standard input
  12. /*    to blanks. A tab stop distance of eight blanks is assumed.
  13. /* BUGS
  14. /*    This program does not handle backspaces.
  15. /* AUTHOR(S)
  16. /*    Wietse Venema
  17. /*    Eindhoven University of Technology
  18. /*    Department of Mathematics and Computer Science
  19. /*    Den Dolech 2, P.O. Box 513, 5600 MB Eindhoven, The Netherlands
  20. /* CREATION DATE
  21. /*    Sep 14 1985
  22. /* LAST MODIFICATION
  23. /*    Mon May  4 20:32:48 GMT+1:00 1987
  24. /* VERSION/RELEASE
  25. /*    1.3
  26. /*--*/
  27.  
  28. #include <stdio.h>
  29.  
  30. #define BLANK    ' '
  31.  
  32. main()
  33. {
  34.     register int c;        /* character buffer */
  35.     register int ccount = 0;    /* nr of characters printed on current line */
  36.  
  37.     while ((c = getchar()) != EOF) {
  38.     switch (c) {
  39.  
  40.         case '\r':
  41.         case '\n':  putchar(c);
  42.             ccount = 0;
  43.             break;
  44.  
  45.         case '\t':  do { putchar(BLANK); } while (++ccount & 7);
  46.             break;
  47.  
  48.         default:    putchar(c);
  49.             ccount++;
  50.             break;
  51.     }
  52.     }
  53.     exit(0);
  54. }
  55.