diff options
author | Hidetoshi Shimokawa <simokawa@FreeBSD.org> | 1999-01-18 06:59:18 +0000 |
---|---|---|
committer | Hidetoshi Shimokawa <simokawa@FreeBSD.org> | 1999-01-18 06:59:18 +0000 |
commit | 3ba3e2cc4b63fa16707f51e735e751e62dd9526e (patch) | |
tree | 2d073c94248fff7dcaa8a3b1356933e1dcd784db /contrib/global/lib/tab.c | |
parent | 0823b5bf088ea8520ea23a0c424e4ecab62491d5 (diff) |
Notes
Diffstat (limited to 'contrib/global/lib/tab.c')
-rw-r--r-- | contrib/global/lib/tab.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/contrib/global/lib/tab.c b/contrib/global/lib/tab.c index d309386a2d41..1a9896ff8b26 100644 --- a/contrib/global/lib/tab.c +++ b/contrib/global/lib/tab.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 1997 Shigio Yamaguchi. All rights reserved. + * Copyright (c) 1996, 1997, 1998 Shigio Yamaguchi. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -28,14 +28,29 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * tab.c 20-Oct-97 + * tab.c 8-Oct-98 * */ #include <stdio.h> #include "tab.h" -#define TABPOS(i) ((i)%8 == 0) +static int tabs = 8; + +#define TABPOS(i) ((i)%tabs == 0) +/* + * settabs: set default tab stop + * + * i) n tab stop + */ +void +settabs(n) +int n; +{ + if (n < 1 || n > 32) + return; + tabs = n; +} /* * detab: convert tabs into spaces and print * @@ -84,7 +99,8 @@ char *buf; blanks++; /* count blanks */ continue; } - buf[dst++] = '\t'; + /* don't convert single blank into tab */ + buf[dst++] = (blanks == 0) ? ' ' : '\t'; } else if (c == '\t') { while (!TABPOS(++pos)) ; @@ -97,5 +113,8 @@ char *buf; } blanks = 0; } + if (blanks > 0) + while (blanks--) + buf[dst++] = ' '; buf[dst] = 0; } |