#-h- entab.r 1577 asc 09-apr-81 09:05:49 [002,101] #-h- main 793 asc 09-apr-81 09:05:42 [002,101] ## entab - replace blanks by tabs and blanks DRIVER(entab) character getch integer nxtfil character c, buf(MAXLINE) integer tabpos, int, argct integer col, i, newcol, tabs(MAXLINE) call query("usage: entab [...] [+] [file] ...") call argtab(buf) # fetch tab info into buf call settab(buf, tabs) # set up tab stops col = 1 argct = 1 while (nxtfil(argct,int) != EOF) { repeat { newcol = col while (getch(c,int) == BLANK) { newcol = newcol + 1 if(tabpos(newcol,tabs) == YES) { call putc(TAB) col = newcol } } for (;col < newcol; col = col + 1) call putc(BLANK) if(c == EOF) { if (int != STDIN) call close(int) break } call putc(c) if(c == NEWLINE) col = 1 else col = col + 1 } } DRETURN end #-h- nxtfil 660 asc 09-apr-81 09:05:44 [002,101] ## nxtfil - get next file from argument list integer function nxtfil(argct,int) integer getarg, open, alldig integer argct, int integer flag #own character abuf(FILENAMESIZE) data flag /0/ # flag for one time through int = STDIN for ( ; ; argct = argct + 1) { nxtfil = getarg(argct,abuf,FILENAMESIZE) if (nxtfil == EOF) break if (abuf(1) == PLUS | alldig(abuf) == YES) next flag = flag + 1 if (abuf(1) == MINUS & abuf(2) == EOS) { int = STDIN break } else { int = open(abuf,READ) if (int != ERR) break else call cant(abuf) } } if (flag == 0) { flag = 1 nxtfil = EOS } argct = argct + 1 return end #-h- entab.rof 924 asc 06-may-81 07:38:54 [002,100] .pl 60 .bp .rm 70 .in 0 .he 'ENTAB'date'ENTAB' .fo ''-#-' .fi NAME .br .in 7 entab - convert spaces to tabs and spaces .sp 1 .in SYNOPSIS .br .in 7 entab [ ...] [+] [file ...] .sp 1 .in DESCRIPTION .br .in 7 Entab replaces strings of blanks with equivalent tabs (control-i) and blanks. It can be used to read files and produce typewriter-like text, reducing file size. Tab stops are indicated by ... (default 8, 16, ...), while + indicates tab stops every columns. Thus the command .ti +3 entab 5 21 +5 would insert tab stops at columns 5, 21, 26, etc. If no files are specified, the standard input is read. An isolated minus sign also indicates the standard input. .sp 1 .in SEE ALSO .br .in 7 detab; lpr .sp 1 .in AUTHORS .br .in 7 .sp 1 Original from Kernighan & Plauger's 'Software Tools', with modifications by Dennis Hall .sp 1 .in BUGS .br .in 7 None to date.