.type RUNOFF internals document is being generated .type .ps 60,78,0,0,1 .first title RUNOFF INTERNALS .c;RUNOFF INTERNALS .s2 This is a quick guide to RUNOFF for those who wish to modify it. It is intended as a guide and not a complete explanation. The novice programmer should confine changes to those documented in the BUILD file. Since all modules are heavily commented the comments are a more detailed guide. .s.c;MACRO modules .list 1 .le;RNODYN - Dynamic memory routines. These store character strings for use by RNO. The routines essentially simulate a sequential file with access by record number. .i5;1 Record = 1 byte .br;You should learn how these routines work it you wish to implement changes. .le;FMTCM - This contains all special purpose routines to format output. This inclues chapters, lists, notes, and header levels. .le;GCIN - Contains all character interpretation routines. .le;RUNOFF - Main program with line formatting routines, and input parameter parsing routines. .le;CMTAB - Command tables - defines commands and routines they call. .le;COMND - Command parser .le;ERMSG - Error message routines and messages .le;HYPHEN - Autohyphenation routine .le;ESCAPE - Contains all DEFINE, DELETE, RESET commands. .le;INDEX - Contains indexing routines .le;INIT - General initialization and all flags commands. .le;PINDX - Contains index printing routines .le;RNCMD - General purpose commands- skip, page, indent, footnote, text etc. .le;RNORSX - RSX I/O tables .le;RSXIO - I/O routines for RSX .le;RTIO - RT-11 I/O routines. .le;RNORT - RT-11 startup. These are include command line parsing and _.REQUIRE commands. .le;START - RSX specific file parsing routines. Includes command line parsing and _.REQ commands. .le;STYLE - Contains most style, layout, and display commands. .els .s.c;Structure of program .list 1 .le;Certain register conventions are used throughout: .i-2;R0#-#is completely volatile. It can not be trusted on return from subroutines unless otherwise stated. .i-2;R1#-#is completely volatile. It is often used to be the current chacter. .i-2;R2#-#is preseved in general across subroutine calls inless otherwise stated. .i-2;R3#-#points to a header for a buffer chain as defined in RNODYN. .i-2;R4#-#is preserved. It points to the numeric input routines when a command interpretation routine is called. .i-2;R5#-#is preserved across calls. .i-2;C##-#is generally clear if the call is ok, and set if not. .p The command interpretation routines are not assumed to save, restore any registers, so they have free use of all registers. Not all routines use consistent conventions, because I started with an older verstion from DECUS. .le;A stack structure is used for all input. This is the heart of this program. A set of headers are used to point to various places in the input. Whenver a substitution is made, the stack depth increases by 1 header. Some routines such as the chapter routine call SETINS to increase the stack depth and then add strings to input, then standard routines are used to format the output. There is a big trap for the unwary here. When the stack depth is increased, the user may add data to the end of input, and when the stack depth is decreased, the added data evaporates. .p;At stack depth 0 only the input line read from the input file is available, but at higher stack depths the substitution buffer is used as input. .le;The character width is now variable. To get the width you should use the character width routines in GCIN. .le;The number conversion routines accept input on the stack. These routines wish to find a series of numbers terminated by a zero word. The output is put into the buffers pointed to by R3. .le;All input is parsed, by discarding all control characters except for TAB, CR, and LF. Each input line ends with CR,LF. Fake input may end with only LF. .le;The input interpretaion in GCIN is table driven. There is a set of tables defining the characteristics of each character. The characteristics table defines autobreak, flags, period, and underlinable characters. Characters are marked as available as non alphanumeric, and as to availability for use as a flag. Another table defines the disposition of each character. The disposition table points to a vector table which dispatches to a specific routine. The disposition table is modifiable by the FLAGS commands. The definition table is modifiable by the FLAGS, PERIOD, AUTOBREAK, AUTOHYPHENATE, and UNDERLINE commands. Upper/lowercase characters are distinguished by the entries in the disposition table. The values 0 and 2 mark the possible values. All values are symbolic. Two values are used in the disposition table, negative and positive. Positive defines allowed input characters, negative are characters that trigger an action on output, and are not printed. This keeps the table sizes small, though the program is a little slower. .p An additional table of character widths has been added to facilitate proportional fonts. .le;Most error messages call ERMSG, except when overlay switching could be fatal. Then imbedded messages are used. ERMSG contains error messages and since it is in a separate overlay the messages are only availabel when ERMSG is called. .le;The initial stack pointer is saved, and periodically restored. After each fatal error and before each new line of input it is restored. This simplifies stack cleanup. .le;If you make major changes in RNO you should enable the symbol $DEBUG. This attempts to catch bugs by checking the dynamic buffer structure in RNODYN. In addition it creates a routine called CHROUT which may display the current value of R1. You may then sprinkle calls to CHROUT in your routines to view the character being handled. .els