“colp” points to a string of pairs of characters. If the character to be output matches the second character of any of these pairs, the charactcr is replaced by a backslash followed by the first character of the pair;
Lower case alphabetics are converted to upper case alphabetics by the addition of a constant.
Note. The conversion here should be compared wth the handling of the reverse problem on input. Here we have an algorithm which clearly trades space (no table analogue to “maptab”) for time (a serial search through the string on line 8400). A space conserving approach could be adopted in “canon” but the problem is rather more complicated there.
Insert the character into the output queue. If perchance, “putc” fails for lack of buffer space, don’t worry about inserting any subsequent delay, or updating the system’s idea of the current printing column;
Set “colp” to point to the “t_col” character of the “tty” structure, i.e. “*colp” has a value which is the ordinal number of the column which has just been printed;
Set “ctype” to the element of “partab” corresponding to the output character “c”;
Mask out the significant bits of “ctype” and use the result as the “switch” index;
(Case 0) The common situation! Increment “t_col”;
(Case 1) Non-printing characters. This group consists of the first, third and fourth octet of the ASCII character set, plus “so” (016), “si” (017) and “del” (0177). Don’t increment “t_col”;
(Case 2) Backspace. Decrement “t_col” unless it is already zero;
(Case 3) Newline. Obviously “t_col” should be set to zero. The main problem is to calculate the delay which should ensue before another character is sent.
For a Model 37 teletype, this depends on how far the print mechanism has progressed across the page. The value chosen is at least a tenth of a second (six clock ticks) and may be as much as ((132/16) + 3)/60 = 0.19 seconds.
For a VT05, the delay is 0.1 second. For a DECwriter it is zero because the terminal incorporates buffer storage and has a double speed “catch up” print mode;
(Case 4) Horizontal tab. Assign the value of bits 10, 11 of “t_flags” to “ctype”;
For the only non-trivial case recognised
(“c” == 1 or Model 37 teletype), calculate the the number of positions to the next tab stop (via the obscure calculation of line 8454). If this turns out to be four columns or less, take it as zero;
Round “*colp” (i.e. the value pointed to by “colp”!) to the next multiple of 8 less one;
Increment “*colp” to be an exact multiple of eight;
(Case 5) Vertical Motion. If bit 14 is set in “t_flags”, make the delay as long as possible, i.e. 0177 or 127 clock ticks, i.e. just over two seconds;
(Case 6) Carriage Return. Assign the value of bits 12, 13 of “t_flags” to “ctype”;
For the first class, allow a delay of five clock ticks;
For the second class, allow a delay of ten clock ticks;
Set the “*colp” (the last column printed) to zero.
Before leaving the file “tty.c”, there are two matters which deserve further examination.