DeTab is the inverse of EnTab. Here is the specification:
{
PROGRAM
DeTab -- convert tabs to blanks
USAGE
DeTab
FUNCTION
DeTab copies its input to its output, expanding horizontal tabs to
blanks along the way, so that the output is visually the same as the
input, but contains no tab chars. Tab stops are assumed to be set
every three columns (i.e., 1, 4, 7, 10, ...), so that each tab char
is replaced by from one to three blanks.
BUGS
1. DeTab is naive about backspace, vertical motions, and
non-printing chars.
2. Each line of output will be truncated at MAXSTR chars.
3. Trailing BLANKS will be trimmed from each line of output.
}
DeTab's main routine echos EnTab's, reducing the problem to one of detabbing a single string. To detab the string we could try to simply apply EnTab's strategy in reverse, however, this is another chance to apply the "how would a human do it?" approach.
Read More