home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / compiler / small_c / cb / sources / dtb.c < prev    next >
Encoding:
C/C++ Source or Header  |  1985-08-11  |  832 b   |  43 lines

  1.  
  2. /*
  3. ** dtb.c -- convert tabs to equivalent blanks
  4. **
  5. ** Copyright 1982 J. E. Hendrix.  All rights reserved.
  6. */
  7. #include <stdio.h>
  8. #include "tools.h"
  9. #define NOCCARGC
  10. #define MAXLIN1 (MAXLINE+1)
  11. main(argc,argv) int argc, *argv; {
  12.   char c, tabs[MAXLIN1];
  13.   int col, i;
  14.   auxbuf(stdin, 4096);
  15.   if(settab(tabs, argc, argv)==ERR) {
  16.     fputs("usage: DTB [#]... [+#]\n", stderr);
  17.     abort(7);
  18.     }
  19.   col=1;
  20.   while((c=getchar())!=EOF) {
  21.     poll(YES);
  22.     if(c=='\t')
  23.       while(YES) {
  24.         cout(' ', stdout);
  25.         ++col;
  26.         if(tabpos(col, tabs)==YES) break;
  27.         }
  28.     else if(c=='\n') {
  29.       cout('\n', stdout);
  30.       col=1;
  31.       }
  32.     else {
  33.       cout(c, stdout);
  34.       ++col;
  35.       }
  36.     }
  37.   fclose(stdout);
  38.   }
  39. #include "settab.c"
  40. #include "tabpos.c"
  41. #include "out.c"
  42.  
  43.