home *** CD-ROM | disk | FTP | other *** search
/ vsiftp.vmssoftware.com / VSIPUBLIC@vsiftp.vmssoftware.com.tar / FREEWARE / FREEWARE40.ZIP / flistfrontend / src / tabexp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1985-01-12  |  793 b   |  52 lines

  1. #ifndef NO_IDENT
  2. static char *Id = "$Id: tabexp.c,v 1.2 1985/01/12 15:38:32 tom Exp $";
  3. #endif
  4.  
  5. /*
  6.  * Title:    tabexp.c
  7.  * Author:    Thomas E. Dickey
  8.  * Created:    12 Jan 1985
  9.  * Last update:    12 Jan 1985
  10.  *
  11.  * Function:    Expand all of the tabs in a string into spaces.
  12.  *
  13.  * Arguments:    obuf    => output buffer
  14.  *        ibuf    => input buffer
  15.  */
  16.  
  17. #include    <ctype.h>
  18.  
  19. #include    "bool.h"
  20.  
  21. tabexp (obuf, ibuf)
  22. char    *obuf, *ibuf;
  23. {
  24. register
  25. char    c,
  26.     *i_ = ibuf,
  27.     *o_ = obuf;
  28. register
  29. int    column = 0, next;
  30.  
  31.     while (*i_)
  32.     {
  33.         if ((c = *i_++) == '\t')
  34.         {
  35.             c = ' ';
  36.             next = column | 7;
  37.             while (column < next)
  38.             {
  39.                 *o_++ = c;
  40.                 column++;
  41.             }
  42.         }
  43.         else if (c == '\b')
  44.             column = (column > 0) ? column-1 : 0;
  45.         else if (c == '\r')
  46.             column = 0;
  47.         if (isprint(c))    column++;
  48.         *o_++ = c;
  49.     }
  50.     *o_ = EOS;
  51. }
  52.