diff options
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;  } | 
