aboutsummaryrefslogtreecommitdiff
path: root/pkg/xtools/strdetab.x
blob: 9ce9967592d75f71547b971050be9c001505c2f1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

# STRDETAB -- Procedure to remove tabs from a line of text and replace with
# blanks.

procedure strdetab (line, outline, maxch, tabsize)

int   ip, op, maxch, tabsize
char  line[ARB], outline [ARB]

begin
	op=1
	ip=1

	while (line[ip] != EOS && op <= maxch) {
	    if (line[ip] == '\t') {
		repeat {
		    outline[op] = ' '
		    op = op + 1
		} until ((mod (op, tabsize) == 1) || (op > maxch)) 
	        ip = ip + 1
	    } else {
		outline[op] = line[ip]
		op = op + 1
		ip = ip + 1
	    }
	}

	outline[op] = EOS
end