This procedure is called by “ttread” (8543) to transfer characters from the “raw” input queue to the “cooked” input queue (after processing “erase” and “kill” characters and, in the case of upper case only terminals, processing “escaped” characters, i.e. characters preceded by the character ‘\’). “canon” returns a non-zero value if the “cooked” input queue is no longer empty.
If the number of delimiters in the “raw” input queue is zero then ...
if the terminal is logically inactive, then just return;
otherwise go to “sleep”.
Note that delimiters in this context are characters of all ones (octal value is 377) and are inserted by “ttyinput” (8358).
Set “bp” to point to the third character of the work array, “canonb”;
Begin a loop (extending to line 8318) which removes one character from the “raw” queue per cycle;
If the character is a delimiter, reduce the delimiter count by one and exit the loop i.e. go to line 8319;
If the terminal is not operating in “raw” mode ...
If the previous character (note the “bp[–1]” notation!) was not a backslash, ‘\’, execute the code from line 8299 to 8307, otherwise execute the code beginning at line 8309.
Previous character was not a backslash
If the characters is an “erase” and ...
if there is at least one charater to erase, backup the pointer “bp”;
Start on the next cycle of the loop beginning at line 8292;
If the character is a “kill”, throw away all the characters accumulated for the current line, by going back to line 8290;
If the character is an “eot” (004) (usually generated at the terminal as “control-D”), ignore it (and do not put it inot “canonb”) and start on the next cycle;
(If this character occurs at the beginning of a line, then subsequently “ttread” (8544) will find no characters in the “cooked” input queue i.e. it will read a zero length record, which then leads to the program receiving the normal “end of file” indication.)
Previous character was a backslash
If “maptab[c]” is non-zero, and either
“maptab[c] == c” or the terminal is upper case only, then ...
if the last character but one was not a backslash (‘\’), then replace “c” by “maptab[c]” and back up “bp” (so that the backslash will be erased).
Character ready
Move “c” into the next character in “canonb”, and if this array is now full, leave the loop.
Line completed