The next program in our project is
EnTab which replaces runs of blanks in a text file by tabs and blanks. Here is the specification, i.e., the "manual"
PROGRAM
EnTab -- convert runs of blanks into tabs
USAGE
EnTab
FUNCTION
EnTab copies its input to its output, replacing strings of blanks by
tabs so that the output is visually the same as the input but contains
fewer characters. Tab stops are assumed to be set every 3 columns
(i.e., 1, 4, 7, ...), so that each sequence of one to four blanks
ending on a tab stop is replaced by a tab character.
BUGS
1. EnTab is naive about backspaces, vertical motions and non-printing
characters.
2. EnTab will convert a single blank to a tab if it occurs at a tab
stop, thus EnTab is not an exact inverse of DeTab.
3. if any record in the input is longer than 255 char Entab will
truncate that record to 255 char.
...
Posted on Monday, December 03, 2007 at 11:43 AM
I've always recommended that programmers make it a point to read this classic by Kernighan and Plauger. I'm now in the process of reading it again. I had to request an interlibrary load to get it.
Upon re-reading it (I'm now up to chapter 3) I find it terribly dated. The examples are all in Fortran and PL/1 (PL/I?). One of the "rules" set forth is "avoid the Fortran arithmetic IF," a good piece of advise if you happen to be programming in Fortran but of little use if you are using C++ or Pascal.
The first chapters of the book seem to deal almost exclusively with when and when not to use GOTO and how to use it when you do. Again advise aimed at Fortran programmers who, lacking WHILE and IF..THEN..ELSE, had no choice but to use GOTO, and at PL/1 programs who could avoid the GOTO but often didn't, producing "Fortran with semicolons."...