home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / prof_c / util / tabs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-08-11  |  926 b   |  51 lines

  1. /*
  2.  *    tabs -- a group of cooperating functions that set
  3.  *    and report the settings of "tabstops"
  4.  */
  5.  
  6. #include <local\std.h>
  7.  
  8. static char Tabstops[MAXLINE];
  9.  
  10. /*
  11.  *    fixtabs -- set up fixed-interval tabstops
  12.  */
  13. void
  14. fixtabs(interval)
  15. register int interval;
  16. {
  17.     register int i;
  18.  
  19.     for (i = 0; i < MAXLINE; i++)
  20.         Tabstops[i] = (i % interval == 0) ? 1 : 0;
  21. } /* end fixtabs() */
  22.  
  23. /*
  24.  *    vartabs -- set up variable tabstops from an array
  25.  *    integers terminated by a -1 entry
  26.  */
  27. void
  28. vartabs(list)
  29. int *list;
  30. {
  31.     register int i;
  32.  
  33.     /* initialize the tabstop array */
  34.     for (i = 0; i < MAXLINE; ++i)
  35.         Tabstops[i] = 0;
  36.  
  37.     /* set user-sprcified tabstops */
  38.     while (*list != -1)
  39.         Tabstops[*++list] = 1;
  40. } /* end vartabs() */
  41.  
  42. /*
  43.  *    tabstop -- return non-zero if col is a tabstop
  44.  */
  45. int
  46. tabstop(col)
  47. register int col;
  48. {
  49.     return (col >= MAXLINE ? 1 : Tabstops[col]);
  50. } /* end tabstop() */
  51.