home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / program / compiler / szadb21b / source / src / tsttabs.c < prev    next >
C/C++ Source or Header  |  1990-05-16  |  877b  |  58 lines

  1. #include <stdio.h>
  2.  
  3. #define MAXLIN 80
  4. #define YES 1
  5. #define NO  0
  6. #define TABSP 8
  7. #define TABPOS(col)    (((col) < MAXLIN) ? tabs[(col)] : YES)
  8.  
  9. int             tabs[MAXLIN];
  10.  
  11. main ()
  12. {
  13.     int            *ptab, col, c;
  14.  
  15.     ptab = tabs;
  16.     settab (ptab);
  17.     col = 0;
  18.     while (EOF != (c = getchar ())) {
  19.     switch (c) {
  20.     case '\t':
  21.         while (YES != tabpos (col)) {
  22.         putchar (' ');
  23.         col++;
  24.         }
  25.         putchar (' ');
  26.         col++;
  27.         break;
  28.     case '\n':
  29.         putchar ('\n');
  30.         col = 0;
  31.         break;
  32.     default:
  33.         putchar (c);
  34.         col++;
  35.         break;
  36.     }
  37.     }
  38.     exit (0);
  39. }
  40.  
  41.  
  42. tabpos (col)
  43.     int             col;
  44. {
  45.     return (TABPOS (col));
  46. }
  47.  
  48. settab (tabp, up)
  49.     short          *tabp;
  50.     long           *up;
  51. {
  52.     int             i;
  53.  
  54.     for (i = 1; i <= MAXLIN; i++) {
  55.     *tabp++ = (0 == (i % TABSP));
  56.     }
  57. }
  58.