oz@yetti.UUCP (Ozan Yigit) (01/14/86)
#!/bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #!/bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # READ_ME # proff.man # This archive created: Mon Jan 13 23:49:39 1986 export PATH; PATH=/bin:$PATH echo shar: extracting "'READ_ME'" '(1426 characters)' if test -f 'READ_ME' then echo shar: over-writing existing file "'READ_ME'" fi sed 's/^X//' << \SHAR_EOF > 'READ_ME' XProff - A portable formatter X XThis is the first distribution of PROFF, a formatter based Xon software tools ROFF. It is mainly a C re-write of ROFF, X(now known as FORMAT), with some expansions. It is mainly Xintended for non-UN*X systems, CP/M, MS-DOS and the like. X XProff was originally written for The Faculty of Administrative XStudies, York University, to supplement their microcomputer Xenvironment. As of this release, the formatter is in the Xcontrol of The Faculty of Administrative Studies. X XThere is no man page for proff, for it was never intended Xfor UN*X systems. There is, however two comprehensive Xdocuments to answer all questions. X XThe C code for PROFF is quite warped, and should be approached Xcarefully. [Ok..Ok.. it is all my fault.. too much midnight Xoil..] It is reasonably customazible, by changing proffsym.new. XThis file is processed by ltb, a static hash table generator. XThis approach is most useful to change the operator keywords, Xcreate aliases, and it also bypassess the initialization Xoverhead. [see the makefile for the right output file names Xfor ltb] X XPROFF is not copyrighted, at least for this release. Future Xreleases may contain York University copyright. X XPlease send me all updates, bugfixes and other tidbits, Xso that future releases may be coordinated smoothly. X Xenjoy. X oz X bitnet: oz@yuyetti X oz@yusol X usenet: {ihnp4|decvax|allegra|linus}!utzoo!yetti!oz X phonet: (416) 667 3976 X SHAR_EOF if test 1426 -ne "`wc -c 'READ_ME'`" then echo shar: error transmitting "'READ_ME'" '(should have been 1426 characters)' fi echo shar: extracting "'proff.man'" '(61510 characters)' if test -f 'proff.man' then echo shar: over-writing existing file "'proff.man'" fi sed 's/^X//' << \SHAR_EOF > 'proff.man' X X X X X X X X X PROFF User's Guide X X Version 1.0 X X X X X X X X X X X X X X X X *** ******* X *** ********* X ** ** X ** ** X ********* X ******* X ** X ** X ** X ****** X **** X X X X X X X X X X X X X X X X X Ozan S. Yigit & Steven Tress X March 1984 X X X X X X X X1.0 Proff User's Guide 1 X X X11..00 IInnttrroodduuccttiioonn X X This manual describes PROFF, a formatter based on the XFORMAT utility presented in _S_o_f_t_w_a_r_e _T_o_o_l_s_. X X PROFF was produced to provide a powerful formatter that can Xbe used under a variety of microcomputers, thus providing a Xconsistent formatting tool across environments. PROFF can be Xused to format memos, reports, form letters and documents such Xas this manual. It can also be configured to mimic other Xformatting systems of similar nature. X X This document itself was produced with PROFF, using most of Xits advanced features. PROFF took care of such things as Xauto-paragraphing and the production of the Table of Contents Xas the manual was being formatted. X X PROFF was developed under a Digital Equipment Corporation XRainbow 100, using Mark Williams C Compiler for portability Xreasons. PROFF is available under VAX/VMS operating system. XPROFF implementations for IBM PC and APPLE ][ microcomputers Xare also underway. X X X X X X X X X X X X X X X X X X X X X XRainbow, VAX/VMS are trademarks of Digital Equipment XCorporation. XMark Williams C Compiler is a trademark of Mark Williams XCompany. XIBM is a registered trademark of International Business Machines XInc. XAPPLE is a trademark of Apple Computer Inc. XUNIX is a trademark of Bell Laboratories. X X X X X X X1.0 Proff User's Guide 2 X X X22..00 GGeenneerraall DDeessccrriippttiioonn X X22..11 TThhee IInnppuutt X X The text that is to be formatted by PROFF is typed into an Xinput file using any text editor. This file contains the text to Xbe formatted as well as PROFF commands. X X Each line in the input file is either a command line or a Xtext line. A command line is a line that begins with a period X("."). All other lines are text lines. The command lines are not Xprinted - they tell PROFF how you want it to format the text Xthat follows. Appendix A summarizes all of the PROFF commands Xfor a quick reference. X X22..11..11 TTeexxtt X X Text can be entered into the input file in any format. XPROFF removes all extra blanks and tabs between words when Xoperating in fill mode. This means you do not have to worry Xabout how many words you put on a line, and you can break lines Xwherever it is convenient to your typing. Note however, that you Xcannot break a word between two lines. X X Blanks and tabs at the beginning of a line are not removed. XThis is useful for producing special tables and performing Xspecial types of indentation. Thus, normal text lines should Xnot have any leading tabs or blanks. X X22..11..22 CCoommmmaannddss X X A command is a line that starts with a period. Immediately Xfollowing the period is a command name. Some commands accept a Xnumeric quantity or a character string parameter, which must be Xseparated from the command name by a space or a comma. For Xexample, an indent command might appear as follows: X X | X |It is to do nothing that the elect exists. X |.in 5 X |- Oscar Wilde X | X X Assuming that the left margin was at column 1, PROFF would Xproduce the following: X X | X |It is to do nothing that the elect exists. X | - Oscar Wilde X | X X (In the examples above, as in those following, the vertical X X X X X X1.0 Proff User's Guide 3 X X Xline indicates the left edge of input or the left edge of the Xprinted page). X X The number following the command may be preceeded by a "+" Xor "-" sign. This plus or minus sign indicates an addition or Xsubtraction of the number to or from the current value for the Xcommand. for example, the text: X X | X |Nothing to do but work, X |.in +3 X |Nothing to eat but food, X |.in -3 X |Nothing to wear but clothes X |.in +3 X |To keep one from going nude. X |.in +7 X |-Benjamin King X | X Xwill produce as output: X X | X |Nothing to do but work, X | Nothing to eat but food, X |Nothing to wear but clothes X | To keep one from going nude. X | -Benjamin King X | X X If a number is not supplied with a command that requires a Xnumber, PROFF will use a default value. The defaults for each Xcommand are summarized in Appendix A. X X22..22 TThhee OOuuttppuutt X X The main functions performed by PROFF are _f_i_l_l_i_n_g and X_j_u_s_t_i_f_y_i_n_g_. A line is filled by packing as many words onto it Xas will fit. The line is justified by spacing words evenly Xbetween the left and right margins. When PROFF starts, it Xassumes that the text is to be filled and justified. Of course, Xwhen fill and justify are not needed (as in the case of a letter Xor a table), there are commands to turn these features off, and Xback on again, as necessary. X X When PROFF is in fill mode, it normally strips out extra Xspaces and tabs between words. X X Many PROFF commands cause a _b_r_e_a_k to occur in the output. XThis means that the line currently being filled is immediately Xoutput. Any following text goes into a new output line. X X X X X X X1.0 Proff User's Guide 4 X X X22..33 EExxeeccuuttiinngg PPRROOFFFF X X Once a text file is ready for formatting, PROFF is started Xby typing the program name, various options, name of the input Xfile and the name of the output file. For example the command X X A> proff -po5 proffman.prf proff.man X Xwould produce this document as proff.man, from an input file Xproffman.prf, shifted right by 5 spaces. (The symbol "A>" is XCP/M system prompt). X X22..44 BBiibblliiooggrraapphhiicc NNootteess X X PROFF wa produced by re-writing the Software Tools XFormatter FORMAT. Some of the ideas are from Freshwater XInstitute RUNOFF, NROFF, University of Waterloo SCRIPT and Xother formatters of similar nature. The underlying ideas of the Xmentioned above formatters may be found in _S_o_f_t_w_a_r_e _T_o_o_l_s by XB.W. Kernighan and P.J. Plauger. 1976. (Addison-Wesley, Reading, XMass.). X X22..55 RReeffeerreenncceess aanndd RReeaaddiinnggss X XBrian W. Kernighan and P. J. Plauger, X_S_o_f_t_w_a_r_e _T_o_o_l_s XAddison-Wesley (1976) X XR. Furuta, J. Scofield and A. Shaw, X_D_o_c_u_m_e_n_t _F_o_r_m_a_t_t_i_n_g _S_y_s_t_e_m_s_: X_S_u_r_v_e_y_, _C_o_n_c_e_p_t_s_, _a_n_d _i_s_s_u_e_s XACM Computing Surveys, Sept. 1982, Pp. 417 X XMark Stuart Brader, X_A_n _I_n_c_r_e_m_e_n_t_a_l _T_e_x_t _F_o_r_m_a_t_t_e_r XDepartment of Computer Science XUniversity of Waterloo, CS-81-12 X X X X X X X X X X X X X X X X X X X X X1.0 Proff User's Guide 5 X X X33..00 CCoommmmaanndd DDeessccrriippttiioonnss X X This section describes PROFF commands. Commands specify how Xthe program is to process the text lines in the input file. XLines in the input file that begin with a period (or the control Xcharacter selected by the user) immediately followed by a Xcommand name are commands. Any line that begins with a period Xand followed by a # or ! is a comment line and is ignored by XPROFF - this allows you to put information in the file that will Xbe neither processed nor output by PROFF. X X As described earlier, some of the commands can be followed Xby "parameters". Parameters are used in executing a command; Xfor example, in the command ".sp 3", the parameter "3" tells the Xformatter to insert 3 blank lines into the document. The Xfollowing conventions are used in describing the parameters: X X o Parameters surrounded by square brackets are optional. If X not supplied, PROFF assumes a default value. X (e.g. .sp [n]) X X o Parameters surrounded by angle brackets are mandatory. X PROFF will display a fatal error message if the parameter X is absent. (e.g. .set <variable name>) X X o Parameters surrounded by squiggly brackets are to be typed X exactly as indicated. (e.g. .pn {roman}) X X o A bar character seperating the parameters within brackets X indicate an alternative. (e.g. .st [+|-][n] means both .st X [+n] and .st [-n]) X X In describing the commands, the command is typed exacty as Xaccepted by PROFF with the associated control character default X("."). If more than one form of the command is accepted by XPROFF, the command names are separated with a bar indicating an Xalternative. X X X X X X X X X X X X X X X X X X X X X1.0 Proff User's Guide 6 X X X33..11 FFiilllliinngg aanndd JJuussttiiffyyiinngg X X.fi | .f | .fill X X The fill command causes a line to be filled with as many X words as the right margin allows. For this purpose, all X extra blanks and tabs are removed between words. Each word X is separated with a single blank. PROFF automatically X assumes fill mode during the startup. X X.nf | .nofill X X No fill discontinues the filling of the text. PROFF simply X copies the text to the output. This command may be used to X pass tables and other text unaltered through the X formatter. X X.ju | .j | .justify X X Justify causes the words on a line to be evenly spaced X between the left and the right margins. Note that lines can X be justified only if lines are also being filled. PROFF X automatically assumes justify mode during the startup. X X.nj | .nojustify X X No justify discontinues the text justification. X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X1.0 Proff User's Guide 7 X X X33..22 TTeexxtt FFoorrmmaattttiinngg X X.br | .break X X Break causes a break: the current line is printed without X justification, and the next word is placed at the beginning X of a new line. Note that many PROFF commands cause an X implicit break. X X.in | .lm | .leftmargin [+|-][n] X X Indent causes a break and indents the following lines [n] X spaces to the right of the left margin. [n] can be negative X to allow beginning a line to the left of the left margin, X however, a line cannot begin to the left of column 0. If a X plus or minus sign is used with n, then [n] is added or X subtracted to or from the current value. X X.ti | .i | .left [+|-][n] X X Temporary indent is identical to the indent command except X that it applies only to the next line of printed text. X Thus, the command ".ti +5" would cause the next line to be X printed 5 spaces to the right of those that follow. X X.st | .spaceto [-][n] X X Spaceto allows spacing to line [n] from the top of the X current page. If a negative [n] is specified, than spacing X is performed to line [n] from the bottom of the page X (excluding the footer lines). Thus, footnotes can be set at X a fixed distance from the bottom of the page by a command X such as ".st -5". X X.sp | .s | .skip [n] X X Space causes a break and skips [n] lines, except at the top X of a page. The space command is dependent on the setting X of line spacing. X X.ce | .center [n | on | off] X X Center causes the next [n] lines of text to be centered X between the left and right margins. Centering may be X started with "on" and terminated with "off", in which case X all input lines between these commands will be centered. X X.ul | .underline [n | on | off] X X Underline command causes the text on the next [n] input X lines to be underlined when printed. If [n] is omitted, X only the next line is underlined. This command does not X X X X X X1.0 Proff User's Guide 8 X X X cause a break, so words in filled text may be underlined X by: X X X | X |The "Pay-off" Theory: Only X |.ul X |losers X |believe in luck, horses, horoscopes X |and X |.ul X |lotteries. X | X X to get X X | X |The "Pay-off" Theory: Only _l_o_s_e_r_s believe in X |luck, horses, horoscopes and _l_o_t_t_e_r_i_e_s_. X | X X Underlining may be started with "on" and terminated X with "off", similar to the centering command. X X.ul | .underline [all | words] X X This version of the underline command is used to set the X mode of underlining: X X all - underline across all characters, X including spaces. X words - underline words only X X X.bd | .bold [n | on | off] X X The bold command causes the text on the next [n] input X lines to be highlighted by overstriking. If [n] is omitted, X only the next line is highlighted. Bolding may be started X with "on" and terminated with "off" as in the case of the X center and underline commands. X X.db | .dbo | .disablebolding X X Turns the bolding off, all bolding commands are ignored. X This feature is useful for rough drafts. X X.eb | .ebo | .enablebolding X X Turns the bolding feature back on. Bolding is turned on X during the PROFF startup. X X X X X X X1.0 Proff User's Guide 9 X X X33..33 PPaaggee FFoorrmmaattttiinngg X X.ls | .spc | .spacing [n] X X Line spacing is the command to set line spacing. Set n to 1 X for single spacing, 2 for double spacing etc. X X.bp | .pg | .page [n] X X The begin page command causes a break, ends the current X page, outputs footers if required and begins a new page. If X [n] is present, the page number is set to [n]. The default X action is to number the pages incrementally. X X.pn | .pagenumber {roman} | {arabic} X X Page number command defines the format of the page number. X Uppercase roman numerals may be obtained with "roman" X keyword. To convert the page numbers back to normal, X "arabic" is specified. PROFF uses arabic numerals as a X default. X X.np | .nopaging X X No paging disables the pagination. When PROFF is in no X paging mode, "begin page" (.bp) and "page length" (.pl) X commands are ignored. This mode of operation is especially X useful for using the proff output with the multi-column X formatter (MC). X X.pa | .paging X X Paging enables normal page generation. This command starts X a new page and restores the page length to the value X previous to the ".np" command. X X.ne | .need | .tp | .testpage [n] X X Test page checks to see whether at least [n] lines remain X in the current page. If less than this number of lines X remain, printing will resume at the top of a new page. If X [n] is missing, it is assumed to be zero. X X.he | .header <text> X X Header sets the text to be printed on top of each page. X <text> is divided into sections which are to be left X justified, centered and right justified. To divide <text> X into these three parts, the first character is assumed to X be a separator. (e.g. /left/center/right/) But any X non-alphanumeric character may also be used. The characters X "#" and "%" are replaced with the current page number and X X X X X X1.0 Proff User's Guide 10 X X X day/time in the header. X X.fo | .footer <text> X X Footer is identical to header except that it sets the text X to be printed at the bottom of each page. X X.oh <text> X X The odd header command sets the header for odd pages only. X X.eh <text> X X The even header command sets the header for even pages X only. X X.of <text> X X The odd footer command sets the footer for odd pages only. X X.ef <text> X X The even footer command sets the footer for even pages X only. X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X1.0 Proff User's Guide 11 X X X33..44 PPaaggee LLaayyoouutt X X These commands are used to specify where on the page you Xwant the formatted text to be placed. The general layout of a Xpage is as follows: X X page offset (.po) | X | | X V | X +----+-------------------------------------+----+ -+ X | | top margin (m1) includes header | | | X +----+-------------------------------------+----+ | X | | top margin 2 (m2) | | | X +----+-------------------------------------+----+ | X | | . | | P X | |<-- indent (.in) . | | A X | | . | | G X | | T | | E X | | E | | X | | X | | L X | | T | | E X | | . | | N X | | right margin (.rm) -->| | G X | | . | | T X | | . | | H X | | . | | | X +----+-------------------------------------+----+ | X | | bottom margin 3 (m3) | | | X +----+-------------------------------------+----+ | X | | bottom margin (m4) includes footer | | | X +----+-------------------------------------+----+ -+ X | | X | | X X.po | .offset [+|-][n] X X The page offset command moves the entire page to the right X or left depending on the specified value. All indentation X is according to the page offset. PROFF assumes a page X offset of 0 during the startup. If [n] is specified with a X plus or minus, it will be added or subtracted from the X current value. X X.rm | .rightmargin [+|-][n] X X Right Margin sets the position of the last printable X character from the left edge of the page to [n]. Default X value for right margin is 65. A plus or minus value will X be added or subtracted from the current value. If [n] is X not specified, right margin is set to the default value. X X.pl | .ps | .pagesize [n] X X X X X X1.0 Proff User's Guide 12 X X X Page length is used to set the number of lines that are to X be printed on a page including the header and footer lines. X After [n] lines are printed, the paper will advance to the X top of next page. The default page length is 66 lines (11 X inches for 6 lines/inch). This command is disabled if X nopaging is set. X X.m1 [n] X X Margin 1 sets the number of lines (including the header) X which will be left at the top of the page to [n]. The X default setting is 3. If [n] is omitted, is set to the X default. X X.m2 [n] X X Margin 2 sets the number of blank lines between the header X and the first line of text. The default setting is 2. X X.m3 [n] X X Margin 3 sets the number of blank lines between the footer X and the last line of text. The default setting is 2. X X.m4 [n] X X Margin 4 sets the number of lines (including the footer) X which will be left at the bottom of the page to [n]. The X default setting is 3. X X X X X X X X X X X X X X X X X X X X X X X X X X X X X1.0 Proff User's Guide 13 X X X33..55 TTaabbllee ooff CCoonntteennttss X X This section describes the the commands that are used to Xgenerate a table of contents. Basically, a contents line command Xis used in every place in the document where an entry is needed Xin the table of contents. PROFF stores the text and the page Xnumber when it encounters this command. After the the body of Xthe document is processed, a print contents command dumps the Xcontents table. The contents should be dumped in a new page, Xwith nofill. Page numbering should be disabled if the table of Xcontents is to be used in front of the document. X X X.cl | .contline [<n> <text>] X X Contents line specifies a line of <text> to be entered into X the table of contents. <n> specifies the level at which the X item is to be printed in the table. When the table is X printed, each level of entry will be indented by specific X number of spaces. <text> appears in the output exactly as X it appears in the contents line command, except that X leading blanks are removed. If no options specified in the X contents line, a blank is inserted during the table X output. X X.pc | .printcont [n] X X Print Contents causes the currently accumulated table of X contents to be printed. If [n] is specified, it is used as X the indent value for each level. If [n] is not specified, X it is defaulted to 3. X X A contents line at level 0 is as wide as X rightmargin-indent. The outlook of the table of contents X may be changed by altering the right margin and indent X values. A typical table of contents may be produced as X follows: X X |.page X |.he //// X |.fo //// X |.nofill X |.sp X |.center X |Table of Contents X |.sp X |.printcont X X The following example illustrates the generation of a table X of contents. Note that only one table of contents is active X for a PROFF session. X X X X X X X1.0 Proff User's Guide 14 X X X X .cl X .cl 0 A. Introduction X Introduction X text X . X .cl X .cl 0 B. Methods X Methods X text X . X .cl 1 a) Sampling Procedures X Sampling X text X . X .cl 1 b) Laboratory Procedures X Laboratory X text X . X .cl X .cl 0 C. Results X Results X text X . X . X .pg X .nf X .he //// X .fo //// X .ce X Table of Contents X .sp X .pc X X These commands will produce the following table: X X Table of Contents X X A. Introduction............................... 1 X X B. Methods.................................... 3 X a) Sampling Procedures..................... 3 X b) Laboratory Procedures................... 4 X X C. Results.................................... 5 X X Macros may be defined as described in the following X sections to help the generation of the table of contents. X X X X X X X X X X1.0 Proff User's Guide 15 X X X33..66 MMiisscceellllaanneeoouuss X X This section describes miscellaneous commands that Xradically increase the formatting powers of PROFF. With the Xassistance of variables, PROFF can generate form letters and Xdocuments with dynamic parts. The ability to save and restore Xformatter context eliminates the need to remember the exact Xsettings of the formatter across the document. X X.vs | .set <variable> [definition] X X Set variable defines a variable to be later used in the X document. If the definition part is left out, PROFF uses X the variable name as a prompt and allows the user to define X the variable interactively. Variable names cannot start X with a numeric character, and may only contain X alphanumeric characters. The definition of a variable may X not contain any blanks, unless they are surrounded by X double-quotes. To get a double quote within a a quoted X definition, two double-quotes are used. X X Once the variable is defined, it can be used anywhere X in the document, including the command line itself. A X variable substitution is invoked by a dollar sign ($). (A X literal $ is inserted into text using _$). A variable name X must be delimited by a non-alphanumeric character within X the text. If the contents of the variable is to be X appended to other alphanumeric characters, it must be X surrounded by wiggly braces ("{" and "}"). The following X is an example of variable usage: X X |.nf X |.vs v1 Murphy X |${v1}'s first law: X | Nothing is as easy as it looks. X |${v1}'s second law: X | Everything takes longer than you think. X |Charley's observation: X | Computers were invented by $v1. X | X X Produces the following: X X | X |Murphy's first law: X | Nothing is as easy as it looks. X |Murphy's second law: X | Everything takes longer than you think. X |Charley's observation: X | Computers were invented by Murphy. X | X X X X X X X1.0 Proff User's Guide 16 X X X.vg | .get <variable> <prompt> X X Get variable is the interactive version of variable X definition. In this variant, a prompt string is used to X obtain the value of the variable, which is typed at the X user's terminal. If the prompt string is to contain X blanks, tabs etc., it must be enclosed in double quotes. No X quotes are necessary for input text. X X.nr <a-z> [+|-][n] X X Number register is used to define registers that contain X numeric values. There are 26 number registers, named a-z. X The command ".nr x n" sets the number register "x" to value X n; ".nr x +n" increments the number register by n; ".nr x X -n" decrements the number register by n. The value of the X number register x is placed in the text by the appearance X of @nx. A literal @ may be inserted using _@. Number X registers may be used on command lines and anywhere in the X text. X X.cc | .cchar [char] X X Control Character sets the character that distinguishes X PROFF commands from text to be formatted. As a default, X control character is set to (".") period. This character X may be changed to something other than a period, either to X mimic other formatters or to disallow interpretation of X lines beginning with a period. (This document makes heavy X use of the .cc command). X X.ec | .echar [char] X X Escape Character sets the character that disallows the X interpretation of spacial characters such as @ and $. PROFF X uses an underline ("_") character as a default. X X.so | .source | .include | .require [filename] X X The source (include) command allows external files to be X inserted into the input file during the formatting. Using X this feature, tables, graphs and other documents generated X outside PROFF may be included into the document being X formatted. This feature is also very useful in including a X common set of macros during formatting. Include files may X be nested inside other include files. Currently, PROFF only X allows a nested include files level of 8. Filename may be X enclosed in quotes. X X.sv | .save X X The save command allows the saving of the current formatter X X X X X X1.0 Proff User's Guide 17 X X X context on a pushdown stack. The saved context of the X formatter segment (FSECT) includes the following values and X flags: X X values flags on | off X ------ ----- X indent (.in) fill (.fi | .nf) X right margin (.rm) justify (.ju | .nj) X offset (.po) paging (.pa | .np) X line spacing (.ls) number type (.pn) X page length (.pl) bolding (.eb | .db) X margin values (.m1) autoparagraph (.ap | .na) X (.m2) X (.m3) X (.m4) X control char (.cc) X escape char (.ec) X X X.rs | .restore X X The restore command pops the context stack and restores the X values and flags as defined above. X X.lx | .lex <command> [equate] X X The lexical modification command is essentially a permanent X replacement of a given command. This command is used for X changing the command names without resorting to the macro X facility. Lex permanently removes the old command name from X command tables and replaces it with the new definition. If X the equate is not specified, the command becomes undefined X and is no longer recognised by PROFF. The command equate X should not contain non-alphanumeric characters. X X.ap | .autoparagraph X X The autoparagraph command turns on the automatic X paragraphing feature. If auto-paragraphing is on, every X line that starts with a _b_l_a_n_k or a _t_a_b character starts a X new paragraph. A new line is generated (.sp) and the X beginning of the paragraph is indented by five spaces. X Autoparagraphing is the equivalent of the following X commands: X | X |textextextextext X |.sp X |.ti +5 X |textextextextext X | X X.na | nap | .noautoparagraph X X X X X X1.0 Proff User's Guide 18 X X X No Autoparagraph command disables auto-paragraphing. X X.wr | .write <string> X X Write is a special output command, only to be used to X configure printers and other output devices with escape X sequences. This command outputs the associated string as it X is encountered, without going through the normal output X routines of the formatter. Currently, the output string may X contain control characters specified as "^<char>", decimal X numbers within the range of 1-255, and other characters. X Blanks within the string are skipped. Any portion of the X string enclosed with double quotes is output as is. To X output a double quote, two double quotes must be used X within the quoted string. Following is a typical string to X set a Digital La-100 printer to letter quality print mode: X X | X |.wr ^["[2z" X | X X In the control string, "^[" is the ASCII equivalent of the X Escape (esc) character. Following mapping table is used to X convert characters starting with a caret to their binary X equivalents: ("|" indicates an alternative) X X Control chr Dec. Oct. Hex. X ----------- ---- ---- ---- X ^a | ^A (soh) 1 01 01 X ^b | ^B (stx) 2 02 02 X ^c | ^C (etx) 3 03 03 X ^d | ^D (eot) 4 04 04 X ^e | ^E (enq) 5 05 05 X ^f | ^F (ack) 6 06 06 X ^g | ^G (bel) 7 07 07 X ^h | ^H (bs) 8 10 08 X ^i | ^I (ht) 9 11 09 X ^j | ^J (nl) 10 12 0A X ^k | ^K (vt) 11 13 0B X ^l | ^L (np) 12 14 0C X ^m | ^M (cr) 13 15 0D X ^n | ^N (so) 14 16 0E X ^o | ^O (si) 15 17 0F X ^p | ^P (dle) 16 20 10 X ^q | ^Q (dc1) 17 21 11 X ^r | ^R (dc2) 18 22 12 X ^s | ^S (dc3) 19 23 13 X ^t | ^T (dc4) 20 24 14 X ^u | ^U (nak) 21 25 15 X ^v | ^V (syn) 22 26 16 X ^w | ^W (etb) 23 27 17 X ^x | ^X (can) 24 30 18 X X X X X X1.0 Proff User's Guide 19 X X X ^y | ^Y (em) 25 31 19 X ^z | ^Z (sub) 26 32 1A X ^[ (esc) 27 33 1B X ^\ (fs) 28 34 1C X ^] (gs) 29 35 1D X ^^ (rs) 30 36 1E X ^_ (us) 31 37 1F X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X1.0 Proff User's Guide 20 X X X33..77 DDeeffiinniinngg NNeeww CCoommmmaannddss ((MMaaccrrooss)) X X In document formatting, it is common to repeat a series of Xcommands at several places in the document. PROFF allows you to Xdefine a new command that will replace these repeated commands. XThis not only saves typing but ensures that _e_x_a_c_t_l_y the same Xsequence of commands are applied throughout the document. A new Xcommand that you define is formally called a _m_a_c_r_o_. To define a Xmacro, you must use the define macro (.de | .define) and end Xmacro (.en) commands. X X.de | .define <macro name> X X Define is used to define a <macro name> to which a series X of commands to be assigned. This definition line is X followed by any number of PROFF commands and/or text which X define the action that the macro will subsequently produce. X Macros may refer to other macros. X X.en X X End macro is the last line in the command definition. You X must put in this command to finish a currently defined X macro. ".en" command should not be re-defined as a macro. X XThe example below defines macros ".note" and ".endnote", similar Xto the RUNOFF commands of the same name. X X | X |.define note X |.sp X |.ce X |NOTE X |.sp X |.fi X |.in +5 X |.rm -5 X |.en X | X |.define endnote X |.sp X |.nf X |.in -5 X |.rm +5 X |.en X | X X A macro is used like any other PROFF command, control Xcharacter followed immediately by the name of the macro. For Xexample, the above macros may be used as follows: X X X X X X X X1.0 Proff User's Guide 21 X X X X | X |.note X |textextextextextextextextextext X | . X | . X | . X |.endnote X | X XThe following note is generated by the same macros described Xpreviously. X X NOTE X X Flap's Law: Any inanimate object, regardless of its X position or configuration, may be expected to perform X at any time in a totally unexpected manner for reasons X that are either entirely obscure or else completely X mysterious. X XSpecial symbols may be used within a macro definition. These Xsymbols represent the parameters passed to a macro, delimited by Xblanks or commas. These symbols are $0 for macro name, $1 for Xthe first parameter, $2 for the second parameter and so on, up Xto $9 for the ninth parameter. Currently, macro parameters may Xonly contain alphanumerics, no string parameters are possible. XThe previous macro "note" may now be defined as follows: X X | X |.define note X |.sp X |.ce X |$2 $3 $4 $5 $6 $7 $8 $9 X |.nr m $1 X |.sp X |.fi X |.in +$1 X |.rm -$1 X |.en X | X |.define endnote X |.sp X |.nf X |.in -@nm X |.rm +@nm X |.en X | X X In this version of the "note" and "endnote" macros, the Xfirst parameter ($1) is used to pass the value for indentation Xand right margin adjustment. All the rest of the macro X X X X X X1.0 Proff User's Guide 22 X X Xparameters ($2 - $9) are used as the title of the note. The Xindent value passed as the first parameter is also saved in the Xnumber register "m" to communicate it to the "endnote" macro, Xsuch that when the endnote macro is called, both indent and Xright margin values are adjusted back to normal. It is possible Xand may be more useful to use ".save" and ".restore" commands to Xaccomplish the same task, especially if the macro alters the Xcurrent formatting context drastically. The ".note" and X".endnote" macros may be called as follows: X X | X |.note 5 Asimov's Law of Robotics X |textextextextextextextextextext X | . X | . X | . X |.endnote X | X X In this usage, the indent value will be adjusted by +5, Xright margin will be adjusted by -5, and the title "Asimov's Law Xof Robotics" will appear centered above the note. X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X1.0 Proff User's Guide 23 X X X44..00 EExxeeccuuttiinngg PPRROOFFFF X X The PROFF program may be invoked with a series of optional Xparameters and filenames on the command line. The command Xsynopsis is: X XPROFF [+n] [-n] [-v] [-s] [-pon] [-ifile] input [output] X XThe square brackets indicate an optional parameter. XInterpretation of the parameters is as follows: X X ++nn X Start the printing of the document at the first page X with number n. X X --nn X Stop printing at the first page numbered higher than X n. X X --vv X Verbose mode. PROFF indicates the source files being X included into document, and produces a summary of the X number of textlines read in, the number of lines and X actual pages generated. A memory usage summary of X internal storage for macros, stacks and tables is also X displayed. X X --ss X Stop before each page, including the first one to X allow paper adjustment. A prompt is given just before X the first page. For each page thereafter, the terminal X bell is rung to indicate that another sheet of paper X is needed. X X --ppoonn X Sets the page offset to n. This is equivalent to ".po" X command within the document. It is recommended that X -pon option be used instead of embedding the offset X value within the document. X X --iiffiillee X Includes the given file to the formatted document. X This is equivalent to a ".include file" command within X the document. This option may be repeated more than X once, -ifile1 -ifile2 etc. X X iinnppuutt X Specifies the input file to be formatted. PROFF does X not impose any file extension. The recommended X extension is ".PRF". X X X X X X X X1.0 Proff User's Guide 24 X X X X oouuttppuutt X Specifies the output file for the formatted document. X If this is omitted, output is directed to the user's X terminal. X XFollowing are some examples of PROFF command lines: X X A>PROFF -v proffman.prf X XFormat this document (proffman.prf) in verbose mode, and output Xthe formatted document to the terminal. X X A>PROFF +5 -imacros.pma proffman.prf X XFormat this document, include the external file MACROS.PMA, skip Xthe first four pages and output the formatted document to the Xterminal. X X A>PROFF -po10 proffman.prf proff.man X XFormat this document, shift the entire document by 10 spaces to Xright and output to a file called proff.man. X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X1.0 Proff User's Guide 25 X X X55..00 TTiippss oonn uussiinngg PPRROOFFFF X X55..11 CCaarree aanndd FFeeeeddiinngg ooff MMeemmoorryy X X PROFF uses a dynamic memory allocation scheme for some of Xits operations. These are macro definitions, contents lines, Xvariables and save context operation. Running PROFF under Xmicrocomputers with limited memory resources (64k or less) Xrequire some care in using these commands: X Xa) Do not declare macros that are not needed within the X document. X Xb) Do not use comments within macros. Due to delayed evaluation, X comments will also be stored as a part of the macro X definition. X Xc) Where possible, avoid using too much text within macros. It X is just as easy to pass the information during the macro X call. X Xd) Use only the shortest form of commands within macros. X Xe) Be brief in contents line text. X Xf) Use short variable names as long as it is not so cryptic as X to be confusing. X Xg) Avoid unnecessary blanks within the variable definitions. X Xh) Avoid too many context saves without a corresponding restore. X The restore operation reclaims the memory used for a save. X X X Even if the formatter is used with a system of large memory Xresources, some of the precautions above are applicable. (Utz's X4th law of Computer Programming: Any given program will Xeventually expand to fill all the available memory.) Using the X-v option under memory-restricted systems may be useful in Xdetermining the memory usage. X X X55..22 FFoorrmmaattttiinngg wwiitthhoouutt ffuussss X X PROFF, using its default settings, may provide reasonably Xformatted output in many situations. As an example, examine the Xdocument PROFF.TUT. This document does not use ANY formatting Xcommands. All formatting is done with the default settings. X X X55..33 VVaarriiaabblleess wwiitthhiinn mmaaccrrooss X X X X X X X1.0 Proff User's Guide 26 X X X Variable expansions may be performed within the macros. XTypically, one of the parameters of the macro is assumed to be a Xvariable, which is expanded only after the macro is used. Thus: X X | X |.define xx X |.ce X |$$1 X |.cl $$1 X |.en X | X XThe macro xx assumes the first parameter to be a variable, which Xis centered on the page, and also entered in the table of Xcontents. Note the usage of "$$1". The lines within a macro are Xscanned from right to left for parameter expansion. Thus, "$1" Xis expanded first, resulting in "$<first parameter>". This is Xlater expanded as a variable. X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X1.0 Proff User's Guide 27 X X X66..00 EExxaammppllee mmaaccrrooss X X .! X .! macros to create a point-form lists. X .! note the use of number registers within X .! the macros. X .!------------ X .define list X .nr a $1 X .in $1 X .en X .!------------ X .define item X .sp X .ti -@na X $1 X .en X .!------------ X .define nolist X .in -@na X .sp X .en X .!------------ X XThe "list" macro is used to generate point-form lists. The first Xparameter is an indent value, size of point-str + 1. A typical Xusage may be as follows: X X | X |Project work involves: X |.sp X |.list 3 { size-of-point-str + 1 } X |.item a) { "a)" is the point-str } X |choosing a topic X |.item b) X |defining the topic X |.item c) X |research X |.item d) X |organizing the notes X |{etc.} X |.nolist { readjusts the indent } X | X XThe above usage will produce the following: X X X X X X X X X X X X X1.0 Proff User's Guide 28 X X X X | X |Project work involves: X | X |a) choosing a topic X | X |b) defining the topic X | X |c) research X | X |d) organizing the notes X | X XThe point-form recommendations under section 5.1 (Care and XFeeding of Memory) were generated with the same set of macros Xdescribed above. X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X1.0 Proff User's Guide 29 X X X77..00 AAcckknnoowwlleeddggeemmeennttss X X This document was edited by Terry Lim and Steven Tress. XThe format of the document is largely based on The Freshwater XInstitute RUNOFF User's Guide. The Quotes for the various Xformatting examples are from THE QUOTABLE NOTHING BOOK and from X1001 LOGICAL LAWS, ACCURATE AXIOMS, PROFOUND PRINCIPLES, TRUSTY XTRUISMS, HOMEY HOMILIES, COLORFUL COROLLARIES, QUOTABLE QUOTES, XAND RAMBUNCTIOUS RUMINATIONS FOR ALL WALKS OF LIFE, by Peers, XBennet and Booth, Fawcett Columbine Books, New York. X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X1.0 Appendix A 30 X X XAAppppeennddiixx AA X Summary of Commands X X---------------------------------------------------------- X.fi | .f | .fill X default: initial: yes break: yes X begin filling output lines X---------------------------------------------------------- X.nf | .nofill X default: initial: no break: yes X stop filling X---------------------------------------------------------- X.ju | .j | .justify X default: initial: yes break: yes X begin justifying filled lines X---------------------------------------------------------- X.nj | .nojustify X default: initial: no break: yes X stop justifying X---------------------------------------------------------- X.br | .break X default: initial: break: yes X cause a break and output current line X---------------------------------------------------------- X.in | .lm | .leftmargin [+|-][n] X default: 0 inital: 0 break: yes X set left margin to column n+1 X---------------------------------------------------------- X.ti | .i | .left [+|-][n] X default: 0 initial: break: yes X temporarily indent next output n spaces X---------------------------------------------------------- X.st | .spaceto [-][n] X default: 0 initial: break: yes X space to line +n from top X space to line -n from bottom X---------------------------------------------------------- X.sp | .s | .skip [n] X default: 1 initial: break: yes X space n lines except at top of page X---------------------------------------------------------- X.ce | .center [n | on | off] X default: 1 initial break: yes X center next n lines X center until turned off X---------------------------------------------------------- X.ul | .underline [n | on | off] X default: 1 initial break: no X underline next n lines X underline until turned off X---------------------------------------------------------- X X X X X X X1.0 Appendix A 31 X X X---------------------------------------------------------- X.ul | .underline [all | words] X default: words initial: words break: no X set mode for underline - words or all X---------------------------------------------------------- X.bd | .bold [n | on | off] X default: 1 initial: break: no X boldface (overstrike) next n lines X boldface until turned off X---------------------------------------------------------- X.db | .dbo | .disablebolding X default: initial: no break: no X disable bolding X---------------------------------------------------------- X.eb | .ebo | .enablebolding X default: initial: yes break: no X enable bolding X---------------------------------------------------------- X.ls | .spc | .spacing [n] X default: 1 initial: 1 break: no X set line spacing to n X---------------------------------------------------------- X.bp | .pg | .page [n] X default: +1 initial: 1 break: yes X begin a new page and number it n X---------------------------------------------------------- X.pn | .pagenumber {roman} | {arabic} X default: initial: arabic break: no X set page numbering to arabic or roman X---------------------------------------------------------- X.np | .nopaging X default: initial: no break: yes X disable paging X---------------------------------------------------------- X.pa | .paging X default: initial: yes break: yes X enable paging X---------------------------------------------------------- X.ne | .need | .tp | .testpage [n] X default: 0 initial: break: yes/no X need n lines. Break and generate a new page X if not available X---------------------------------------------------------- X.he | .header <text> X default: null initial: null break: no X set header to text (/left/center/right/) X---------------------------------------------------------- X.fo | .footer <text> X default: null initial: null break: no X set footer to text (/lef/center/right/) X---------------------------------------------------------- X X X X X X X1.0 Appendix A 32 X X X---------------------------------------------------------- X.oh <text> X default: null initial: null break: no X set header on odd pages to text X---------------------------------------------------------- X.eh <text> X default: null initial: null break: no X set header on even pages to text X---------------------------------------------------------- X.of <text> X default: null initial: null break: no X set footer on odd pages to text X---------------------------------------------------------- X.ef <text> X default: null initial: null break: no X set footer on odd pages to text X---------------------------------------------------------- X.po | .offset [+|-][n] X default: 0 initial: 0 break: yes X set page offset to n spaces X---------------------------------------------------------- X.rm | .rightmargin [+|-][n] X default: 65 initial: 65 break: no X set right margin to column n X---------------------------------------------------------- X.pl | .ps | .pagesize [n] X default: 66 initial: 66 break: no X set page length to n lines X---------------------------------------------------------- X.m1 [n] X default: 3 initial: 3 break: no X lines between top of page and header X---------------------------------------------------------- X.m2 [n] X default: 2 initial: 2 break: no X lines between header and text X---------------------------------------------------------- X.m3 [n] X default: 2 initial: 2 break: no X lines between text and footer X---------------------------------------------------------- X.m4 [n] X default: 3 initial: 3 break: no X lines between footer and bottom X---------------------------------------------------------- X.cl | .contline [<n> <text>] X default: initial: break: yes X enter text into table of contents at level X n X---------------------------------------------------------- X X X X X X X X1.0 Appendix A 33 X X X---------------------------------------------------------- X.pc | .printcont [n] X default: 3 initial: 3 break: yes X print table of contents, indent each level X n spaces X---------------------------------------------------------- X.vs | .set <variable> [definition] X default: initial: break: no X set variable to text X---------------------------------------------------------- X.vg | .get <variable> <prompt> X default: initial: break: no X set variable interactively, using text X as prompt X---------------------------------------------------------- X.nr <a-z> [+|-][n] X default: 0 initial: 0 break: no X set number register (a-z) to n X---------------------------------------------------------- X.cc | .cchar [char] X default: "." initial: "." break: no X set command control character to char X---------------------------------------------------------- X.ec | .echar [char] X default: "_" initial: "_" break: no X set universal escape character to char X---------------------------------------------------------- X.so | .source | .include | .require [filename] X default: initial: input break: no X switch input to file X---------------------------------------------------------- X.sv | .save X default: initial: break: yes X save the current formatter context on X context stack X---------------------------------------------------------- X.rs | .restore X default: initial: break: yes X restore the formatter context from context X stack X---------------------------------------------------------- X.lx | .lex <command> [equate] X default: initial: break: no X rename a command X---------------------------------------------------------- X.ap | .autoparagraph X default: initial: no break: no X enable auto-paragraphing X---------------------------------------------------------- X X X X X X X X X1.0 Appendix A 34 X X X---------------------------------------------------------- X.na | nap | .noautoparagraph X default: initial: yes break: no X disable auto-paragraphing X---------------------------------------------------------- X.wr | .write <string> X default: initial: break: no X write a special string to output. line X counter does not change X---------------------------------------------------------- X.de | .define <macro name> X default: initial: break: no X define a macro command - ends at ".en" X---------------------------------------------------------- X.en X default: initial: break: no X end the macro definition X---------------------------------------------------------- X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X X Table Of Contents X X PROFF 1.0 X1.0 Introduction ....................................... 1 X X2.0 General Description ................................. 2 X X 2.1 The Input ........................................ 2 X 2.1.1 Text ....................................... 2 X 2.1.2 Commands ................................... 2 X X 2.2 The Output ....................................... 3 X X 2.3 Executing PROFF .................................. 3 X X 2.4 Bibliographic Notes .............................. 4 X X 2.5 References and Readings ........................... 4 X X3.0 Command Descriptions ................................ 5 X X 3.1 Filling and Justifying ............................ 6 X .fi | .f | .fill..................................... 6 X .nf | .nofill........................................ 6 X .ju | .j | .justify.................................. 6 X .nj | .nojustify..................................... 6 X X 3.2 Text Formatting .................................. 7 X .br | .break......................................... 7 X .in | .lm | .leftmargin [+|-][n]..................... 7 X .ti | .i | .left [+|-][n]............................ 7 X .st | .spaceto [-][n]................................ 7 X .sp | .s | .skip [n]................................. 7 X .ce | .center [n | on | off]......................... 7 X .ul | .underline [n | on | off]...................... 7 X .ul | .underline [all | words]....................... 8 X .bd | .bold [n | on | off]........................... 8 X .db | .dbo | .disablebolding......................... 8 X .eb | .ebo | .enablebolding.......................... 8 X X 3.3 Page Formatting .................................. 9 X .ls | .spc | .spacing [n]............................ 9 X .bp | .pg | .page [n]................................ 9 X .pn | .pagenumber {roman} | {arabic}................. 9 X .np | .nopaging...................................... 9 X .pa | .paging........................................ 9 X .ne | .need | .tp | .testpage [n].................... 9 X .he | .header <text>................................. 9 X .fo | .footer <text>................................. 10 X .oh <text>........................................... 10 X .eh <text>........................................... 10 X .of <text>........................................... 10 X X X - I - X X X X X X .ef <text>........................................... 10 X X 3.4 Page Layout ...................................... 11 X .po | .offset [+|-][n]............................... 11 X .rm | .rightmargin [+|-][n].......................... 11 X .pl | .ps | .pagesize [n]............................ 11 X .m1 [n].............................................. 12 X .m2 [n].............................................. 12 X .m3 [n].............................................. 12 X .m4 [n].............................................. 12 X X 3.5 Table of Contents ................................. 13 X .cl | .contline [<n> <text>]......................... 13 X .pc | .printcont [n]................................. 13 X X 3.6 Miscellaneous ................................... 15 X .vs | .set <variable> [definition]................... 15 X .vg | .get <variable> <prompt>....................... 15 X .nr <a-z> [+|-][n]................................... 16 X .cc | .cchar [char].................................. 16 X .ec | .echar [char].................................. 16 X .so | .source | .include | .require [filename]....... 16 X .sv | .save.......................................... 16 X .rs | .restore....................................... 17 X .lx | .lex <command> [equate]........................ 17 X .ap | .autoparagraph................................. 17 X .na | nap | .noautoparagraph......................... 17 X .wr | .write <string>................................ 18 X X 3.7 Defining New Commands (Macros) ..................... 20 X .de | .define <macro name>........................... 20 X .en.................................................. 20 X X4.0 Executing PROFF ..................................... 23 X X5.0 Tips on using PROFF ................................... 25 X 5.1 Care and Feeding of Memory.......................... 25 X 5.2 Formatting without fuss ........................... 25 X 5.3 Variables within macros ........................... 25 X X6.0 Example macros ...................................... 27 X X7.0 Acknowledgements ................................... 29 X XAppendix A ............................................. 30 X X X X X X X X X X - II - X SHAR_EOF if test 61510 -ne "`wc -c 'proff.man'`" then echo shar: error transmitting "'proff.man'" '(should have been 61510 characters)' fi # End of shell archive exit 0 -- Usenet: [decvax|allegra|linus|ihnp4]!utzoo!yetti!oz Bitnet: oz@[yusol|yuyetti] In the beginning, there was Word all right, except it wasn't fixed number of bits.
oz@yetti.UUCP (Ozan Yigit) (01/14/86)
#!/bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #!/bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # pinit.c # proff.c # proff.h # proff.pro # proff01.c # proff02.c # proffsym.new # This archive created: Mon Jan 13 23:54:09 1986 export PATH; PATH=/bin:$PATH echo shar: extracting "'pinit.c'" '(1236 characters)' if test -f 'pinit.c' then echo shar: over-writing existing file "'pinit.c'" fi sed 's/^X//' << \SHAR_EOF > 'pinit.c' X X X X X#include <stdio.h> X#include <ctype.h> X#include "proff.h" X#include "debug.h" X X/* X * finit - initialise parameters, set default values X * used by .reset command X * X */ Xfinit() X{ X int i; X X inval = 0; X rmval = PAGEWIDTH; X tival = 0; X lsval = 1; X fill = YES; X ceval = 0; X ulval = 0; X boval = 0; X cchar = '.'; X genesc = '_'; X tjust[0] = LEFT; X tjust[1] = CENTER; X tjust[2] = RIGHT; X bsval = 0; X rjust = YES; X ulblnk = BLANK; X X for (i = 0; i < INSIZE; i++) X if (i % 8 == 0) X tabs[i] = YES; X else X tabs[i] = NO; X X lineno = 0; X curpag = 0; X newpag = 1; X plval = PAGELEN; X m1val = 3; X m2val = 2; X m3val = 2; X m4val = 3; X bottom = plval - m3val - m4val; X ehead[0] = '\n'; X ehead[1] = EOS; X ohead[0] = '\n'; X ohead[1] = EOS; X efoot[0] = '\n'; X efoot[1] = EOS; X ofoot[0] = '\n'; X ofoot[1] = EOS; X ehlim[0] = inval; X ehlim[1] = rmval; X ohlim[0] = inval; X ohlim[1] = rmval; X eflim[0] = inval; X eflim[1] = rmval; X oflim[0] = inval; X oflim[1] = rmval; X verbose = NO; X stopx = 0; X frstpg = 0; X lastpg = HUGE; X print = YES; X offset = 0; X outp = 0; X outw = 0; X outwds = 0; X bp = -1; X for (i = 0; i < 26; i++) X nr[i] = 0; X X CEon = FALSE; X ULon = FALSE; X BDon = FALSE; X X onlyrunoff = FALSE; X roman = FALSE; X bolding = YES; X autopar = NO; X} X SHAR_EOF if test 1236 -ne "`wc -c 'pinit.c'`" then echo shar: error transmitting "'pinit.c'" '(should have been 1236 characters)' fi echo shar: extracting "'proff.c'" '(9150 characters)' if test -f 'proff.c' then echo shar: over-writing existing file "'proff.c'" fi sed 's/^X//' << \SHAR_EOF > 'proff.c' X X X Xchar *version = "v.1.1"; X X#include <stdio.h> X#include <ctype.h> X#include "debug.h" X#include "defs.h" X#include "lookup.h" X X X/* X * G L O B A L S X * X */ X#ifndef vms X#define globaldef X#endif X X /* next available char; init = 0 */ Xglobaldef int bp = -1; X /* pushed-back characters */ Xglobaldef char buf[BUFSIZE]; X /* stack of file descriptors */ Xglobaldef FILE *infile[NFILES]; X /* current file is infile[level] */ Xglobaldef int level; X /* stack of output file descriptors */ Xglobaldef FILE *outfile[NFILES]; X /* current output is outfile[olevel]; */ Xglobaldef int olevel; X /* current output file pointer */ Xglobaldef FILE *poutput; X /* number registers a..z */ Xglobaldef int nr[26] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, X 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; X /* system registers a..z */ Xglobaldef int sr[26] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, X 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; X /* last char position in outbuf; init = 0 */ Xglobaldef int outp = 0; X /* width of text currently in outbuf; init = 0 */ Xglobaldef int outw = 0; X /* number of words in outbuf; init = 0 */ Xglobaldef int outwds = 0; X /* lines to be filled collect here */ Xglobaldef char outbuf[MAXOUT]; X /* word in outbuf; init=0 */ X /* current output page number; init = 0 */ Xglobaldef int curpag = 0; X /* next output page number; init = 1 */ Xglobaldef int newpag = 1; X /* next line to be printed; init = 0 */ Xglobaldef int lineno = 0; X /* page length in lines; init = PAGELEN = 66 */ Xglobaldef int plval = PAGELEN; X /* page length save area */ Xglobaldef int savpl = PAGELEN; X /* margin before and including header */ Xglobaldef int m1val = 3; X /* margin after header */ Xglobaldef int m2val = 2; X /* margin after last text line */ Xglobaldef int m3val = 2; X /* bottom margin, including footer */ Xglobaldef int m4val = 3; X /* last live line on page, = plval-m3val-m4val */ Xglobaldef int bottom = PAGELEN - 5; X /* top of page title for even pages;init=NEWLINE */ Xglobaldef char ehead[MAXLINE]; X /* top of page title for odd pages;init=NEWLINE */ Xglobaldef char ohead[MAXLINE]; X /* left,right margins for even header;init=inval,rmval */ Xglobaldef int ehlim[2] = { 0, PAGEWIDTH }; X /* left,right margins for odd header;init=inval,rmval */ Xglobaldef int ohlim[2] = { 0, PAGEWIDTH }; X /* bot of page title for even pages;init=NEWLINE */ Xglobaldef char efoot[MAXLINE]; X /* bot of page title for odd pages;init=NEWLINE */ Xglobaldef char ofoot[MAXLINE]; X /* left,right margins for even footer;init=inval,rmval */ Xglobaldef int eflim[2] = { 0, PAGEWIDTH }; X /* left,right margins for odd footer;init=inval,rmval */ Xglobaldef int oflim[2] = { 0, PAGEWIDTH }; X /* flag for pausing between pages */ Xglobaldef int stopx = 0; X /* first page to begin printing with */ Xglobaldef int frstpg = 0; X /* last page to be printed */ Xglobaldef int lastpg = HUGE; X /* flag to indicate whether page should be printed */ Xglobaldef int print = YES; X /* number of blanks to offset page by; init = 0 */ Xglobaldef int offset = 0; X /* verbose option; init = NO */ Xglobaldef int verbose = NO; X /* bolding option; init = YES; */ Xglobaldef char bolding = YES; X /* fill if YES; init = YES */ Xglobaldef int fill = YES; X /* current line spacing; init = 1 */ Xglobaldef int lsval = 1; X /* current indent; >= 0; init = 0 */ Xglobaldef int inval = 0; X /* current right margin; init = PAGEWIDTH = 60 */ Xglobaldef int rmval = PAGEWIDTH; X /* current temporary indent; init = 0 */ Xglobaldef int tival = 0; X /* number of lines to center; init = 0 */ Xglobaldef int ceval = 0; X /* flag for continuous center */ Xglobaldef char CEon = FALSE; X /* number of lines to underline; init = 0 */ Xglobaldef int ulval = 0; X /* flag for continuous underline */ Xglobaldef char ULon = FALSE; X /* number of lines to boldface; init = 0 */ Xglobaldef int boval = 0; X /* flag for continuous bolding */ Xglobaldef char BDon = FALSE; X /* justification types for heads and foots; */ X /* init = LEFT, CENTER, RIGHT */ Xglobaldef int tjust[3] = { LEFT, CENTER, RIGHT }; X /* number of lines to blank suppress; init=0 */ Xglobaldef int bsval = 0; X /* right justify filled lines if YES; init=YES */ Xglobaldef int rjust = YES; X /* tab stops; init every 8 spaces */ Xglobaldef int tabs[INSIZE]; X /* line control character; init = PERIOD */ Xglobaldef char cchar = '.'; X /* universal escape - init = UNDERBAR */ Xglobaldef char genesc = '_'; X /* character used to underline a BLANK; init = BLANK */ Xglobaldef char ulblnk = ' '; X /* scratch arrays for use by various routines */ Xglobaldef char tbuf1[MAXLINE]; Xglobaldef char tbuf2[MAXLINE]; Xglobaldef char tbuf3[MAXLINE]; Xglobaldef char ttl[MAXLINE]; X /* flag to process runoff symbols only */ Xglobaldef char onlyrunoff = NO; X /* Flag to turn paging off */ Xglobaldef char paging = YES; X /* page number in roman numerals. Init = NO */ Xglobaldef char roman = NO; X /* autopar flag. Init = NO */ Xglobaldef char autopar = NO; X /* temporary indent value for autopar */ Xglobaldef int autoprv = 5; X /* hash tables for macros and variables */ Xglobaldef struct hashlist *macrotab[HASHMAX]; Xglobaldef struct hashlist *gentab[HASHMAX]; X /* linked list entries for contents */ Xglobaldef struct clist *chead = NULL; Xglobaldef struct clist *clast = NULL; X /* keep track of what is done - VERBOSE */ Xglobaldef int p_txtlines = 0; Xglobaldef int p_outlines = 0; Xglobaldef int p_outpages = 0; Xglobaldef int p_memoryus = 0; X X X X/* X * M A I N L I N E OF P R O F F X * X */ X Xmain(argc,argv) Xint argc; Xchar *argv[]; X{ X int i,j,val,type; X char *p,c; X FILE *fp; X X for (i = 1; i < argc; i++) { X p = argv[i]; X if (*p == '-') { X ++p; X if (isalpha(*p)) { X c = *p++; X switch(c) { X X/* verbose stats */ case 'v': X case 'V': X verbose = TRUE; X break; X/* runoff only */ case 'r': X case 'R': X onlyrunoff = TRUE; X break; X/* stop for page */ case 's': X case 'S': X stopx = 1; X break; X/* page offset */ case 'p': X case 'P': X if (*p == 'o' || *p == 'O') { X p++; X j = 0; X val = getval(p, &j, &type); X set(&offset, val, type, 0, 0, X rmval - 1); X } X else X usage(); X break; X/* include file */ case 'i': X case 'I': /* simulate .so <filename> */ X pbstr("\n"); X pbstr(p); X pbstr(".so "); X break; X X/* disable some */ case 'd': X case 'D': X switch (*p) { X X case 'b': X case 'B': X bolding = NO; X break; X case 'p': X case 'P': X paging = NO; X break; X default: X break; X } X break; X X/* garbage */ default: X usage(); X } X } X else X lastpg = atoi(p); X } X else if (*p == '+') { X p++; X if ((frstpg = atoi(p)) == 0) X usage(); X } X else X break; X } X if (i == argc) X usage(); X if ((fp = fopen(argv[i], "r")) == NULL) { X fprintf(stderr, "%s: cannot open.\n",argv[i]); X exit(1); X } X if (p = argv[++i]) { X if ((outfile[0] = fopen(p, "w")) == NULL) { X fprintf(stderr,"%s: cannot create.\n\n", p); X exit(1); X } X } X else X outfile[0] = stdout; X /* set output file level */ X olevel = 0; X poutput = outfile[0]; X /* X * some minor initialisation X */ X X for (i = 0; i < INSIZE; i++) X if (i % 8 == 0) X tabs[i] = YES; X else X tabs[i] = NO; X X ehead[0] = '\n'; X ehead[1] = EOS; X ohead[0] = '\n'; X ohead[1] = EOS; X efoot[0] = '\n'; X efoot[1] = EOS; X ofoot[0] = '\n'; X ofoot[1] = EOS; X X /* initialise contents linked list */ X X chead = (struct clist *) malloc(sizeof(struct clist)); X clast = chead; X p_memoryus += sizeof(struct clist); X X doroff(fp); X brk(); X if (plval <= 100 && (lineno > 0 | outp > 0)) X space(HUGE); X putchar('\n'); X X if(verbose) { X fprintf(stderr,"proff read in %6d textlines to produce\n", X p_txtlines); X fprintf(stderr," %6d lines\n", X p_outlines); X fprintf(stderr," %6d pages of formatted text.\n", X p_outpages); X fprintf(stderr,"\n%d bytes of memory was required\n", X p_memoryus); X fprintf(stderr,"for internal tables and lists.\n"); X } X#ifdef vms X exit(1); X#else X exit(0); X#endif X} SHAR_EOF if test 9150 -ne "`wc -c 'proff.c'`" then echo shar: error transmitting "'proff.c'" '(should have been 9150 characters)' fi echo shar: extracting "'proff.h'" '(4562 characters)' if test -f 'proff.h' then echo shar: over-writing existing file "'proff.h'" fi sed 's/^X//' << \SHAR_EOF > 'proff.h' X X X#include "defs.h" X#include "lookup.h" X X#ifdef vms X#define extern globalref X#endif X /* next available char; init = 0 */ Xextern int bp; X /* pushed-back characters */ Xextern char buf[BUFSIZE]; X /* stack of file descriptors */ Xextern FILE *infile[NFILES]; X /* current file is infile[level] */ Xextern int level; X /* stack of output file descriptors */ Xextern FILE *outfile[NFILES]; X /* current output file is outfile[olevel] */ Xextern int olevel; X /* current output file pointer */ Xextern FILE *poutput; X /* number registers a..z */ Xextern int nr[26]; X /* system registers a..z */ Xextern int nr[26]; X /* last char position in outbuf; init = 0 */ Xextern int outp; X /* width of text currently in outbuf; init = 0 */ Xextern int outw; X /* number of words in outbuf; init = 0 */ Xextern int outwds; X /* lines to be filled collect here */ Xextern char outbuf[MAXOUT]; X /* word in outbuf; init=0 */ X /* current output page number; init = 0 */ Xextern int curpag; X /* next output page number; init = 1 */ Xextern int newpag; X /* next line to be printed; init = 0 */ Xextern int lineno; X /* page length in lines; init = PAGELEN = 66 */ Xextern int plval; X /* page length save area */ Xextern int savpl; X /* margin before and including header */ Xextern int m1val; X /* margin after header */ Xextern int m2val; X /* margin after last text line */ Xextern int m3val; X /* bottom margin, including footer */ Xextern int m4val; X /* last live line on page, = plval-m3val-m4val */ Xextern int bottom; X /* top of page title for even pages;init=NEWLINE */ Xextern char ehead[MAXLINE]; X /* top of page title for odd pages;init=NEWLINE */ Xextern char ohead[MAXLINE]; X /* left,right margins for even header;init=inval,rmval */ Xextern int ehlim[2]; X /* left,right margins for odd header;init=inval,rmval */ Xextern int ohlim[2]; X /* bot of page title for even pages;init=NEWLINE */ Xextern char efoot[MAXLINE]; X /* bot of page title for odd pages;init=NEWLINE */ Xextern char ofoot[MAXLINE]; X /* left,right margins for even footer;init=inval,rmval */ Xextern int eflim[2]; X /* left,right margins for odd footer;init=inval,rmval */ Xextern int oflim[2]; X /* flag for pausing between pages */ Xextern int stopx; X /* first page to begin printing with */ Xextern int frstpg; X /* last page to be printed */ Xextern int lastpg; X /* flag to indicate whether page should be printed */ Xextern int print; X /* number of blanks to offset page by; init = 0 */ Xextern int offset; X /* verbose option; init = FALSE */ Xextern int verbose; X /* bolding option; init = YES; */ Xextern char bolding; X /* fill if YES; init = YES */ Xextern int fill; X /* current line spacing; init = 1 */ Xextern int lsval; X /* current indent; >= 0; init = 0 */ Xextern int inval; X /* current right margin; init = PAGEWIDTH = 60 */ Xextern int rmval; X /* current temporary indent; init = 0 */ Xextern int tival; X /* number of lines to center; init = 0 */ Xextern int ceval; X /* flag for continuous center */ Xextern char CEon; X /* number of lines to underline; init = 0 */ Xextern int ulval; X /* flag for continuous underline */ Xextern char ULon; X /* number of lines to boldface; init = 0 */ Xextern int boval; X /* flag for continuous bolding */ Xextern char BDon; X /* justification types for heads and foots; */ Xextern int tjust[3]; /* init = LEFT, CENTER, RIGHT */ X /* number of lines to blank suppress; init=0 */ Xextern int bsval; X /* right justify filled lines if YES; init=YES */ Xextern int rjust; X /* tab stops; init every 8 spaces */ Xextern int tabs[INSIZE]; X /* line control character; init = PERIOD */ Xextern char cchar; X /* universal escape - init = UNDERBAR */ Xextern char genesc; X /* character used to underline a BLANK; init = BLANK */ Xextern char ulblnk; X /* scratch arrays for use by various routines */ Xextern char tbuf1[MAXLINE]; Xextern char tbuf2[MAXLINE]; Xextern char tbuf3[MAXLINE]; Xextern char ttl[MAXLINE]; X /* flag to process runoff symbols only */ Xextern char onlyrunoff; X /* flag to turn paging off */ Xextern char paging; X /* page number in roman numerals. Init = NO */ Xextern char roman; X /* autopar flag. Init = NO */ Xextern char autopar; X /* temporary indent value for autopar */ Xextern int autoprv; X /* hash tables for macros and variables */ Xextern struct hashlist *macrotab[HASHMAX]; Xextern struct hashlist *gentab[HASHMAX]; X /* linked list entries for contents */ Xextern struct clist *chead; Xextern struct clist *clast; X /* keep track of the work - VERBOSE opt.*/ X Xextern int p_txtlines; Xextern int p_outlines; Xextern int p_outpages; Xextern int p_memoryus; X X#ifdef vms X#undef extern X#endif X SHAR_EOF if test 4562 -ne "`wc -c 'proff.h'`" then echo shar: error transmitting "'proff.h'" '(should have been 4562 characters)' fi echo shar: extracting "'proff.pro'" '(3302 characters)' if test -f 'proff.pro' then echo shar: over-writing existing file "'proff.pro'" fi sed 's/^X//' << \SHAR_EOF > 'proff.pro' X name %time cumsecs #call ms/call X _doesc 14.6 6.48 1929 3.36 X _ngetln 12.0 11.79 2004 2.65 X _dotabs 10.6 16.46 1118 4.18 X _getwrb 8.5 20.21 5493 0.68 X _put 8.4 23.91 1311 2.82 X _width 7.2 27.11 5060 0.63 X _dovar 6.7 30.05 1962 1.50 X cret 3.6 31.62 X csv 3.3 33.10 X _strcpy 3.3 34.57 X _spread 3.0 35.88 389 3.39 X _putwrd 1.8 36.69 4947 0.16 X mcount 1.7 37.44 X _strlen 1.6 38.14 X _leadbl 1.2 38.69 227 2.42 X _text 1.2 39.23 1118 0.48 X _getwrd 0.9 39.64 860 0.48 X _eval 0.9 40.03 95 4.04 X _puttl 0.9 40.41 74 5.18 X _hash 0.8 40.76 1827 0.19 X _getarg 0.7 41.06 861 0.35 X_docline 0.6 41.34 75 3.78 X_command 0.6 41.61 844 0.32 X _bold 0.5 41.84 33 7.07 X _malloc 0.4 42.03 X _putbak 0.4 42.21 3624 0.05 X_comtype 0.4 42.38 844 0.20 X _doroff 0.3 42.53 1 150.03 X _gfield 0.3 42.66 150 0.89 X _skipl 0.3 42.79 1623 0.08 X _brk 0.3 42.90 1073 0.10 X _strcmp 0.2 43.01 X _lookup 0.2 43.11 1053 0.10 X _pbstr 0.2 43.21 443 0.23 X_lexlook 0.2 43.31 716 0.14 X _write 0.2 43.41 X _subst 0.2 43.50 208 0.44 X _skipbl 0.2 43.57 1205 0.06 X__strout 0.2 43.63 X__flsbuf 0.2 43.70 X _jcopy 0.2 43.77 104 0.64 X _underl 0.1 43.83 15 3.89 X _read 0.1 43.88 X _set 0.1 43.91 409 0.09 X_strsave 0.1 43.95 191 0.17 X _atoi 0.1 43.98 X_install 0.1 44.01 58 0.50 X _getval 0.1 44.03 1 25.01 X _getnow 0.1 44.06 74 0.34 X _center 0.0 44.08 9 2.32 X _phead 0.0 44.10 37 0.45 X _main 0.0 44.11 1 16.67 X_sprintf 0.0 44.13 X _justfy 0.0 44.15 104 0.16 X_cvtroma 0.0 44.16 4 4.17 X _dodef 0.0 44.18 8 2.08 X _addstr 0.0 44.20 33 0.51 X _sbrk 0.0 44.21 X _itoc 0.0 44.23 83 0.20 X _close 0.0 44.24 X _fopen 0.0 44.24 X _space 0.0 44.24 219 0.00 X_fprintf 0.0 44.24 X _etext 0.0 44.24 X _gets 0.0 44.24 X _printf 0.0 44.24 X _pfoot 0.0 44.24 37 0.00 X__filbuf 0.0 44.24 X__doprnt 0.0 44.24 X pgen 0.0 44.24 X pfloat 0.0 44.24 X pscien 0.0 44.24 X_getpstr 0.0 44.24 X _finit 0.0 44.24 X _fflush 0.0 44.24 X__cleanu 0.0 44.24 X _fclose 0.0 44.24 X__endope 0.0 44.24 X__findio 0.0 44.24 X _remove 0.0 44.24 X_lexinst 0.0 44.24 X _free 0.0 44.24 X_realloc 0.0 44.24 X _isatty 0.0 44.24 X_monitor 0.0 44.24 X _stty 0.0 44.24 X _gtty 0.0 44.24 X _strcat 0.0 44.24 X _exit 0.0 44.24 X _usage 0.0 44.24 X _error 0.0 44.24 X _ctoi 0.0 44.24 1 0.00 X _creat 0.0 44.24 X _ioctl 0.0 44.24 X _lseek 0.0 44.24 X _open 0.0 44.24 X _profil 0.0 44.24 X _addset 0.0 44.24 8 0.00 X _save 0.0 44.24 4 0.00 X_restore 0.0 44.24 4 0.00 X cerror 0.0 44.24 X ldiv 0.0 44.24 X _map 0.0 44.24 4 0.00 X _prmpt 0.0 44.24 X _gettl 0.0 44.24 8 0.00 SHAR_EOF if test 3302 -ne "`wc -c 'proff.pro'`" then echo shar: error transmitting "'proff.pro'" '(should have been 3302 characters)' fi echo shar: extracting "'proff01.c'" '(11313 characters)' if test -f 'proff01.c' then echo shar: over-writing existing file "'proff01.c'" fi sed 's/^X//' << \SHAR_EOF > 'proff01.c' X X X X X#include <stdio.h> X#include <ctype.h> X#include "proff.h" X#include "debug.h" X X/* X * bold - bold face or overstrike a line X * X */ Xbold(buf,tbuf,size) Xchar buf[]; Xchar tbuf[]; Xint size; X{ X int i,j; X dprintf("bold "); X X j = 0; X for (i = 0; buf[i] != '\n' && j < size - 2; i++) { X tbuf[j] = buf[i]; X j++; X if (buf[i] != ' ' && buf[i] != '\t' && X buf[i] != BACKSPACE ) { X tbuf[j] = BACKSPACE; X tbuf[j+1] = tbuf[j-1]; X j += 2; X } X } X tbuf[j] = '\n'; X tbuf[j+1] = '\0'; X strcpy(buf,tbuf); X} X X/* X * brk - end current filled line X * X */ Xbrk() X{ X dprintf("brk "); X if (outp > 0) { X outbuf[outp] = '\n'; X outbuf[outp+1] = EOS; X put(outbuf); X } X outp = 0; X outw = 0; X outwds = 0; X} X X/* X * center - center a line by setting tival X * X */ Xcenter(buf) Xchar buf[]; X{ X int i; X X dprintf("center "); X X i = (rmval + tival - width(buf)) / 2; X tival = (i > 0) ? i : 0; X} X X/* X * doroff - format text in file fp X * X */ Xdoroff(fp) XFILE *fp; X{ X char inbuf[INSIZE]; X X infile[0] = fp; X for (level = 0; level > -1; level--) { X while (ngetln(inbuf, infile[level]) != EOF) { X if (inbuf[0] == cchar) /* a command */ X command(inbuf); X else { X#ifdef rainbow X if (biosb(2)) X exit(0); X#endif X text(inbuf); X p_txtlines++; X } X } X if (level > 0 && infile[level] > 0) { X fclose(infile[level]); X if (verbose) X fprintf(stderr," done.\n"); X } X } X} X X/* X * gettl - copy title from buf to ttl X * X * modifies lim X */ Xgettl(buf,ttl,lim) Xchar *buf; Xchar *ttl; Xint lim[]; X{ X while (!isspace(*buf)) X buf++; X while (isspace(*buf)) X buf++; X strcpy(ttl,buf); X lim[0] = inval; X lim[1] = rmval; X} X X/* X * getwrb - get a word INCLUDING the trailing blanks X * X */ Xint Xgetwrb(in,i,out) Xchar in[]; Xchar out[]; Xint *i; X{ X int j,k; X dprintf("getval "); X k = *i; X j = 0; X while (in[k] != EOS && in[k] != ' ' && X in[k] != '\t' && in[k] != '\n') { X out[j] = in[k]; X k++; X j++; X } X while (in[k] == ' ') { X out[j] = ' '; X k++; X j++; X } X *i = k; X out[j] = EOS; X return(j); X} X X X/* X * gfield - get next tab or title field X * X */ Xint Xgfield(buf, i, n, temp, delim) Xchar buf[]; Xint *i; Xint n; Xchar temp[]; Xchar delim; X{ X int j,k; X X dprintf("gfield "); X j = 0; X k = *i; X if (n > 0) { X if (buf[k] == delim) X k++; X while (buf[k] != delim && buf[k] != EOS && buf[k] != '\n' && X j <= n) { X temp[j] = buf[k]; X j++; X k++; X } X } X temp[j] = EOS; X while (buf[k] != delim && buf[k] != EOS && buf[k] != '\n') X k++; X *i = k; X return(j); X} X X/* X * jcopy - scopy without copying EOS X * X */ Xjcopy(from, i, to, j) Xchar from[]; Xchar to[]; Xint i; Xint j; X{ X int k1, k2; X dprintf("jcopy "); X X k1 = i; X k2 = j; X while (from[k1] != EOS) { X to[k2] = from[k1]; X k1++; X k2++; X } X} X X/* X * justfy - justifies string in its tab column X * */ Xjustfy(in, left, right, type, out) Xchar in[]; Xchar out[]; Xint left; Xint right; Xint type; X{ X int j,k, n; X X dprintf("justfy "); X n = width(in); X if (type == RIGHT) X jcopy(in, 0, out, right-n); X else if (type == CENTER) { X k = (right+left-n) / 2; X j = (k > left) ? k : left; X jcopy(in, 0, out, j); X } X else X jcopy(in, 0, out, left); X} X X/* X * leadbl - delete leading blanks, set tival X * X */ Xleadbl(buf) Xchar buf[]; X{ X int i, j; X X dprintf("leadbl "); X brk(); X for (i = 0; buf[i] == ' '; i++) /* find 1st non-blank */ X ; X if (buf[i] != '\n') X if (autopar) { X put("\n"); /* blank line */ X tival = inval + autoprv; X } X else X tival = inval + i; /* ??????????? */ X for (j = 0; buf[i] != EOS; j++) { /* move line to left */ X buf[j] = buf[i]; X i++; X } X buf[j] = EOS; X} X X/* X * ngetln - get next line from f into line X * X */ Xint Xngetln(line, f) Xchar line[]; XFILE *f; X{ X int c, i; X X for (i = 0; (c = (bp >= 0) ? buf[bp--] : getc(f)) != EOF; ) { X if (i < MAXLINE - 1) { X line[i++] = (char) c; X } X if (c == '\n' || c == '\r') X break; X } X line[i] = EOS; X if (i == 0 && c == EOF) X i = EOF; X#ifdef DEBUG X printf("ngetln: %s (line)\n",line); X#endif X return(i); X} X X/* X * pbstr - push string back onto input X * X */ Xpbstr(in) Xchar in[]; X{ X X int i; X X dprintf("pbstr "); X for (i = strlen(in) - 1; i >= 0; i--) X putbak(in[i]); X} X X/* X * pfoot - put out page footer X * X */ Xpfoot() X{ X X dprintf("pfoot "); X skipl(m3val); X if (m4val > 0) { X if (curpag % 2 == 1) X puttl(efoot, eflim, curpag); X else X puttl(ofoot, oflim, curpag); X } X if (print == YES) /* flush the page */ X { X putchar(PAGEJECT); /* ... */ X p_outpages++; X if (stopx > 0) /* -s, so flush ^L*/ X putchar('\n'); X } X} X X/* X * phead - put out page header X * X */ Xphead() X{ X dprintf("phead "); X X curpag = newpag; X if (curpag >= frstpg && curpag <= lastpg) X print = YES; X else X print = NO; X if(stopx > 0 && print == YES) X prmpt(&stopx); X newpag++; X if (m1val > 0) { X skipl(m1val-1); X if (curpag % 2 == 0) X puttl(ehead, ehlim, curpag); X else X puttl(ohead, ohlim, curpag); X } X skipl(m2val); X lineno = m1val + m2val + 1; X} X X/* X * prmpt - pause for paper insertion X * prompt if i == 1; increment i X * X */ Xprmpt(i) Xint *i; X{ X int junk,j; X static char bellst[2] = { BEL, EOS}; X X dprintf("prmpt "); X j = *i; X if (j == 1) X#ifdef rainbow X printf("%s\033[7minsert paper and type return\033[0m ",bellst); X#else X printf("%sinsert paper and type return ",bellst); X#endif X else X printf(bellst); X junk = getchar(); X *i = ++j; X} X X/* X * Put - put out line with proper spacing and indenting X * X */ Xput(buf) Xchar buf[]; X{ X register int i; X dprintf("put "); X if (lineno == 0 || lineno > bottom) X phead(); X X if ( print == YES ) { X if (buf[0] == '\n') { /* empty line.. */ X putchar('\n'); X p_outlines++; X } X else { X for ( i = 1 ; i <= offset ; i++ ) /* page offset */ X putchar(' '); X for ( i = 1 ; i <= tival ; i++ ) /* indenting */ X putchar(' '); X X while (*buf != '\0') { X putchar(*buf); X buf++; X } X p_outlines++; X } X } X X tival = inval; X skipl(((lsval-1 < bottom-lineno) ? lsval-1 : bottom-lineno)); X lineno += lsval; X X if (lineno > bottom) X pfoot(); X X} X X/* X * putbak - push character back onto input X * X */ Xputbak(c) Xchar c; X{ X dprintf("putbak "); X X bp++; X if (bp > BUFSIZE) X error("too many characters pushed back.\n"); X buf[bp] = c; X} X X X/* X * puttl - put out title line with optional page number & date X * X */ Xputtl(buf, lim, pageno) Xchar buf[]; Xint lim[]; Xint pageno; X{ X char chars[9],cdate[27]; X char rmstr[MAXTOK]; X char delim; X char *tp; X int j; X int nc, n, i, left, right, ncd; X X dprintf("puttl "); X if (print == NO) X return; X left = lim[0]; /* no more +1 here */ X right = lim[1]; /* no more +1 here */ X nc = itoc(pageno, chars, MAXCHARS); X if (roman) { X nc = cvtroman(chars,rmstr); X strcpy(chars,rmstr); X } X getnow(cdate); X ncd = strlen(cdate); X i = 0; X delim = buf[i]; X for (j = 0; j < right; j++) X ttl[j] = ' '; X n = 0; X do { X if (gfield(buf, &i, right-left, tbuf1, delim) > 0) { X subst(tbuf1, PAGENUM, tbuf2, chars, nc); X subst(tbuf2, CURRENTDATE, tbuf1, cdate, ncd); X justfy(tbuf1, left, right, tjust[n], ttl); X } X n++; /* update title counter */ X } X while (buf[i] != EOS && buf[i] != '\n' && n != 3); X X for( ; right >= 1 ; right--) X if( ttl[right-1] != ' ' ) X break; X ttl[right] = '\n'; X ttl[right+1] = EOS; X for (i = 1; i <= offset; i++) X putchar(' '); /* offset */ X tp = ttl; X while (*tp != '\0') { X putchar(*tp); X tp++; X } X p_outlines++; X} X X/* X * set - set parameter and check range X * X */ Xset(param, val, argtyp, defval, minval, maxval) Xint *param; Xint val; Xint argtyp; Xint defval; Xint minval; Xint maxval; X{ X int i; X dprintf("set "); X i = *param; X if (argtyp == '\n') /* defaulted */ X i = defval; X else if (argtyp == '+') /* relative +*/ X i += val; X else if (argtyp == '-') /* relative -*/ X i -= val; X else /* absolute */ X i = val; X i = (i < maxval) ? i : maxval; /* min */ X i = (i > minval) ? i : minval; /* max */ X *param = i; X} X X/* X* skipl - output n blank lines X* X*/ Xskipl(n) Xregister int n; X{ X register int i; X X dprintf("skip "); X if (print == YES) X for (i = 1; i <= n; i++) { X putchar('\n'); X p_outlines++; X } X} X X/* X * space - space n lines or to bottom of page X * X */ Xspace(n) Xint n; X{ X X dprintf("space "); X brk(); X if (lineno > bottom) X return; X if (lineno == 0) X phead(); X skipl(((n < bottom+1-lineno) ? n : bottom+1-lineno)); X lineno += n; X if (lineno > bottom) X pfoot(); X} X X/* X * spread - spread words to justify right margin X * X */ Xspread(buf, outp, nextra, outwds) Xchar buf[]; Xint outp; Xint nextra; Xint outwds; X{ X int dir = 0; X X register int i, j; X int nb, ne, nholes; X X dprintf("spread "); X if (nextra <= 0 || outwds <= 1) X return; X dir = 1 - dir; /* reverse previous direction */ X ne = nextra; X nholes = outwds - 1; X if (tival != inval && nholes > 1) X nholes--; X i = outp - 1; X j = (MAXOUT-2 < i+ne) ? MAXOUT-2 : i+ne; /* leave room for '\n', EOS */ X while (i < j) { X buf[j] = buf[i]; X if (buf[i] == ' ' && buf[i-1] != ' ') { X if (dir == 0) X nb = (ne-1) / nholes + 1; X else X nb = ne / nholes; X ne -= nb; X nholes--; X for ( ; nb > 0; nb--) { X j--; X buf[j] = ' '; X } X } X i--; X j--; X } X} X X/* X * subst - substitutes a string for a specified character X * X */ Xsubst(in, chr, out, subara, n) Xchar in[]; Xchar chr; Xchar out[]; Xchar subara[]; Xint n; X{ X register int i, j, k; X X dprintf("subst "); X j = 0; X for (i = 0; in[i] != EOS; i++) X if (in[i] == chr) X for (k = 0; k < n; k++) { X out[j] = subara[k]; X j++; X } X else { X out[j] = in[i]; X j++; X } X out[j] = EOS; X} X X/* X * Text process text lines X * X */ X Xtext(inbuf) Xchar inbuf[]; X{ X int i; X register int j; X char wrdbuf[INSIZE]; X X dovar(wrdbuf,inbuf); /* expand variables */ X strcpy(inbuf,wrdbuf); X doesc(inbuf, wrdbuf, INSIZE); /* expand escapes */ X dotabs(inbuf, wrdbuf, INSIZE); /* expand tabs */ X X if(inbuf[0] == ' ' || inbuf[0] == '\n') X leadbl(inbuf); /* move left, set tival */ X if(ulval > 0 || ULon) /* word underlining */ X { X underl(inbuf, wrdbuf, INSIZE); X ulval--; X } X if(boval > 0 || BDon) /* boldfacing */ X { X bold( inbuf, wrdbuf, INSIZE); X boval--; X } X if(ceval > 0 || CEon) /* centering */ X { X center(inbuf); X put(inbuf); X ceval--; X } X else if( inbuf[0] == '\n' ) /* all blank line */ X put(inbuf); X else if( fill == NO ) /* unfilled text */ X put(inbuf); X else /* filled text */ X { X i = strlen(inbuf) - 1; X inbuf[i] = ' '; X if( inbuf[i-1] == '.' ) X { X i++; X inbuf[i] = ' '; X } X inbuf[i+1] = EOS; X for( i = 0 ; getwrb(inbuf, &i, wrdbuf) > 0 ; ) X putwrd(wrdbuf); X } X} X X/* X * Underl underline words in a line X * X */ Xunderl(buf, tbuf, size) Xchar buf[]; Xchar tbuf[]; Xint size; X{ X int i, j; X X j = 0; X for(i = 0 ; buf[i] != '\n' && j < size - 2; i++) { X if( buf[i] != ' ' && buf[i] != BACKSPACE && buf[i] != '_' ) { X tbuf[j++] = '_'; X tbuf[j++] = BACKSPACE; X } X if( buf[i] == BLANK ) X tbuf[j++] = ulblnk; X else X tbuf[j++] = buf[i]; X } X X tbuf[j] = '\n'; X tbuf[j+1] = '\0'; X strcpy(buf, tbuf); X} X X/* X * width - compute width of character string X * X */ Xint Xwidth(buf) Xchar buf[]; X{ X int k,i; X X dprintf("width "); X k = 0; X for (i = 0; buf[i] != EOS; i++) X if (buf[i] == BACKSPACE) X k--; X else if (buf[i] >= ' ' && buf[i] <= '~') X k++; X return(k); X} X/* X * getnow - get the date from command line if present. X * if not specified, prompt user for it. X * X * (stub) X */ Xgetnow(date) Xchar date[]; X{ X dprintf("getnow "); X strcpy(date,"00-xxx-1900 00:00:00"); X} SHAR_EOF if test 11313 -ne "`wc -c 'proff01.c'`" then echo shar: error transmitting "'proff01.c'" '(should have been 11313 characters)' fi echo shar: extracting "'proff02.c'" '(2681 characters)' if test -f 'proff02.c' then echo shar: over-writing existing file "'proff02.c'" fi sed 's/^X//' << \SHAR_EOF > 'proff02.c' X X X X X#include <stdio.h> X#include <ctype.h> X#include "defs.h" X#include "debug.h" X X/* X * addset - put c in array[i], if it fits, increment i X * X */ Xint Xaddset(c,array,i,maxsize) Xchar c; Xchar array[]; Xint *i; Xint maxsize; X{ X int n,status = NO; X dprintf("addset "); X n = *i; X if (n <= maxsize - 1) { X array[n++] = c; X status = YES; X } X *i = n; X return(status); X} X X/* X * addstr - add string s to str[i] if it fits, increment i X * X */ Xint Xaddstr(s,str,i,maxsize) Xchar s[]; Xchar str[]; Xint *i; Xint maxsize; X{ X int k,j,status = NO; X X dprintf("addstr "); X j = *i; X if (j + strlen(s) <= maxsize - 1) { X for (k = 0; s[k] != EOS; k++) X str[j++] = s[k]; X status = YES; X } X *i = j; X return(status); X} X X/* X * ctoi - convert string at in[i] to integer, increment i X * X */ Xint Xctoi(in,i) Xchar in[]; Xint *i; X{ X int j,n,sign; X X dprintf("ctoi "); X n = 0; X for (j = *i; in[j] == ' ' || in[j] == '\t'; j++) X ; /* skip leading garbage */ X sign = 1; X if (in[j] == '+' || in[j] == '-') /* sign */ X sign = (in[j++] == '+') ? 1 : -1; X for (n = 0; in[j] >= '0' && in[j] <= '9'; j++) X n = 10 * n + in[j] - '0'; X *i = j; X return(sign * n); X} X X/* X * error - print message and terminate X * X */ Xerror(s) Xchar s[]; X{ X fprintf(stderr,"%s\n",s); X exit(1); X} X X/* X * getwrd - get non-blank word from in[i] into out, increment i X * X */ Xint Xgetwrd(in,i,out) Xchar in[]; Xint *i; Xchar out[]; X{ X int j,size = 0; X X for (j = *i; in[j] == '\t' || in[j] == ' '; j++) X ; /* skip leading garbage */ X while (in[j] != ' ' && in[j] != '\t' && X in[j] != EOS && in[j] != '\n') X out[size++] = in[j++]; X out[size++] = EOS; X *i = j; X#ifdef DEBUG X printf("getwrd: %s\n",out); X#endif X return(size); X} X/* X * skipbl - skip blanks, tabs at str[i], increment i X * X */ Xskipbl(str,i) Xchar str[]; Xint *i; X{ X int n; X dprintf("skipbl "); X n = *i; X while (str[n] == ' ' || str[n] == '\t') X n++; X *i = n; X} X X/* X * itoc - special version of itoa X * X */ Xint Xitoc(n,str,size) Xint n; Xchar str[]; Xint size; X{ X X int i,j,k,sign; X char c; X X dprintf("itoc "); X if ((sign = n) < 0) X n = -n; X i = 0; X do { X str[i++] = n % 10 + '0'; X } X while ((n /= 10) > 0 && i < size-2); X if (sign < 0 && i < size-1) X str[i++] = '-'; X str[i] = EOS; X /* X * reverse the string and plug it back in X * X */ X for (j = 0, k = strlen(str) - 1; j < k; j++, k--) { X c = str[j]; X str[j] = str[k]; X str[k] = c; X } X return(i); X} X X/* X * usage - obvious.. X * X */ Xusage() X{ X#ifdef rainbow X fprintf(stderr,"%s %s", X "usage: proff \033[7m[+n] [-n] [-v] [-ifile] [-s] [-pon]\033[0m", X "\033[1minfile\033[0m \033[7m[outfile]\033[0m\n"); X#else X fprintf(stderr, X "usage: proff [+n] [-n] [-v] [-ifile] [-s] [-pon] infile [outfile]"); X#endif X exit(0); X} SHAR_EOF echo shar: a missing newline was added to "'proff02.c'" if test 2681 -ne "`wc -c 'proff02.c'`" then echo shar: error transmitting "'proff02.c'" '(should have been 2681 characters)' fi echo shar: extracting "'proffsym.new'" '(3452 characters)' if test -f 'proffsym.new' then echo shar: over-writing existing file "'proffsym.new'" fi sed 's/^X//' << \SHAR_EOF > 'proffsym.new' X X! proff symbols X! flag value of 1 indicate X! a runoff-supported symbol X! feb. 1984 X! X! reset the formatter X! Xreset RESET X! X! bolding X! Xbd BD Xbold * X!disable_bolding DBO 1 Xdisablebolding DBO 1 Xdbo * 1 Xdb * X!enable_bolding EBO 1 Xenablebolding EBO 1 Xebo * 1 Xeb * X! X! new page & paging modes X! Xbp BP Xpage * 1 Xpg * 1 Xpaging PGI 1 Xpa * 1 Xnopaging NPA 1 Xnp * X! X! break X! Xbr BR 1 Xbreak * 1 X! Xbs BS X! X! setup control character X! Xcc CC Xcchar * X! X! centering X! Xce CE Xcenter * X! Xcu CU X! X! macro definitions X! Xde DE Xdefine * X! X! setup generic escape character X! Xec EC Xechar * X! X! even footers and headers X! Xef EF Xeh EH X! X! end macro definition X! X!en EN X! X! fill the lines X! Xfi FI Xf * 1 Xfill * 1 X! X! general footers and headers X! Xfo FO Xfooter * Xhe HE Xheader * X! X! indentation (permanent) X! Xin IN Xlm * 1 X!left_margin * 1 Xleftmargin * 1 X! X! justification X! Xju JU Xj * 1 Xjustify * 1 X! X! line spacing X! Xls LS Xspacing * 1 Xspc * 1 X! X! margin spacing X! Xm1 M1 Xm2 M2 Xm3 M3 Xm4 M4 X! X! test for page X! Xne NE Xneed * X!test_page * 1 Xtestpage * 1 Xtp * 1 X! X! disable fill X! Xnf NF 1 Xnofill * X!no_fill * 1 X! X! disable justification X! Xnj NJ 1 Xnojustify * X!no_justify * 1 X! X! number registers X! Xnr NR X! X! external output X! Xou OU Xoutput * Xoe OE Xoutend * X! X! odd footers and headers X! Xof OF Xoh OH X! X! page length X! Xpl PL Xps * 1 X!page_size * 1 Xpagesize * 1 X! X! page offset X! Xpo PO Xoffset * X! X! right margin X! Xrm RM 1 X!right_margin * 1 Xrightmargin * 1 X! X! external input (include) X! Xso SO Xsource * Xinclude * Xrequire * 1 Xreq * 1 X! X! skip line (blank lines) according to spacing X! sp is not the same as runoff sp X! Xsp SP Xskip * 1 Xs * 1 X! X! blank line X! X!blank BL 1 X!b * 1 X! X! space from top (or bottom) X! Xst ST Xskipto * X! X! temporary indent X! Xti TI Xleft * 1 X! X! underline X! Xul UL Xunderline * X! X! substitute (using reqular expresions) X! X!su SU X!subs * X!substitute * X!esu ESU X!enable_subs * X!dsu DSU X!disable_subs * X! X! save and restore of FSECT X! Xsv SAV Xsave * Xrs RST Xrestore * X! X! looping formatting for each variable X! X!for FOR X!foreach * X!enf ENF X!endfor * X! X! permanent symbol replacement X! Xlx LEX Xlex LEX X! X! ignore character X! Xig IG Xignore IG X! X! variable definition X! Xvs SET Xset * Xvg GET Xget * X! X! page numbering (roman or arabic) X! Xpn PN Xpagenumber * X! X! paragraphing X! Xap AP 1 Xautoparagraph * 1 Xna * Xnap NAP 1 X!no_autoparagraph * 1 Xnoautoparagraph * 1 X!paragraph PAR 1 X!p * 1 X!set_paragraph SPR 1 X!setparagraph * 1 X!spr * 1 X! X! X!comment COM 1 X! X! same as pagenumber X! X!display_number DNM 1 X!dnm * 1 X! X! entry into an index listing X! X!entry ENT 1 X!y * 1 X! X! entry into contents table X! Xcl CL Xcontline * Xpc PC Xprintcont * X! X! conditional formatting X! X!if CIF 1 X!else CELSE 1 X!endif CENDIF 1 X!ifnot CIFNOT 1 X! X! list generation X! X!list LST 1 X!end_list ELS 1 X!endlist ELS 1 X!els * 1 X!list_element LEM 1 X!listelement LEM 1 X!le * 1 X! X! literal mode (nf-nj-lm0-rm150) X! Xliteral LTR 1 Xlt * 1 X!end_literal ELT 1 Xendliteral ELT 1 Xel * 1 X! X! overstrike control X! X!enable_overstriking EOV 1 X!eov * 1 X!disable_overstriking DOV 1 X!dov * 1 X! X! repeat a string X! X!repeat REP 1 X!rpt * 1 X! X! flush right margin X! X!right RIG 1 X!r * 1 X! X! write out a special string X! Xwr WR Xwrite * X! X! end of definitions X SHAR_EOF if test 3452 -ne "`wc -c 'proffsym.new'`" then echo shar: error transmitting "'proffsym.new'" '(should have been 3452 characters)' fi # End of shell archive exit 0 -- Usenet: [decvax|allegra|linus|ihnp4]!utzoo!yetti!oz Bitnet: oz@[yusol|yuyetti] In the beginning, there was Word all right, except it wasn't fixed number of bits.
oz@yetti.UUCP (Ozan Yigit) (01/14/86)
#!/bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #!/bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # debug.h # defs.h # dostuff2.c # eval.c # look.c # lookup.c # lookup.h # ltb.c # makefile # map.c # This archive created: Mon Jan 13 23:53:32 1986 export PATH; PATH=/bin:$PATH echo shar: extracting "'debug.h'" '(126 characters)' if test -f 'debug.h' then echo shar: over-writing existing file "'debug.h'" fi sed 's/^X//' << \SHAR_EOF > 'debug.h' X X X X/* X#define DEBUG X#define PROFILE X*/ X X#ifdef PROFILE X#define dprintf(str) printf((str)); X#else X#define dprintf(str) X#endif X SHAR_EOF if test 126 -ne "`wc -c 'debug.h'`" then echo shar: error transmitting "'debug.h'" '(should have been 126 characters)' fi echo shar: extracting "'defs.h'" '(1580 characters)' if test -f 'defs.h' then echo shar: over-writing existing file "'defs.h'" fi sed 's/^X//' << \SHAR_EOF > 'defs.h' X X/* X * defs.h X * X * #define rainbow - rainbow CP/M-86 version X * #define vms - vms version (predefined by VAX11C compiler) X * #define unix - unix version X */ X X/* X * Synonyms for ASCII control characters X * X */ X X#define BACKSPACE 8 X#define BEL 7 X#define BELL 7 X#define BLANK 32 X#define CARRIAGE_RETURN 13 X#define NEWLINE 10 X#define RUBOUT 127 X#define TAB 9 X X/* X * misc. definitions X * X */ X X#define EOS 0 X#define HUGE 30000 X#define NO 0 X#define OK 0 X#define YES 1 X#define FALSE 0 X#define TRUE 1 X#define FILENAMESIZE 50 X#define MAXCHARS 20 X#define MAXLINE 256 X#define MAXTOK 80 X#define ARB MAXLINE X X#define MAXCARD MAXLINE-1 X#define MAXNAME FILENAMESIZE X X#define NCHARS 33 X#define MAXOFILES 12 X X#define ARGFLAG '$' X#define INSIZE MAXLINE X#define MAXOUT 2*MAXLINE X#define MAXDEF 200 X#define NFILES MAXOFILES-4 X#define PAGENUM '#' X#define CURRENTDATE '%' X#define ESCAPE '@' X#define VESCAPE '$' X#define PAGEJECT 12 /* 12 is ASCII formfeed (control-L) */ X#define PAGEWIDTH 65 X#define PAGELEN 62 X#define BUFSIZE 512 /* push back buffer */ X/* X * lexical analyser values X * X * include lexical analyser return constants X * generated by ltb. X * X */ X#include "lextab.d" /* expended format & roff & runoff */ X X#define UNKNOWN 999 X#define MACRO 0 X#define NEGATED -1 X#define LEFT 1 X#define CENTER 2 X#define RIGHT 3 X X/* X * structure definition for contents linked list X * X */ X Xstruct clist { /* list struct for contents */ X char level; X char *str; X int page; X struct clist *nextc; X}; X X#undef putchar X#define putchar(c) putc((c),poutput); X SHAR_EOF if test 1580 -ne "`wc -c 'defs.h'`" then echo shar: error transmitting "'defs.h'" '(should have been 1580 characters)' fi echo shar: extracting "'dostuff2.c'" '(2884 characters)' if test -f 'dostuff2.c' then echo shar: over-writing existing file "'dostuff2.c'" fi sed 's/^X//' << \SHAR_EOF > 'dostuff2.c' X X X X X#include <stdio.h> X#include <ctype.h> X#include "proff.h" X#include "debug.h" X X/* X * dodef - define a command macro (".de xx" is in buf.) X * X */ Xdodef(buf,fd) Xchar buf[]; Xint fd; X{ X char name[MAXNAME],defn[MAXDEF]; X int i,junk; X X dprintf("dodef "); X i = 0; X junk = getwrd(buf, &i, name); X i = getwrd(buf, &i, name); /* get the name */ X if (i == 0) X error("missing name in command def."); X i = 0; X while (ngetln(buf,fd) != NULL) { X if (buf[0] == cchar && buf[1] == 'e' && X buf[2] == 'n' && !isalnum(buf[3])) X break; X junk = addstr(buf, defn, &i, MAXDEF); X } X if (addset(EOS, defn, &i, MAXDEF) == NO) X error("definition too long.\n"); X if (install(name, defn, macrotab) == NULL) X fprintf(stderr,"no room for new definition.\n"); X#ifdef DEBUG X printf("dodef: %s (name) %s (defn)\n",name,defn); X#endif X} X X/* X * doesc - expand escapes in buf X * X */ Xdoesc(buf, tbuf, size) Xchar buf[]; Xchar tbuf[]; Xint size; X{ X int i,j; X X dprintf("doesc "); X j = 0; X for (i = 0; buf[i] != EOS && j < size-1; i++) X /* X * clean up generic escapes along the way. X */ X if (buf[i] == genesc) X tbuf[j++] = buf[++i]; X X else if (buf[i] != ESCAPE) { X tbuf[j] = buf[i]; X j++; X } X else if (buf[i+1] == 'n' && X (buf[i+2] >= 'a' && buf[i+2] <= 'z')) { X j += itoc(nr[buf[i+2] - 'a'], X &tbuf[j], size - j - 1); X i += 2; X } X else { X tbuf[j] = buf[i]; X j++; X } X tbuf[j] = EOS; X strcpy(buf, tbuf); X} X X/* X * dovar - expand variables in buf X * X */ Xdovar(tbuf, buf) Xchar *buf; Xchar *tbuf; X{ X register char *c, *p, t; X struct hashlist *xp; X X while (*buf != '\0') { X if (*buf == genesc) { X *tbuf++ = *buf++; X *tbuf++ = *buf; X } X else if (*buf != VESCAPE) X *tbuf++ = *buf; X else { X buf++; /* skip the ESCAPE */ X if (*buf == '{') X buf++; X p = buf; /* save the beginning address of variable */ X while (isalnum(*buf)) X buf++; X t = *buf; /* save the character*/ X *buf = '\0'; /* hack a null there */ X if ((xp = lookup(p,gentab)) != NULL) { X c = xp->def; /* point to def */ X while (*c != '\0') X *tbuf++ = *c++; X } X if (*(p-1) != '{') X *tbuf++ = t; X else if (t != '}') X fprintf(stderr, "missing \"}\" in %s\n",p); X } X buf++; X } X *tbuf = '\0'; X} X X X/* X * dotabs - expand tabs in buf X * X */ Xdotabs(buf,tbuf,size) Xchar buf[]; Xchar tbuf[]; Xint size; X{ X int i,j; X dprintf("dotabs "); X X j = 0; X for (i = 0; buf[i] != EOS && j < size - 1; i++) X if (buf[i] == '\t') X while (j < size - 1) { X tbuf[j] = ' '; X j++; X if (tabs[j] == YES || j > INSIZE) X break; X } X else { X tbuf[j] = buf[i]; X j++; X } X tbuf[j] = EOS; X strcpy(buf, tbuf); X} X X/* X * docline - produce a "contents" line. X * X */ Xdocline(str,width,cline,page) Xchar *str; Xint width; Xchar *cline; Xint page; X{ X int i; X X for (i = 0; i < width - 6 && cline[i] != '\0'; i++) X str[i] = cline[i]; X while (i < width - 6) X str[i++] = '.'; X sprintf(str+i,"%5d\n",page); X} X SHAR_EOF if test 2884 -ne "`wc -c 'dostuff2.c'`" then echo shar: error transmitting "'dostuff2.c'" '(should have been 2884 characters)' fi echo shar: extracting "'eval.c'" '(1298 characters)' if test -f 'eval.c' then echo shar: over-writing existing file "'eval.c'" fi sed 's/^X//' << \SHAR_EOF > 'eval.c' X X X#include <stdio.h> X#include <ctype.h> X#include "proff.h" X#include "debug.h" X X X/* X * eval - evaluate defined command (push back definition) X * X */ Xeval(buf,defn) Xchar buf[]; Xchar defn[]; X{ X register int j,k; X int i; X int argptr[10]; X X for (i = 0; i < 10 ; i++) X argptr[i] = 0; X X buf[0] = '\0'; /* buf[0] is cchar */ X dprintf(defn); X dprintf("eval "); X i = 1; X argptr[0] = 1; /* first parm is macro name */ X while (buf[i] != ' ' && buf[i] != '\t' && X buf[i] != '\n' && buf[i] != '\0') X i++; X buf[i++] = '\0'; /* EOS terminate */ X /* X * start scanning remaining macro parameters. X * delimiters are blanks or commas. Any string X * enclosed with double quotes are accepted as X * parameters as well X * X */ X for (j = 1; j < 10; j++) { X skipbl(buf, &i); X if (buf[i] == '\n' || buf[i] == '\0') X break; X argptr[j] = i; X while (buf[i] != ' ' && buf[i] != '\t' && X buf[i] != ',' && buf[i] != '\n' && buf[i] != '\0') X i++; X buf[i] = '\0'; X i++; X } X for (k = strlen(defn) - 1; k >= 0; k--) X if (defn[k-1] != ARGFLAG) X putbak(defn[k]); X else { X if (defn[k] < '0' || defn[k] > '9') X putbak(defn[k]); X else { X i = defn[k] - '0'; X i = argptr[i]; X pbstr(&buf[i]); X k--; /* skip over $ */ X } X } X if (k = 0) /* do the last character */ X putbak(defn[k]); X} X SHAR_EOF if test 1298 -ne "`wc -c 'eval.c'`" then echo shar: error transmitting "'eval.c'" '(should have been 1298 characters)' fi echo shar: extracting "'look.c'" '(2939 characters)' if test -f 'look.c' then echo shar: over-writing existing file "'look.c'" fi sed 's/^X//' << \SHAR_EOF > 'look.c' X X X X X/* X * from K&R "The C Programming language" X * Table lookup routines X * X */ X#include <stdio.h> X#include "lookup.h" X/* X * hash - for a hash value for string s X * X */ Xhash(s) Xchar *s; X{ X int hashval; X X for (hashval = 0; *s != '\0';) X hashval += *s++; X return (hashval % HASHMAX); X} X X/* X * lookup - lookup for a string s in the hash table X * X */ Xstruct hashlist X*lookup(s, hashtab) Xchar *s; Xstruct hashlist *hashtab[]; X{ X struct hashlist *np; X X for (np = hashtab[hash(s)]; np != NULL; np = np->next) X if (strcmp(s, np->name) == 0) X return(np); /* found */ X return(NULL); /* not found */ X} X X/* X * install - install a string name in hashtable and its value def X * at a given hashtable. X */ Xstruct hashlist X*install(name,def,hashtab) Xchar *name; Xchar *def; Xstruct hashlist *hashtab[]; X{ X int hashval; X struct hashlist *np, *lookup(); X char *strsave(), *malloc(); X X if ((np = lookup(name, hashtab)) == NULL) { /* not found.. */ X np = (struct hashlist *) malloc(sizeof(*np)); X if (np == NULL) X return(NULL); X if ((np->name = strsave(name)) == NULL) X return(NULL); X hashval = hash(np->name); X np->next = hashtab[hashval]; X hashtab[hashval] = np; X } else /* found.. */ X free(np->def); /* free prev. */ X if ((np->def = strsave(def)) == NULL) X return(NULL); X return(np); X} X X/* X * strsave - save string s somewhere X * X */ Xchar X*strsave(s) Xchar *s; X{ X char *p, *malloc(); X register int n; X X n = strlen(s) + 1; X if ((p = malloc(n)) != NULL) X strcpy(p, s); X return(p); X} X X/* X * lexinstal - instal a string name in hashtable and its value X * used by lexical analyser to quickly match a token X * and return its lexical value. X * X */ Xstruct lexlist X*lexinstal(name,val,flag,lextable) Xchar *name; Xint val; Xint flag; Xstruct lexlist *lextable[]; X{ X int hashval; X struct lexlist *np,*lexlook(); X char *strsave(), *malloc(); X X if ((np = lexlook(name,lextable)) == NULL) { /* not found.. */ X np = (struct lexlist *) malloc(sizeof(*np)); X if (np == NULL) X return(NULL); X if ((np->name = strsave(name)) == NULL) X return(NULL); X hashval = hash(np->name); X np->link = lextable[hashval]; X lextable[hashval] = np; X } X np->val = val; /* replace prev */ X np->flag = flag; X return(np); X} X X/* X * lexlook - lookup for a string s in the hash table X * used by lexinstal only. X * X */ Xstruct lexlist X*lexlook(s,table) Xchar *s; Xstruct lexlist *table[]; X{ X struct lexlist *np; X X for (np = table[hash(s)]; np != NULL; np = np->link) X if (strcmp(s, np->name) == 0) X return(np); /* found */ X return(NULL); /* not found */ X} X X/* X * remove an item from the hash table forever X * X */ Xstruct lexlist X*remove(s, table) Xchar *s; Xstruct lexlist *table[]; X{ X struct lexlist *np, *xp; X X np = table[hash(s)]; X xp = np; X while (np != NULL) { X if (strcmp(s, np->name) == 0) { X xp->link = np->link; /* remove the link */ X return(np); /* return the lost */ X } X xp = np; X np = np->link; X } X return(NULL); X} X SHAR_EOF if test 2939 -ne "`wc -c 'look.c'`" then echo shar: error transmitting "'look.c'" '(should have been 2939 characters)' fi echo shar: extracting "'lookup.c'" '(3017 characters)' if test -f 'lookup.c' then echo shar: over-writing existing file "'lookup.c'" fi sed 's/^X//' << \SHAR_EOF > 'lookup.c' X X X X X/* X * from K&R "The C Programming language" X * Table lookup routines X * X */ X#include <stdio.h> X#include "proff.h" X/* X * hash - for a hash value for string s X * X */ Xhash(s) Xchar *s; X{ X int hashval; X X for (hashval = 0; *s != '\0';) X hashval += *s++; X return (hashval % HASHMAX); X} X X/* X * lookup - lookup for a string s in the hash table X * X */ Xstruct hashlist X*lookup(s, hashtab) Xchar *s; Xstruct hashlist *hashtab[]; X{ X struct hashlist *np; X X for (np = hashtab[hash(s)]; np != NULL; np = np->next) X if (strcmp(s, np->name) == 0) X return(np); /* found */ X return(NULL); /* not found */ X} X X/* X * install - install a string name in hashtable and its value def X * at a given hashtable. X */ Xstruct hashlist X*install(name,def,hashtab) Xchar *name; Xchar *def; Xstruct hashlist *hashtab[]; X{ X int hashval; X struct hashlist *np, *lookup(); X char *strsave(), *malloc(); X X if ((np = lookup(name, hashtab)) == NULL) { /* not found.. */ X np = (struct hashlist *) malloc(sizeof(*np)); X p_memoryus += sizeof(*np); X if (np == NULL) X return(NULL); X if ((np->name = strsave(name)) == NULL) X return(NULL); X hashval = hash(np->name); X np->next = hashtab[hashval]; X hashtab[hashval] = np; X } else /* found.. */ X free(np->def); /* free prev. */ X if ((np->def = strsave(def)) == NULL) X return(NULL); X return(np); X} X X/* X * strsave - save string s somewhere X * X */ Xchar X*strsave(s) Xchar *s; X{ X char *p, *malloc(); X register int n; X X n = strlen(s) + 1; X if ((p = malloc(n)) != NULL) { X p_memoryus += n; X strcpy(p, s); X } X return(p); X} X X/* X * lexinstal - instal a string name in hashtable and its value X * used by lexical analyser to quickly match a token X * and return its lexical value. X * X */ Xstruct lexlist X*lexinstal(name,val,flag,lextable) Xchar *name; Xint val; Xint flag; Xstruct lexlist *lextable[]; X{ X int hashval; X struct lexlist *np,*lexlook(); X char *strsave(), *malloc(); X X if ((np = lexlook(name,lextable)) == NULL) { /* not found.. */ X np = (struct lexlist *) malloc(sizeof(*np)); X p_memoryus += sizeof(*np); X if (np == NULL) X return(NULL); X if ((np->name = strsave(name)) == NULL) X return(NULL); X hashval = hash(np->name); X np->link = lextable[hashval]; X lextable[hashval] = np; X } X np->val = val; /* replace prev */ X np->flag = flag; X return(np); X} X X/* X * lexlook - lookup for a string s in the hash table X * used by lexinstal only. X * X */ Xstruct lexlist X*lexlook(s,table) Xchar *s; Xstruct lexlist *table[]; X{ X struct lexlist *np; X X for (np = table[hash(s)]; np != NULL; np = np->link) X if (strcmp(s, np->name) == 0) X return(np); /* found */ X return(NULL); /* not found */ X} X X/* X * remove an item from the hash table forever X * X */ Xstruct lexlist X*remove(s, table) Xchar *s; Xstruct lexlist *table[]; X{ X struct lexlist *np, *xp; X X np = table[hash(s)]; X xp = np; X while (np != NULL) { X if (strcmp(s, np->name) == 0) { X xp->link = np->link; /* remove the link */ X return(np); /* return the lost */ X } X xp = np; X np = np->link; X } X return(NULL); X} X SHAR_EOF if test 3017 -ne "`wc -c 'lookup.c'`" then echo shar: error transmitting "'lookup.c'" '(should have been 3017 characters)' fi echo shar: extracting "'lookup.h'" '(553 characters)' if test -f 'lookup.h' then echo shar: over-writing existing file "'lookup.h'" fi sed 's/^X//' << \SHAR_EOF > 'lookup.h' X X X X/* X * from K&R "The C Programming language" X * Table lookup routines X * structure and definitions X * X */ X X /* basic table entry */ Xstruct hashlist { X char *name; X char *def; X struct hashlist *next; /* next in chain */ X}; X /* basic table entry */ Xstruct lexlist { X char *name; X int val; /* lexical value */ X int flag; /* optional flag val */ X struct lexlist *link; /* next in chain */ X}; X X X#define HASHMAX 100 /* size of hashtable */ X Xstruct Xlexlist (*(*lextable))[];/* global pointer for lexical analyser hash table */ X SHAR_EOF if test 553 -ne "`wc -c 'lookup.h'`" then echo shar: error transmitting "'lookup.h'" '(should have been 553 characters)' fi echo shar: extracting "'ltb.c'" '(6222 characters)' if test -f 'ltb.c' then echo shar: over-writing existing file "'ltb.c'" fi sed 's/^X//' << \SHAR_EOF > 'ltb.c' X/* X * ltb.c - Lexical Table Builder X * X * Functional description: X * X * This program builds a file containing the data X * structures of a compile-time-initialised hash table. X * This hash table may later be used for lexical analysis, X * where number of symbols to look up is sufficiently large X * to avoid a run-time table initialization. X * In order to guarantee the success of this setup, the X * hash routine, the lookup and install routines should be X * the same between ltb and the lexical analysis. X * X * synopsis: X * X * ltb <input file> [table name] X * X * input file format: X * X * <token> <value identifier> [flag value] X * X * token: string of alphanumeric characters to be X * matched by the lexical analyser (no blanks). X * these token strings are "installed" to a hash X * table by ltb to avoid run-time overhead. X * value X * identifier: A constant name to be used internally by the X * lexical analyser in place of the actual X * token value. a "#define <indentifier> <value>" X * is generated for each value identifier, where X * value is an odd and unique integer constant. If X * the value identifier is a `*' (star), then the X * previous value is repeated. Thus: X * X * token ident. flag X * X * sp SP 1 X * space * { inherits SP } X * blank * { inherits SP } X * . . . X * . . . X * X * flag value: An additional integer field to pass flags etc. to X * the lexical analyser. If not specified, set to X * 0. token value field must be present for this field X * to be obtained. X * X * outputs: X * X * ltb generates two C include files: X * X * [tablename].d: compile time lexical constants (defines) X * [tablename].h: initialised hash table. X * X * where [tablename] is the name of the hash table as specified X * in the command line of ltb. If not specified, "lextab" is used X * as a default. X * X * routines used by LTB: X * X * hash, lookup and a modified version of install routines, X * as defined in K&R, pp. 134 - 136. X * X * Application areas: X * X * Lexical analysers for compilers, interpreters, spelling X * checkers. X * X * Author: X * Ozan S. Yigit X * Dept. of Computer Science X * York University X * X */ X X#define MAXLINE 80 X#define MAXSYM 80 X X#include <stdio.h> X#include <ctype.h> X#include "lookup.h" X Xstatic struct lexlist *hashtab[HASHMAX]; Xstatic struct lexlist *defitab[HASHMAX]; X Xchar *tabnam; /* table name */ X Xmain(argc,argv) Xint argc; Xchar *argv[]; X{ X FILE *fp; X char line[MAXLINE]; X char sym[MAXSYM],def[MAXSYM]; X register int val; X register int prev, *p; X register char *ptr; X int flag; X struct lexlist *np, *lexlook(); X X if (argc <= 2) { X fprintf(stderr,"%s [-<base>] <symbol file> [tablename]", X argv[0]); X exit(1); X } X X if (*argv[1] == '-') { X val = atoi(argv[1]+1); /* skip "-" and convert */ X val = (val & 1) ? val : val+1; X p = argv[2]; X } X else { X val = 1; X p = argv[1]; X } X X if (argc < 3) X tabnam = "lextab"; X else X tabnam = argv[argc-1]; X X if ((fp = fopen(p,"r")) == NULL) { X fprintf(stderr,"%s:cannot open.\n",argv[1]); X exit(1); X } X else { X prev = val; X while (fgets(line,MAXLINE,fp) != NULL) { X if (*line != '!') { X flag = 0; X def[0] = '\0'; X ptr = line; X while (isspace(*ptr)) X ptr++; X if (*ptr == '\0') X continue; X sscanf(line,"%s %s %d",sym,def,&flag); X if (!(def[0] == '*' && def[1] == '\0')) { X if ((np = lexlook(def,defitab)) == NULL) { X /* value define */ X lexinstal(def,val,0,defitab); X prev = val; X val += 2; X } X else X prev = np->val; X } X /* lexical token */ X lexinstal(sym,prev,flag,hashtab); X } X } X defgen(); X lexgen(); X } X} X/* X * lexgen - print out the hash table in static form X * X */ Xlexgen() X{ X register int i; X register struct lexlist *np; X char filebuf[12]; X char *file; X FILE *op; X X file = filebuf; X X strncpy(file,tabnam,8); X strcat(file,".h"); X X if ((op = fopen(file,"w")) == NULL) { X fprintf(stderr,"%s: cannot create.\n",file); X exit(1); X } X X fprintf(op,"#ifndef STRUC_DEFINED\n\n"); X fprintf(op,"\/\*\t%s\t\*\/\n\n%s\n%s\n%s\n%s\n%s\n",file, X "struct _lex_h { char *__s;", X " int __v;", X " int __f;", X " struct _lex_h *__l;", X "};"); X fprintf(op,"\n#define STRUC_DEFINED\n#endif\n"); X X /* X * generate the hash table entries. X * each entry is followed by the next entry in its X * chain. X * In the operating systems with memory paging, this X * should have the extra advantage of localized X * memory referances. X * X */ X X for (i=0; i < HASHMAX; i++) X if ((np = hashtab[i]) != NULL) X prnode(np,op); X /* X * At last, we generate the pointer array (hashtable). X * this table should be assigned to lextable global X * variable before using with lexlook() or lexinstal(). X * lextable is defined in lookup.h X * X */ X X fprintf(op,"\n\n\/\* Hash Table \*\/\n\n"); X fprintf(op,"struct _lex_h *%s[%d] = {\n\t",tabnam,HASHMAX); X for (i=0; i < HASHMAX - 1; i++) { X np = hashtab[i]; X if(np == NULL) X fprintf(op,"NULL,\t"); X else X fprintf(op,"\&__%s,\t", np->name); X if (i % 4 == 0) X fprintf(op,"\n\t"); X } X np = hashtab[i]; X if (np == NULL) X fprintf(op,"NULL };\n"); X else X fprintf(op,"\&__%s };\n", np->name); X X fclose(op); X} X X/* X * prnode - print the current node. This routine is X * recursive such that printing starts from X * the end of the given list X * X */ Xprnode(np,op) Xregister struct Xlexlist *np; XFILE *op; X{ X if (np->link != NULL) X prnode(np->link,op); X fprintf(op,"struct\n_lex_h __%s = { ", X np->name); X fprintf(op,"\"%s\",\n %6d,%6d,", X np->name, X np->val, X np->flag); X if (np->link != NULL) X fprintf(op,"\&__%s };\n", X (np->link)->name); X else X fprintf(op,"NULL };\n"); X} X X/* X * defgen - generate a file containing the lexical X * constants to be equated to lexical symbols X */ Xdefgen() X{ X register int i; X register struct lexlist *np; X char *file; X char filebuf[12]; X FILE *op; X X file = filebuf; X strncpy(file,tabnam,8); X strcat(file,".d"); X X if ((op = fopen(file,"w")) == NULL) { X fprintf(stderr,"%s: cannot create.\n",file); X exit(1); X } X for (i=0; i < HASHMAX; i++) { X for (np = defitab[i]; np != NULL; np = np->link) X fprintf(op,"\#define %s\t%d\n", X np->name, X np->val); X } X fclose(op); X} X SHAR_EOF if test 6222 -ne "`wc -c 'ltb.c'`" then echo shar: error transmitting "'ltb.c'" '(should have been 6222 characters)' fi echo shar: extracting "'makefile'" '(376 characters)' if test -f 'makefile' then echo shar: over-writing existing file "'makefile'" fi sed 's/^X//' << \SHAR_EOF > 'makefile' XCFLAGS=-O XOBJS= proff.o proff01.o proff02.o lookup.o pinit.o putwrd.o\ X pxlex.o pxxparse.o dostuff2.o eval.o stack.o map.o Xproff: $(OBJS) X cc -s -o proff $(OBJS) X X$(OBJS): lextab.h lextab.d X Xlextab.h lextab.d: proffsym.new ltb X ltb proffsym.new lextab X Xltb: ltb.o look.o X cc -s -o ltb ltb.o look.o Xclean: X rm proff *.o Xarch: X ./archc Makefile *.c *.h proffsym.new >proff.arc SHAR_EOF if test 376 -ne "`wc -c 'makefile'`" then echo shar: error transmitting "'makefile'" '(should have been 376 characters)' fi echo shar: extracting "'map.c'" '(1224 characters)' if test -f 'map.c' then echo shar: over-writing existing file "'map.c'" fi sed 's/^X//' << \SHAR_EOF > 'map.c' X X X#include <stdio.h> X/* X * map map every character of s1 that is specified in s2 X * into s3 and replace in s. (source s1 remains untouched) X */ X Xmap(s,s1,s2,s3) Xregister char *s; Xregister char *s1; Xregister char *s2; Xregister char *s3; X{ X char *t, *t1; X if (*s1 != '\0') { X t = s; X t1 = s1; X strcpy(t,t1); X X while (*s2 != '\0' && *s3 != '\0') { X while (*t1 != '\0') { X if (*t1 == *s2) X *t = *s3; X t++; X t1++; X } X t = s; X t1 = s1; X s2++; X s3++; X } X } X else X *s = '\0'; X} X X/* X * roman - convert a numeric string into roman numerals X * X * icon version: X *procedure roman(n) X * local arabic, result X * static equiv X * initial equiv := ["","I","II","III","IV","V","VI","VII","VIII","IX"] X * integer(n) > 0 | fail X * result := "" X * every arabic := !n do X * result := map(result,"IVXLCDM","XLCDM**") || equiv[arabic+1] X * if find("*",result) then fail else return result X * end X * X */ Xint Xcvtroman(num,rom) Xchar *num; Xchar *rom; X{ X char tmp[20]; X Xstatic char *equiv_U[] = { "","I","II","III","IV","V","VI","VII","VIII","IX" }; X X *rom = NULL; X while (*num != '\0') { X map(tmp,rom,"IVXLCDM","XLCDM**"); X strcpy(rom,tmp); X strcat(rom,equiv_U[*num - '0']); X num++; X } X return(strlen(rom)); X} X SHAR_EOF if test 1224 -ne "`wc -c 'map.c'`" then echo shar: error transmitting "'map.c'" '(should have been 1224 characters)' fi # End of shell archive exit 0 -- Usenet: [decvax|allegra|linus|ihnp4]!utzoo!yetti!oz Bitnet: oz@[yusol|yuyetti] In the beginning, there was Word all right, except it wasn't fixed number of bits.
oz@yetti.UUCP (Ozan Yigit) (01/14/86)
#!/bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #!/bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # putwrd.c # pxlex.c # pxxparse.c # stack.c # This archive created: Mon Jan 13 23:54:44 1986 export PATH; PATH=/bin:$PATH echo shar: extracting "'putwrd.c'" '(980 characters)' if test -f 'putwrd.c' then echo shar: over-writing existing file "'putwrd.c'" fi sed 's/^X//' << \SHAR_EOF > 'putwrd.c' X X X X X#include <stdio.h> X#include "proff.h" X#include "debug.h" X X/* X * putwrd - put a word in outbuf; includes margin justification X * X */ Xputwrd(wrdbuf) Xchar wrdbuf[]; X{ X int last, llval, extra, w; X Xdprintf("putwrd "); X w = width(wrdbuf); X last = strlen(wrdbuf) + outp; /* new end of outbuf */ X#ifdef DEBUG Xprintf("strlen(wrdbuf) = %d\n",strlen(wrdbuf)); X#endif X llval = rmval - tival; X if (outw + w > llval || last >= MAXOUT) { /* too big */ X last -= outp; X extra = llval - outw; X#ifdef DEBUG Xprintf("extra = %d\n",extra); X#endif X for ( ; outp > 0; outp--) X if (outbuf[outp-1] == ' ') X extra++; X else X break; X if (rjust == YES) { X spread(outbuf, outp, extra, outwds); X if (extra > 0 && outwds > 1) X outp += extra; X } X brk(); /* flush previous line */ X } X#ifdef DEBUG Xprintf("putwrd: last=%d w=%d outp=%d llval=%d outw=%d extra=%d\n", X last,w,outp,llval,outw,extra); X#endif X strcpy(&outbuf[outp],wrdbuf); X outp = last; X outw += w; X outwds++; X} X SHAR_EOF if test 980 -ne "`wc -c 'putwrd.c'`" then echo shar: error transmitting "'putwrd.c'" '(should have been 980 characters)' fi echo shar: extracting "'pxlex.c'" '(3358 characters)' if test -f 'pxlex.c' then echo shar: over-writing existing file "'pxlex.c'" fi sed 's/^X//' << \SHAR_EOF > 'pxlex.c' X X X#include <stdio.h> X#include <math.h> X#include <ctype.h> X X/* translation table for control chars */ X Xchar c_ctrl[] = { X 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, X 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, X 0, 0, 0, 0, 0, 0, 0, 0, X 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, X 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, X 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, X 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, X 23, 25, 26, 27, 28, 29, 30, 31, 0, 1, 2, 3, 4, 5, X 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, X 20, 21, 22, 23, 24, 25, 26, 0, 0, 0, 0, 0 X }; X X/* X * getval - evaluate optional numeric argument X * X * increments i X */ Xint Xgetval(buf,i,argtyp) Xchar buf[]; Xint *i; Xint *argtyp; X{ X int j,k; X X j = *i; X k = *argtyp; X X skipbl(buf, &j); X k = buf[j]; X if (k == '+' || k == '-') X j++; X *i = j; X *argtyp = k; X return(ctoi(buf,i)); X} X X/* X * getarg - get the next argument from the buffer X * X * return values: -1 - no argument X * n - number of chars in argument X * X * also handles quoted ("..") strings. If a quote is wanted X * in the string, use "" or \". quotes are stripped. X * X * argument delimiters: blank, tab or comma (,). X * X * increments i X * X */ Xint Xgetarg(buf,i,arg) Xchar buf[]; Xint *i; Xchar arg[]; X{ X int j,k; X register char ch; X X j = *i; X X k = -1; X skipbl(buf,&j); X if (buf[j] != '\0') { X k = 0; X if (buf[j] == '\"') { X j++; X while (buf[j] != '\0') { X if (buf[j] == '\"') { X if (buf[j+1] == '\"') { X arg[k++] = '\"'; X j += 2; X } X else X break; X } X arg[k++] = buf[j++]; X } X arg[k] = '\0'; X j++; /* skip the quote */ X /* peek next char */ X if (isalnum(buf[j])) X error("improper argument list."); X j++; /* skip the delimeter */ X } X else { X ch = buf[j]; X while (ch != ' '&& X ch != '\t' && X ch != ',' && X ch != '\r' && X ch != '\n' && X ch != '\0') { X arg[k++] = buf[j++]; X ch = buf[j]; X } X arg[k] = '\0'; X if (ch != '\0') /* if non-null delimiter, skip */ X j++; X } X *i = j; X } X return(k); X} X X/* X * getpstr - get a special string to print out X * X */ Xgetpstr(buf,out) Xregister char *buf; Xregister char *out; X{ X register int i; X register char c, cc; X register char *num; X char numbuf[9]; X X while(*buf != '\n' && *buf != '\0') { X c = *buf; X switch(c) { X case ' ': X case '\t': X while (*buf == ' ' || *buf == '\t') X buf++; /* skip blanks */ X break; X case '\\': X if (*(buf+1) != '\0') { X *out++ = *(buf+1); X buf += 2; X } X else X buf++; X break; X case '^': X if ((cc = c_ctrl[*(buf+1)]) != 0) X *out++ = cc; X buf += 2; X break; X case '\"': X buf++; /* skip the quote */ X while (*buf != '\0') { X if (*buf != '\"') X *out++ = *buf++; X else if (*(buf+1) == '\"') { X *out++ = '\"'; X buf += 2; X } X else X break; X } X buf++; /* skip the quote */ X break; X case '0': X case '1': X case '2': X case '3': X case '4': X case '5': X case '6': X case '7': X case '8': X case '9': X num = numbuf; X while (isdigit(*buf)) X *num++ = *buf++; X *num = '\0'; X if ((i = atoi(numbuf)) > 256) X error("non-ascii char value in write string."); X else if (i > 0) /* do not output null */ X *out++ = (char) i; X break; X default: X *out++ = *buf++; X } X } X *out = '\0'; X} X SHAR_EOF if test 3358 -ne "`wc -c 'pxlex.c'`" then echo shar: error transmitting "'pxlex.c'" '(should have been 3358 characters)' fi echo shar: extracting "'pxxparse.c'" '(9576 characters)' if test -f 'pxxparse.c' then echo shar: over-writing existing file "'pxxparse.c'" fi sed 's/^X//' << \SHAR_EOF > 'pxxparse.c' X#include <stdio.h> X#include <ctype.h> X#include "proff.h" X#include "debug.h" X#include "lextab.h" X X#define RUNOFF 1 /* recognise RUNOFF commands */ X Xchar literal = NO; /* literal flag */ X X/* X * command - perform formatting command X * X */ Xcommand(buf) Xchar buf[]; X{ X char token[MAXTOK], xtoken[MAXTOK], variable[MAXTOK], *defn; X char special[MAXTOK]; X int argtyp, ct, at, spval, i, flags; X register int val, n, rest; X char onflag = FALSE; X char offlag = FALSE; X struct lexlist *xp; X X dovar(tbuf1,buf); /* use scratch buffer to expand variables */ X strcpy(buf,tbuf1); X X i = 1; X n = getwrd(buf, &i, token); /* get the command token */ X rest = i; /* remaining string */ X ct = comtype(token, n, &defn, &flags); X if (ct == UNKNOWN) X return; X if (literal && ct != ELT) { /* ignore while literal */ X put(buf); X return; X } X X#ifdef DOUBLEWORD X if (flags == 2) { /* check for 2-word command */ X n = getwrd(buf, &i, xtoken); X if (n == 0) { X fprintf(stderr,"%c%s what ?\n", cchar, token); X return; X } X if ((at = comtype(xtoken, n, &defn, &flags)) == UNKNOWN) { X fprintf(stderr,"%c%s %s unknown.\n", cchar, X token, X xtoken); X return; X } X else X ct += at; X } X#endif X X doesc(buf, variable, MAXLINE); /* expand escapes */ X n = getarg(buf, &i, xtoken); /* first parameter*/ X argtyp = '\n'; /* defaulted ** cludge ** */ X val = 0; X if (n > 0) { X if (*xtoken == '+' || *xtoken == '-') { X argtyp = *xtoken; X val = atoi(xtoken+1); X } X else if (isdigit(*xtoken)) { X argtyp = 0; X val = atoi(xtoken); X } X else { X /* check some common flags */ X if (strcmp("on",xtoken) == 0) X onflag = TRUE; X else if (strcmp("off",xtoken) == 0) X offlag = TRUE; X } X } X X switch(ct) { X X case MACRO: X eval(buf, defn); X break; X case FI: X brk(); X fill = YES; X break; X case NF: X brk(); X fill = NO; X break; X case BR: X brk(); X break; X case LS: X set(&lsval, val, argtyp, 1, 1, HUGE); X break; X case CE: X brk(); X if (onflag) X CEon = TRUE; X else if (offlag) { X CEon = FALSE; X ceval = 0; /* reset */ X } X else X set(&ceval, val, argtyp, 1, 0, HUGE); X break; X case UL: X if (onflag) { X ULon = TRUE; X break; X } X else if (offlag) { X ULon = FALSE; X ulval = 0; /* reset */ X break; X } X else X set(&ulval, val, argtyp, 0, 1, HUGE); X X if (!isdigit(*xtoken)) { X if (strcmp("all",xtoken) == 0) { X ulblnk = '_'; X ulval = 0; X } X else if (strcmp("words",xtoken) == 0) { X ulblnk = ' '; X ulval = 0; X } X } X break; X case BD: X if (bolding == YES) { X if (onflag) X BDon = TRUE; X else if (offlag) { X BDon = FALSE; X boval = 0; /* reset */ X } X else X set(&boval, val, argtyp, 0, 1, HUGE); X } X break; X case HE: X gettl(buf, ehead, ehlim); X gettl(buf, ohead, ohlim); X break; X case FO: X gettl(buf, efoot, eflim); X gettl(buf, ofoot, oflim); X break; X case BP: X if (paging == NO) X break; X brk(); X if (lineno > 0) X space(HUGE); X set(&curpag, val, argtyp, curpag+1, -HUGE, HUGE); X newpag = curpag; X break; X case SP: X set(&spval, val, argtyp, 1, 0, HUGE); X space(spval); X break; X case IN: X brk(); X set(&inval, val, argtyp, 0, 0, rmval-1); X tival = inval; X break; X case RM: X set(&rmval, val, argtyp, PAGEWIDTH, tival+1, HUGE); X break; X case TI: X brk(); X set(&tival, val, argtyp, 0, 0, rmval); X break; X case LEX: /****/ X if ((xp = remove(xtoken,lextab)) != NULL) { X if (getwrd(buf, &i, variable) != 0) X lexinstal(variable,xp->val,xp->flag,lextab); X } X else X fprintf(stderr,"%s undefined.\n",xtoken); X break; X case PN: /****/ X if (strcmp(xtoken,"roman") == 0) X roman = TRUE; X else if (strcmp(xtoken,"arabic") == 0) X roman = FALSE; X else X fprintf(stderr,"%c%s does not have %s option.\n", X cchar,token,xtoken); X break; X case IG: /****/ X break; X case SET: /****/ X if (n > 0) { X if (isdigit(*xtoken)) { X fprintf(stderr,"illegal variable name %s\n", X xtoken); X break; X } X *variable = '\0'; X n = getarg(buf, &i, variable); X if (n <= 0) { X fprintf(stderr,"%s: ", xtoken); X gets(variable); X X } X if (*variable != '\0') X install(xtoken, variable, gentab); X } X else X fprintf(stderr,"%c%s needs a variable name.\n", X cchar, token); X break; X case GET: /****/ X if (n > 0) { X if (isdigit(*xtoken)) { X fprintf(stderr,"illegal variable name %s\n", X xtoken); X break; X } X *variable = '\0'; X n = getarg(buf, &i, tbuf3); /* using temp buf3 */ X if (n > 0) { X fprintf(stderr,"%s", tbuf3); X gets(variable); X X } X if (*variable != '\0') X install(xtoken,variable, gentab); X } X else X fprintf(stderr,"%c%s needs a variable name.\n", X cchar, token); X break; X case CL: /****/ X if (argtyp == '\n') { X clast->level = 0; X clast->str = NULL; X } X else { X skipbl(buf,&i); X if (*(buf+i) == '\0') X break; /* no contents line here ! */ X clast->level = val * 3; /* level * indent */ X n = i; X while(*(buf+n) != '\n') X n++; X *(buf+n) = '\0'; /* destroy CR with a null */ X clast->str = strsave(buf+i); X clast->page = curpag; X } X clast->nextc = (struct clist *) malloc(sizeof(struct clist)); X p_memoryus += sizeof(struct clist); X clast = clast->nextc; X clast->nextc = NULL; X break; X case PC: /****/ X brk(); X clast = chead; X while(clast->nextc != NULL) { X if (clast->str == NULL) X put("\n"); X else { X tival = (int) clast->level + inval; X i = rmval - tival; X docline(variable, i, clast->str, clast->page); X put(variable); X } X clast = clast->nextc; X } X break; X case DBO: /****/ X bolding = NO; X break; X case EBO: /****/ X bolding = YES; X break; X case AP: /****/ X autopar = YES; X break; X case NAP: /****/ X autopar = NO; X break; X case SAV: /****/ X brk(); X save(); X break; X case RST: /****/ X brk(); X restore(); X break; X case NPA: /****/ X paging = NO; X savpl = plval; X plval = HUGE; X bottom = plval - m3val - m4val; X break; X case PGI: /****/ X bottom = lineno - 1; /* force end-of-page */ X brk(); X plval = savpl; X break; X case LTR: /****/ X brk(); X if (save()) { X inval = 0; X rmval = 132; X autopar = NO; X lsval = 0; X fill = NO; X literal = YES; X } X break; X case ELT: /****/ X restore(); X literal = NO; X break; X case WR: /****/ X brk(); X getpstr(buf+rest,special); X defn = special; X while(*defn) X putchar(*defn++); X break; X case PL: X if (paging == NO) X break; X set(&plval, val, argtyp, PAGELEN, X m1val + m2val + m3val + m4val + 1, HUGE); X bottom = plval - m3val - m4val; X break; X case PO: X set(&offset, val, argtyp, 0, 0, rmval - 1); X break; X case M1: X set(&m1val, val, argtyp, 3, 0, X plval - m2val - m3val - m4val - 1); X break; X case M2: X set(&m2val, val, argtyp, 2, 0, X plval - m1val - m3val - m4val - 1); X break; X case M3: X set(&m3val, val, argtyp, 2, 0, X plval - m1val - m2val - m4val - 1); X bottom = plval - m3val - m4val; X break; X case M4: X set(&m4val, val, argtyp, 3, 0, X plval - m1val - m2val - m3val - 1); X bottom = plval - m3val - m4val; X break; X case EH: X gettl(buf, ehead, ehlim); X break; X case OH: X gettl(buf, ohead, ohlim); X break; X case EF: X gettl(buf, efoot, eflim); X break; X case OF: X gettl(buf, ofoot, oflim); X break; X case CC: X cchar = *xtoken; X if (cchar == '\0' || cchar == '\n') X cchar = '.'; X if ((lineno + val) > bottom && lineno <= bottom) { X space(val); X lineno = 0; X } X break; X case EC: X genesc = *xtoken; X if (genesc == '\0' || genesc == '\n') X genesc = '_'; X break; X case NE: X if ((lineno + val) > bottom && lineno <= bottom) { X space(val); X lineno = 0; X } X break; X case BS: X set(&bsval, val, argtyp, 1, 0, HUGE); X break; X case JU: X rjust = YES; X break; X case NJ: X rjust = NO; X break; X case SO: X if (n <= 0) X return; X if (level + 1 == NFILES) X error("? SO commands nested too deeply."); X if ((infile[level + 1] = fopen(xtoken, "r")) != NULL) { X level++; X if (verbose == YES) X#ifdef rainbow X fprintf(stderr,"source \033[7m%s\033[0m\n", X xtoken); X#else X fprintf(stderr,"source %s\n",xtoken); X#endif X } X else X fprintf(stderr,"%s: cannot open.\n",xtoken); X break; X case OU: /*****/ X /* skip for now. */ X break; X X case OE: /*****/ X /* skip for now. */ X break; X X case CU: X ulblnk = '_'; X set(&ulval, val, argtyp, 0, 1, HUGE); X break; X case DE: X dodef(buf, infile[level]); X break; X case NR: X if (n <= 0) X return; X if (*xtoken < 'a' || *xtoken > 'z') X error("invalid number register [%c].",*xtoken); X X val = getval(buf, &i, &argtyp); X set(&nr[xtoken[0] - 'a'], val, argtyp, 0, -HUGE, HUGE); X break; X case ST: X if (argtyp == '-') X spval = plval; X else X spval = 0; X set(&spval, val, argtyp, 0, 1, bottom); X if (spval > lineno && lineno == 0) X phead(); X if (spval > lineno) X space(spval - lineno); X break; X case RESET: /****/ X finit(); X break; X default: X error("? Botch in command."); X break; X } X} X X/* X * comtype - decode the command type X * X */ Xint Xcomtype(buf, siz, defn, flags) Xchar buf[]; Xint siz; Xchar **defn; Xint *flags; X{ X X struct hashlist *np; X struct lexlist *xp; X extern struct lexlist *lexlook(); X int i,comtyp; X char c1,c2; X X X#ifdef DEBUG X printf("comtype: %s (token)\n",token1); X#endif X X if ((np = lookup(buf, macrotab)) != NULL) { X *defn=np->def; X return(MACRO); X } X comtyp = UNKNOWN; X X if (*buf == '#' || *buf == '!') X return(comtyp); X X if ((xp = lexlook(buf,lextab)) != NULL) X if (onlyrunoff && (xp->flag != RUNOFF)) { X fprintf(stderr,"%c%s is not a runoff command.\n", X cchar,buf); X return(UNKNOWN); X } X else { X comtyp = xp->val; X *flags = xp->flag; X } X X if (comtyp == UNKNOWN) X fprintf(stderr,"unknown command %c%s\n",cchar,buf); X return(comtyp); X} SHAR_EOF if test 9576 -ne "`wc -c 'pxxparse.c'`" then echo shar: error transmitting "'pxxparse.c'" '(should have been 9576 characters)' fi echo shar: extracting "'stack.c'" '(1911 characters)' if test -f 'stack.c' then echo shar: over-writing existing file "'stack.c'" fi sed 's/^X//' << \SHAR_EOF > 'stack.c' X X X#include <stdio.h> X#include "proff.h" X Xstruct _proffitem { X int Xinval; X int Xrmval; X int Xoffset; X int Xlsval; X int Xplval; X int Xm1val; X int Xm2val; X int Xm3val; X int Xm4val; X int Xfill; X int Xrjust; X X char Xcchar; X char Xgenesc; X char Xroman; X char Xbolding; X char Xpaging; X char Xautopar; X X struct _proffitem *prev; X}; X Xstatic struct X_proffitem *head = NULL; Xstatic struct X_proffitem *top = NULL; X X Xchar *pusherr = "save: stack overflow.\n"; Xchar *poperr = "restore: stack underflow.\n"; X X/* X * save - save proff parameters X * X */ Xsave() X{ X struct _proffitem *sp; X char *malloc(); X X if ((sp = (struct _proffitem *) malloc(sizeof(*sp))) == NULL) { X fprintf(stderr,pusherr); X return(FALSE); X } X else { X p_memoryus += sizeof(struct _proffitem); X if (head == NULL) { /* first element in stack */ X head = sp; X top = NULL; X } X X sp->Xinval = inval; X sp->Xrmval = rmval; X sp->Xoffset= offset; X sp->Xlsval = lsval; X sp->Xplval = plval; X sp->Xm1val = m1val; X sp->Xm2val = m2val; X sp->Xm3val = m3val; X sp->Xm4val = m4val; X sp->Xfill = fill; X sp->Xrjust = rjust; X sp->Xcchar = cchar; X sp->Xgenesc= genesc; X sp->Xroman = roman; X sp->Xbolding = bolding; X sp->Xpaging = paging; X sp->Xautopar = autopar; X X sp->prev = top; X top = sp; X } X return(TRUE); X} X Xrestore() X{ X struct _proffitem *sp; X X if (top != NULL) { X X inval = top->Xinval; X rmval = top->Xrmval; X offset= top->Xoffset; X lsval = top->Xlsval; X plval = top->Xplval; X m1val = top->Xm1val; X m2val = top->Xm2val; X m3val = top->Xm3val; X m4val = top->Xm4val; X fill = top->Xfill; X rjust = top->Xrjust; X cchar = top->Xcchar; X genesc= top->Xgenesc; X roman = top->Xroman; X bolding = top->Xbolding; X paging = top->Xpaging; X autopar = top->Xautopar; X X sp = top->prev; X free(top); X p_memoryus -= sizeof(struct _proffitem); X if ((top = sp) == NULL) X head = NULL; X } X else X fprintf(stderr,poperr); X} SHAR_EOF if test 1911 -ne "`wc -c 'stack.c'`" then echo shar: error transmitting "'stack.c'" '(should have been 1911 characters)' fi # End of shell archive exit 0 -- Usenet: [decvax|allegra|linus|ihnp4]!utzoo!yetti!oz Bitnet: oz@[yusol|yuyetti] In the beginning, there was Word all right, except it wasn't fixed number of bits.
oz@yetti.UUCP (Ozan Yigit) (01/14/86)
#!/bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #!/bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # proffman.prf # This archive created: Mon Jan 13 23:54:56 1986 export PATH; PATH=/bin:$PATH echo shar: extracting "'proffman.prf'" '(46207 characters)' if test -f 'proffman.prf' then echo shar: over-writing existing file "'proffman.prf'" fi sed 's/^X//' << \SHAR_EOF > 'proffman.prf' X X.! Proff user's manual X.! Feb. 1984 by Ozan S. Yigit X.! X.! Edited by Steven Tress and Terry Lim X.! vers. 1.0 X.! X.! ----------- macros ---------- X.! sect - produce a bold section header and X.! enter a contents line. First parameter X.! is indent level for contents line. X.define sect X.sp X.cl $1 $2 $3 $4 $5 $6 $7 X.bd X$2 $3 $4 $5 $6 $7 X.en X.! ----------------------------- X.define note X.sp X.ce XNOTE X.sp X.fi X.in +5 X.rm -5 X.en X.define endnote X.sp X.nf X.in -5 X.rm +5 X.en X.! ----------------------------- X.! Macros to create a point-form lists. X.! Note the use of number registers within X.! the macros. See section 5. X.! X.define list X.nr a $1 X.in +$1 X.en X X.define item X.sp X.ti -@na X$1 X.en X X.define nolist X.in -@na X.sp X.en X.! ----------------------------- X.ce 100 X.st 8 XPROFF User's Guide X.sp XVersion 1.0 X.ce 0 X.nf X.in +25 X.sp 15 X*** ******* X*** ********* X ** ** X ** ** X ********* X ******* X ** X ** X ** X****** X**** X.in -25 X.fi X.ce 100 X.st -8 XOzan S. Yigit & Steven Tress XMarch 1984 X.ce 0 X.bp 1 X.he /1.0/Proff User's Guide/#/ X.ap X.fi X.ju X.sect 0 1.0 Introduction X This manual describes PROFF, a formatter based on the FORMAT utility Xpresented in X.ul XSoftware Tools. X PROFF was produced to provide a powerful formatter that can be used under Xa variety of microcomputers, thus providing a consistent formatting tool Xacross environments. PROFF can be used to format memos, reports, form letters Xand Xdocuments such as this manual. It can also be configured to mimic Xother formatting Xsystems of similar nature. X This document itself was produced with PROFF, using most of its advanced features. XPROFF took care of such things as auto-paragraphing and the production of Xthe Table of Contents as the manual was being formatted. X PROFF was developed under a Digital Equipment Corporation Rainbow 100, Xusing Mark Williams C Compiler for portability reasons. PROFF is Xavailable under VAX/VMS operating system. PROFF implementations for XIBM PC and APPLE ][ microcomputers are also underway. X.st -14 XRainbow, VAX/VMS are trademarks of Digital Equipment Corporation. X.br XMark Williams C Compiler is a trademark of Mark Williams Company. X.br XIBM is a registered trademark of International Business Machines Inc. X.br XAPPLE is a trademark of Apple Computer Inc. X.br XUNIX is a trademark of Bell Laboratories. X.bp X.cl X.sect 0 2.0 General Description X.cl X.sect 1 2.1 The Input X The text that is to be formatted by PROFF is typed into an input file Xusing any text editor. This file contains the text to be formatted Xas well as PROFF commands. X Each line in the input file is either a command line or a text line. A Xcommand line is a line that begins with a period ("."). All other lines are Xtext lines. The command lines are not printed - they tell PROFF how you want Xit to format the text that follows. Appendix A summarizes all of the PROFF Xcommands for a quick reference. X.sect 2 2.1.1 Text X Text can be entered into the input file in any format. PROFF removes all extra Xblanks and tabs between words when operating in fill mode. This means you do Xnot have to worry about how many words you put on a line, and you can break Xlines wherever it is convenient to your typing. Note however, that you cannot Xbreak a word between two lines. X Blanks and tabs at the beginning of a line are not removed. This is useful Xfor producing special tables and performing special types of indentation. XThus, normal text lines should not have any leading tabs or blanks. X.sect 2 2.1.2 Commands X A command is a line that starts with a period. Immediately following the Xperiod is a command name. Some commands accept a numeric quantity or a Xcharacter string parameter, which must be separated from the command name Xby a space or a comma. For example, an indent command might appear as follows: X.save X.in +5 X.nf X.nj X.sp X| X|It is to do nothing that the elect exists. X|.in 5 X|- Oscar Wilde X| X.restore X Assuming that the left margin was at column 1, PROFF would produce the Xfollowing: X.save X.in +5 X.nf X.nj X.sp X.need 4 X| X|It is to do nothing that the elect exists. X| - Oscar Wilde X| X.restore X.sp X(In the examples above, as in those following, the vertical line indicates Xthe left edge of input or the left edge of the printed page). X The number following the command may be preceeded by a "+" or "-" sign. XThis plus or minus sign indicates an addition or subtraction of the number Xto or from the current value for the command. for example, the text: X.sp X.save X.in +5 X.nf X.nj X.need 11 X| X|Nothing to do but work, X|.in +3 X|Nothing to eat but food, X|.in -3 X|Nothing to wear but clothes X|.in +3 X|To keep one from going nude. X|.in +7 X|-Benjamin King X| X.in -5 X.sp Xwill produce as output: X.sp X.in +5 X.need 6 X| X|Nothing to do but work, X| Nothing to eat but food, X|Nothing to wear but clothes X| To keep one from going nude. X| -Benjamin King X| X.restore X If a number is not supplied with a command that requires a number, PROFF Xwill use a default value. The defaults for each command are summarized in XAppendix A. X.cl X.sect 1 2.2 The Output X The main functions performed by PROFF are X.ul Xfilling Xand X.ul Xjustifying. XA line is Xfilled by packing as many words onto it as will fit. The line is justified Xby spacing words evenly between the left and right margins. When PROFF starts, Xit assumes that the text is to be filled and justified. Of course, when fill Xand justify are not needed (as in the case of a letter or a table), there are Xcommands to turn these features off, and back on again, as necessary. X When PROFF is in fill mode, it normally strips out extra spaces and tabs Xbetween words. X Many PROFF commands cause a X.ul Xbreak Xto occur in the output. This means that the line currently being filled is Ximmediately output. Any following text goes into a new output line. X.cl X.sect 1 2.3 Executing PROFF X Once a text file is ready for formatting, PROFF is started by typing Xthe program name, various options, name of the input file and the name Xof the output file. For example the command X.sp X.in +5 XA> proff -po5 proffman.prf proff.man X.sp X.in -5 Xwould produce this document as proff.man, from an input file proffman.prf, Xshifted right by 5 spaces. X(The symbol "A>" is CP/M system prompt). X.cl X.sect 1 2.4 Bibliographic Notes X PROFF wa produced by re-writing the Software Tools Formatter FORMAT. XSome of the ideas are from Freshwater Institute RUNOFF, NROFF, XUniversity of Waterloo SCRIPT Xand other formatters of similar nature. The underlying ideas of the Xmentioned above formatters may be found in X.ul XSoftware Tools Xby B.W. Kernighan and P.J. Plauger. 1976. (Addison-Wesley, Reading, Mass.). X.cl X.sect 1 2.5 References and Readings X.nf X.nap X.sp XBrian W. Kernighan and P. J. Plauger, X.ul XSoftware Tools XAddison-Wesley (1976) X.sp XR. Furuta, J. Scofield and A. Shaw, X.ul XDocument Formatting Systems: X.ul XSurvey, Concepts, and issues XACM Computing Surveys, Sept. 1982, Pp. 417 X.sp XMark Stuart Brader, X.ul XAn Incremental Text Formatter XDepartment of Computer Science XUniversity of Waterloo, CS-81-12 X.bp X.fi X.ap X.cl X.sect 0 3.0 Command Descriptions X This section describes PROFF commands. Commands specify how the program is Xto process the text lines in the input file. Lines in the input file that Xbegin with a period (or the control character selected by the user) Ximmediately followed by a command name are commands. Any line that begins Xwith a period and followed by a _# or _! is a comment line and is ignored Xby PROFF - this allows you to put information in the file that will be neither Xprocessed nor output by PROFF. X As described earlier, some of the commands can be followed by "parameters". XParameters are used in executing a command; for example, in the command X".sp 3", the parameter "3" tells the formatter to insert 3 blank lines into Xthe document. The following conventions are used in describing the parameters: X.sp X.in +5 X.ti -2 Xo Parameters surrounded by square brackets are optional. If not supplied, PROFF Xassumes a default value. X.br X(e.g. .sp [n]) X.sp X.ti -2 Xo Parameters surrounded by angle brackets are mandatory. PROFF will display Xa fatal error message if the parameter is absent. (e.g. .set <variable name>) X.sp X.ti -2 Xo Parameters surrounded by squiggly brackets are to be typed exactly as Xindicated. (e.g. .pn {roman}) X.sp X.ti -2 Xo A bar character seperating the parameters within brackets indicate an Xalternative. (e.g. .st [+|-][n] means both .st [+n] and .st [-n]) X.in -5 X In describing the commands, the command is typed exacty as accepted by PROFF Xwith the associated control character default ("."). If more than one form of Xthe command is accepted by PROFF, the command names are separated with a Xbar indicating an alternative. X.bp X.cl X.sect 1 3.1 Filling and Justifying X.nap X.in +5 X.! X.! define a simple macro for generating the headers. X.! note that the second "$" within macro is for X.! variable expansion. Initially, the variable name X.! is passed into the macro WITHOUT any expension. X.! we also use the new control character within macro. X.! X.define comm X\sp X\cl 2 $$1 X\ti -5 X$$1 X\sp X.en X.! change the control character from period (".") to a backslash ("\") X.! to avoid the interpretation of the command headers X.! X.cchar \ X\! X\! Variable creation X\! We use variables to avoid re-typing of multiple options over X\! and over again. These variable names will be reused in the X\! appendix to produce a quick referance X\! X\set FILL ".fi | .f | .fill" X\comm FILL XThe fill command causes a line to be filled with as many words as the right Xmargin allows. For this purpose, all extra blanks and tabs are removed between Xwords. Each word is separated with a single blank. PROFF automatically assumes Xfill mode during the startup. X\set NOFILL ".nf | .nofill" X\comm NOFILL XNo fill discontinues the filling of the text. PROFF simply copies the text Xto the output. This command may be used to pass tables and other text Xunaltered through the formatter. X\set JUST ".ju | .j | .justify" X\comm JUST XJustify causes the words on a line to be evenly spaced between the left and Xthe right margins. Note that lines can be justified only if lines are also Xbeing filled. PROFF automatically assumes justify mode during the startup. X\set NOJUST ".nj | .nojustify" X\comm NOJUST XNo justify discontinues the text justification. X\in -5 X\cchar . X.bp X.cl X.sect 1 3.2 Text Formatting X.in +5 X.cchar \ X\set BREAK ".br | .break" X\comm BREAK XBreak causes a break: the current line is printed without justification, Xand the next word is placed at the beginning of a new line. Note that many XPROFF commands cause an implicit break. X\set INDENT ".in | .lm | .leftmargin [+|-][n]" X\comm INDENT XIndent causes a break and indents the following lines [n] spaces to the Xright of the left margin. [n] can be negative to allow beginning a line Xto the left of the left margin, however, a line cannot begin to the left of Xcolumn 0. If a plus or minus sign is used with n, then [n] is added or Xsubtracted to or from the current value. X\set TINDENT ".ti | .i | .left [+|-][n]" X\comm TINDENT XTemporary indent is identical to the indent command except that it Xapplies only to the next line of printed text. Thus, the command X".ti +5" would cause the next line to be printed 5 spaces to the right Xof those that follow. X\set SPACETO ".st | .spaceto [-][n]" X\comm SPACETO XSpaceto allows spacing to line [n] from the top of the current page. XIf a negative [n] is specified, than spacing is performed to line [n] Xfrom the bottom of the page (excluding the footer lines). Thus, footnotes Xcan be set at a fixed distance from the bottom of the page by a command such Xas ".st -5". X\set SPACE ".sp | .s | .skip [n]" X\comm SPACE XSpace causes a break and skips [n] lines, except at the top of Xa page. The space command Xis dependent on the setting of line spacing. X\set CENTER ".ce | .center [n | on | off]" X\comm CENTER XCenter causes the next [n] lines of text to be centered between the left Xand right margins. Centering may be started with "on" and terminated with X"off", in which case all input lines between these commands will be centered. X\set UNDLINE ".ul | .underline [n | on | off]" X\comm UNDLINE XUnderline command causes the text on the next [n] input lines to be underlined Xwhen printed. If [n] is omitted, only the next line is underlined. This command Xdoes not cause a break, so words in filled text may be underlined by: X\sp X\save X\cchar . X.in +5 X.nf X.need 11 X.sp X| X|The "Pay-off" Theory: Only X|.ul X|losers X|believe in luck, horses, horoscopes X|and X|.ul X|lotteries. X| X.in -5 X.sp Xto get X.in +5 X.sp X.fi X| X.br X|The "Pay-off" Theory: Only X.ul Xlosers Xbelieve in X.br X|luck, horses, horoscopes and X.ul Xlotteries. X.br X| X.sp X.restore XUnderlining may be started with "on" and terminated with "off", similar to Xthe centering command. X\set CUNDLINE ".ul | .underline [all | words]" X\comm CUNDLINE XThis version of the underline command is used to set the mode of Xunderlining: X\sp X\nap X\in +5 X\nf Xall - underline across all characters, X including spaces. X\br Xwords - underline words only X\fi X\sp X\in -5 X\ap X\set BOLD ".bd | .bold [n | on | off]" X\comm BOLD XThe bold command causes the text on the next [n] input lines to be highlighted Xby overstriking. If [n] is omitted, only the next line is highlighted. XBolding may be started with "on" and terminated with "off" as in the Xcase of the center and underline commands. X\set DBO ".db | .dbo | .disablebolding" X\comm DBO XTurns the bolding off, all bolding commands are ignored. This feature is Xuseful for rough drafts. X\set EBO ".eb | .ebo | .enablebolding" X\comm EBO XTurns the bolding feature back on. Bolding is turned on during the PROFF Xstartup. X\in -5 X\cchar . X.bp X.cl X.sect 1 3.3 Page Formatting X.in +5 X.cchar \ X\set LS ".ls | .spc | .spacing [n]" X\comm LS XLine spacing is the command to set line spacing. Set n to 1 for single spacing, X2 for double spacing etc. X\set BP ".bp | .pg | .page [n]" X\comm BP XThe begin page command causes a break, ends the current page, outputs Xfooters if required and begins a new page. If [n] is present, the page number Xis set to [n]. The default action is to number the pages incrementally. X\set PN ".pn | .pagenumber {roman} | {arabic}" X\comm PN XPage number command defines the format of the page number. Uppercase roman Xnumerals may be obtained with "roman" keyword. To convert the page numbers Xback to normal, "arabic" is specified. PROFF uses arabic numerals as Xa default. X\set NPA ".np | .nopaging" X\comm NPA XNo paging disables the pagination. When PROFF is in no paging mode, X"begin page" (.bp) and "page length" (.pl) commands are ignored. This mode Xof operation is especially useful for using the proff output with the Xmulti-column formatter (MC). X\set PA ".pa | .paging" X\comm PA XPaging enables normal page generation. This command starts a Xnew page and restores the page length to the Xvalue previous to the ".np" command. X\set NE ".ne | .need | .tp | .testpage [n]" X\comm NE XTest page checks to see whether at least [n] lines remain in the Xcurrent page. If less than this number of lines remain, printing will resume Xat the top of a new page. If [n] is missing, it is assumed to be zero. X\set HE ".he | .header <text>" X\comm HE XHeader sets the text to be printed on top of each page. <text> is Xdivided into sections which are to be left justified, centered and right Xjustified. To divide <text> into these three parts, the first character is Xassumed to be a separator. (e.g. /left/center/right/) But any non-alphanumeric Xcharacter may also be used. The characters "#" and "%" are replaced with the Xcurrent page number and day/time in the header. X\set FO ".fo | .footer <text>" X\comm FO XFooter is identical to header except that it sets the text to be printed Xat the bottom of each page. X\set OHE ".oh <text>" X\comm OHE XThe odd header command sets the header for odd pages only. X\set EHE ".eh <text>" X\comm EHE XThe even header command sets the header for even pages only. X\set OFO ".of <text>" X\comm OFO XThe odd footer command sets the footer for odd pages only. X\set EFO ".ef <text>" X\comm EFO XThe even footer command sets the footer for even pages only. X\in -5 X\cchar . X.bp X.cl X.sect 1 3.4 Page Layout X.ap X These commands are used to specify where on the page you want the formatted Xtext to be placed. The general layout of a page is as follows: X.nap X.need 30 X.nf X X page offset (.po) | X | | X V | X +----+-------------------------------------+----+ -+ X | | top margin (m1) includes header | | | X +----+-------------------------------------+----+ | X | | top margin 2 (m2) | | | X +----+-------------------------------------+----+ | X | | . | | P X | |<-- indent (.in) . | | A X | | . | | G X | | T | | E X | | E | | X | | X | | L X | | T | | E X | | . | | N X | | right margin (.rm) -->| | G X | | . | | T X | | . | | H X | | . | | | X +----+-------------------------------------+----+ | X | | bottom margin 3 (m3) | | | X +----+-------------------------------------+----+ | X | | bottom margin (m4) includes footer | | | X +----+-------------------------------------+----+ -+ X | | X | | X.fi X.in +5 X.cchar \ X\set PO ".po | .offset [+|-][n]" X\comm PO XThe page offset command moves the entire page to the right or left depending on the Xspecified value. All indentation is according to the page offset. PROFF Xassumes a page offset of 0 during the startup. If [n] is specified with a Xplus or minus, it will be added or subtracted from the current value. X\set RM ".rm | .rightmargin [+|-][n]" X\comm RM XRight Margin sets the position of the last printable character from the Xleft edge of the page to [n]. Default value for right margin is 65. XA plus or minus value will be added or subtracted from the current value. XIf [n] is not specified, right margin is set to the default value. X\set PL ".pl | .ps | .pagesize [n]" X\comm PL XPage length is used to set the number of lines that are to be printed Xon a page including the header and footer lines. After [n] lines are printed, Xthe paper will advance to the top of next page. The default page length is X66 lines (11 inches for 6 lines/inch). This command is disabled if nopaging Xis set. X\set M1 ".m1 [n]" X\comm M1 XMargin 1 sets the number of lines (including the header) which will be left at Xthe top of the page to [n]. The default setting is 3. If [n] is omitted, is Xset to the default. X\set M2 ".m2 [n]" X\comm M2 XMargin 2 sets the number of blank lines between the header and the first Xline of text. The default setting is 2. X\set M3 ".m3 [n]" X\comm M3 XMargin 3 sets the number of blank lines between the footer and the last line Xof text. The default setting is 2. X\set M4 ".m4 [n]" X\comm M4 XMargin 4 sets the number of lines (including the footer) which will be left at Xthe bottom of the page to [n]. The default setting is 3. X\in -5 X\cchar . X.bp X.cl X.ap X.sect 1 3.5 Table of Contents X This section describes the the commands that are used to generate a table of Xcontents. Basically, a contents line command is used in every place in Xthe document where an entry is needed in the table of contents. PROFF Xstores the text and the page number when it encounters this command. XAfter the the body of the document is processed, a print contents command Xdumps the contents table. The contents should be dumped in a new page, with Xnofill. Page numbering should be disabled if the table of contents is to be Xused in front of the document. X.sp X.in +5 X.ap X.cchar \ X\set CL ".cl | .contline [<n> <text>]" X\comm CL XContents line specifies a line of <text> to be entered into the table of Xcontents. <n> specifies the level at which the item is to be printed Xin the table. When the table is printed, each level of entry will be Xindented by specific number of spaces. X<text> appears in the output exactly as it appears Xin the contents line command, except that leading blanks are removed. XIf no options specified in the contents line, a blank is inserted during Xthe table output. X\set PC ".pc | .printcont [n]" X\comm PC XPrint Contents causes the currently accumulated table of contents to be Xprinted. If [n] is specified, it is used as the indent value for each Xlevel. If [n] is not specified, it is defaulted to 3. X A contents line at level 0 is as wide as rightmargin-indent. The Xoutlook of the table of contents may be changed by altering the right Xmargin and indent values. A typical table of contents may be produced as Xfollows: X\in +5 X\nf X\sp X|.page X|.he //// X|.fo //// X|.nofill X|.sp X|.center X|Table of Contents X|.sp X|.printcont X\in -5 X\fi X\sp XThe following example illustrates the generation of a table of contents. Note Xthat only one table of contents is active for a PROFF session. X\need 40 X\sp X\in +5 X\nf X\nap X.cl X.cl 0 A. Introduction XIntroduction X text X . X.cl X.cl 0 B. Methods XMethods X text X . X.cl 1 a) Sampling Procedures XSampling X text X . X.cl 1 b) Laboratory Procedures XLaboratory X text X . X.cl X.cl 0 C. Results XResults X text X . X . X.pg X.nf X.he //// X.fo //// X.ce XTable of Contents X.sp X.pc X\sp X\in -5 XThese commands will produce the following table: X\sp X\in +5 X Table of Contents X XA. Introduction............................... 1 X XB. Methods.................................... 3 X a) Sampling Procedures..................... 3 X b) Laboratory Procedures................... 4 X XC. Results.................................... 5 X\sp X\in -5 X\fi XMacros may be defined as described in the following sections to help the generation Xof the table of contents. X\cchar . X.in -5 X.bp X.cl X.ap X.sect 1 3.6 Miscellaneous X This section describes miscellaneous commands that radically increase the Xformatting powers of PROFF. With the assistance of variables, PROFF can Xgenerate form letters and documents with dynamic parts. The ability to save Xand restore formatter context eliminates the need to remember the exact Xsettings of the formatter across the document. X.in +5 X.cchar \ X\set VSET ".vs | .set <variable> [definition]" X\comm VSET XSet variable defines a variable to be later used in the document. XIf the definition part is left out, PROFF uses the variable name as a prompt Xand allows the user to define the variable interactively. Variable names cannot Xstart with a numeric character, and may only contain alphanumeric Xcharacters. The definition of a variable may not contain any blanks, unless Xthey are surrounded by double-quotes. To get a double quote within a a quoted Xdefinition, two double-quotes are used. X Once the variable is Xdefined, it can be used anywhere in the document, including the command Xline itself. A variable substitution is invoked by a dollar sign (_$). (A Xliteral _$ is inserted into text using ___$). XA variable name must be delimited by a non-alphanumeric character within the Xtext. If the contents of the variable is to be appended to other Xalphanumeric characters, it must be surrounded by wiggly braces X("{" and "}"). The following is an example of variable usage: X\need 12 X\sp X\nf X|.nf X|.vs v1 Murphy X|_${v1}'s first law: X| Nothing is as easy as it looks. X|_${v1}'s second law: X| Everything takes longer than you think. X|Charley's observation: X| Computers were invented by _$v1. X| X\sp XProduces the following: X\sp X\need 8 X| X|Murphy's first law: X| Nothing is as easy as it looks. X|Murphy's second law: X| Everything takes longer than you think. X|Charley's observation: X| Computers were invented by Murphy. X| X\sp X\fi X\set VGET ".vg | .get <variable> <prompt>" X\comm VGET XGet variable is the interactive version of variable definition. In this Xvariant, a prompt string is used to obtain the value of the variable, Xwhich is typed at the user's terminal. If the prompt string is to Xcontain blanks, tabs etc., it must be enclosed in double quotes. No quotes Xare necessary for input text. X\set VRG ".nr <a-z> [+|-][n]" X\comm VRG XNumber register is used to define registers that contain numeric values. XThere are 26 number registers, named a-z. The command ".nr x n" sets the Xnumber register "x" to value n; ".nr x +n" increments the number register Xby n; ".nr x -n" decrements the number register by n. The value of the Xnumber register x is placed in the text by the appearance of _@nx. A literal X_@ may be inserted using ___@. XNumber registers may be used on command lines and anywhere in the text. X\set CCHAR ".cc | .cchar [char]" X\comm CCHAR XControl Character sets the character that distinguishes PROFF Xcommands from text to be formatted. As a default, control character is set to X(".") period. XThis character may be changed to something other than a period, either Xto mimic other formatters or to disallow interpretation of lines beginning Xwith a period. (This document makes heavy use of the .cc command). X\set ECHAR ".ec | .echar [char]" X\comm ECHAR XEscape Character sets the character that disallows the Xinterpretation of spacial characters such as _@ and _$. PROFF uses an Xunderline ("__") character as a default. X\set SOU ".so | .source | .include | .require [filename]" X\comm SOU XThe source (include) command allows external files to be inserted into the Xinput file Xduring the formatting. Using this feature, tables, graphs and other Xdocuments generated outside PROFF may be included into the document Xbeing formatted. This feature is also very useful in including a common set Xof macros during formatting. Include files may be nested inside other Xinclude files. Currently, PROFF only allows a nested include Xfiles level of 8. Filename may be enclosed in quotes. X\set SAVE ".sv | .save" X\comm SAVE XThe save command allows the saving of the current formatter context on a Xpushdown stack. The saved context of the formatter segment (FSECT) includes Xthe following values and flags: X\need 14 X\sp X\nf X\nap Xvalues flags on | off X------ ----- Xindent (.in) fill (.fi | .nf) Xright margin (.rm) justify (.ju | .nj) Xoffset (.po) paging (.pa | .np) Xline spacing (.ls) number type (.pn) Xpage length (.pl) bolding (.eb | .db) Xmargin values (.m1) autoparagraph (.ap | .na) X (.m2) X (.m3) X (.m4) Xcontrol char (.cc) Xescape char (.ec) X\sp X\ap X\fi X\set RST ".rs | .restore" X\comm RST XThe restore command pops the context stack and restores the values and flags Xas defined above. X\set LEX ".lx | .lex <command> [equate]" X\comm LEX XThe lexical modification command is essentially a permanent replacement of a Xgiven command. This command is used for changing the command names without Xresorting to the macro facility. Lex permanently removes the old Xcommand name from command tables and replaces it with the new definition. XIf the equate is not specified, the command becomes undefined and is Xno longer recognised by PROFF. The command equate should not contain Xnon-alphanumeric characters. X\set APR ".ap | .autoparagraph" X\comm APR XThe autoparagraph command turns on the automatic paragraphing feature. If Xauto-paragraphing is on, every line that starts with a X\ul Xblank Xor a X\ul Xtab Xcharacter starts a new paragraph. A new line is generated (.sp) and Xthe beginning of the paragraph is indented by five spaces. XAutoparagraphing is the equivalent of the following commands: X\in +5 X\nf X| X|textextextextext X|.sp X|.ti +5 X|textextextextext X| X\in -5 X\fi X\set NAP ".na | nap | .noautoparagraph" X\comm NAP XNo Autoparagraph command disables auto-paragraphing. X\set WRT ".wr | .write <string>" X\comm WRT XWrite is a special output command, only to be used to configure printers Xand other output devices with escape sequences. This command outputs the Xassociated string as it is encountered, without going through the normal Xoutput routines of the formatter. Currently, the output string may contain Xcontrol characters specified as "^<char>", decimal numbers within the range Xof 1-255, and other characters. Blanks within the string are skipped. Any Xportion of the string enclosed with double quotes is output as is. To output Xa double quote, two double quotes must be used within the quoted string. XFollowing is a typical string to set a Digital La-100 printer to letter Xquality print mode: X\sp X\nf X\in +5 X| X|.wr ^["[2z" X| X\sp X\fi X\in -5 XIn the control string, "^[" is the ASCII equivalent of the Escape (esc) character. XFollowing mapping table is used to convert characters starting with a caret Xto their binary equivalents: ("|" indicates an alternative) X\nf X\nap X\sp X\in +5 XControl chr Dec. Oct. Hex. X----------- ---- ---- ---- X^a | ^A (soh) 1 01 01 X^b | ^B (stx) 2 02 02 X^c | ^C (etx) 3 03 03 X^d | ^D (eot) 4 04 04 X^e | ^E (enq) 5 05 05 X^f | ^F (ack) 6 06 06 X^g | ^G (bel) 7 07 07 X^h | ^H (bs) 8 10 08 X^i | ^I (ht) 9 11 09 X^j | ^J (nl) 10 12 0A X^k | ^K (vt) 11 13 0B X^l | ^L (np) 12 14 0C X^m | ^M (cr) 13 15 0D X^n | ^N (so) 14 16 0E X^o | ^O (si) 15 17 0F X^p | ^P (dle) 16 20 10 X^q | ^Q (dc1) 17 21 11 X^r | ^R (dc2) 18 22 12 X^s | ^S (dc3) 19 23 13 X^t | ^T (dc4) 20 24 14 X^u | ^U (nak) 21 25 15 X^v | ^V (syn) 22 26 16 X^w | ^W (etb) 23 27 17 X^x | ^X (can) 24 30 18 X^y | ^Y (em) 25 31 19 X^z | ^Z (sub) 26 32 1A X^[ (esc) 27 33 1B X^\ (fs) 28 34 1C X^] (gs) 29 35 1D X^^ (rs) 30 36 1E X^__ (us) 31 37 1F X\sp X\in -5 X\ap X\fi X\cchar . X.in -5 X.bp X.cl X.sect 1 3.7 Defining New Commands (Macros) X In document formatting, it is common to repeat a series of commands at Xseveral places in the document. PROFF allows you to define a new command Xthat will replace these repeated commands. This not only saves typing but Xensures that X.ul Xexactly Xthe same sequence of commands are applied throughout the document. A new Xcommand that you define is formally called a X.ul Xmacro. XTo define a macro, you must use the define macro (.de | .define) and Xend macro (.en) commands. X.in +5 X.cchar \ X\set DEF ".de | .define <macro name>" X\comm DEF XDefine is used to define a <macro name> to which a series of commands to Xbe assigned. This definition line is followed by any number of PROFF Xcommands and/or text which define the action that the macro Xwill subsequently produce. Macros may refer to other macros. X\set ENM ".en" X\comm ENM XEnd macro is the last line in the command definition. You must put in this Xcommand to finish a currently defined macro. ".en" command should not be Xre-defined as a macro. X\in -5 X\sp XThe example below defines macros ".note" and ".endnote", similar to the XRUNOFF commands of the same name. X\in +5 X\nap X\nf X\need 20 X\sp X| X|.define note X|.sp X|.ce X|NOTE X|.sp X|.fi X|.in +5 X|.rm -5 X|.en X| X|.define endnote X|.sp X|.nf X|.in -5 X|.rm +5 X|.en X| X\in -5 X\ap X\fi X A macro is used like any other PROFF command, control character followed Ximmediately by the name of the macro. For example, the above macros Xmay be used as follows: X\in +5 X\nap X\need 9 X\nf X\sp X| X|.note X|textextextextextextextextextext X| . X| . X| . X|.endnote X| X\in -5 X\sp X\fi XThe following note is generated by the same macros described previously. X\cc . X.nap X.note XFlap's Law: Any inanimate object, regardless of its position or configuration, Xmay be expected to perform at any time in a totally unexpected manner for Xreasons that are either entirely obscure or else completely mysterious. X.endnote X.fi X.cc \ X\ap XSpecial symbols may be used within a macro definition. These symbols represent Xthe parameters passed to a macro, delimited by blanks or commas. XThese symbols are _$0 for macro name, _$1 for the first parameter, _$2 for Xthe second parameter and so on, up to _$9 for the ninth parameter. Currently, Xmacro parameters may only contain alphanumerics, no string parameters are Xpossible. The previous macro "note" may now be defined as follows: X\in +5 X\nap X\nf X\need 20 X\sp X| X|.define note X|.sp X|.ce X|_$2 _$3 _$4 _$5 _$6 _$7 _$8 _$9 X|.nr m _$1 X|.sp X|.fi X|.in +_$1 X|.rm -_$1 X|.en X| X|.define endnote X|.sp X|.nf X|.in -_@nm X|.rm +_@nm X|.en X| X\in -5 X\ap X\fi X In this version of the "note" and "endnote" macros, the first parameter (_$1) Xis used to pass the value for indentation and right margin adjustment. XAll the rest of the macro parameters (_$2 - _$9) are used as the title of Xthe note. The indent value passed as the first parameter is also saved in the Xnumber register "m" to communicate it to the "endnote" macro, such that Xwhen the endnote macro is called, both indent and right margin values are Xadjusted back to normal. It is possible and may be more useful to use X".save" and ".restore" commands to accomplish the same task, especially if Xthe macro alters the current formatting context drastically. The ".note" Xand ".endnote" macros may be called as follows: X\in +5 X\nap X\need 9 X\nf X\sp X| X|.note 5 Asimov's Law of Robotics X|textextextextextextextextextext X| . X| . X| . X|.endnote X| X\in -5 X\fi X\ap X In this usage, the indent value will be adjusted by +5, right margin will Xbe adjusted by -5, and the title "Asimov's Law of Robotics" will appear Xcentered above the note. X\cchar . X.bp X.cl X.sect 0 4.0 Executing PROFF X The PROFF program may be invoked with a series of optional parameters and Xfilenames on the command line. The command synopsis is: X XPROFF [+n] [-n] [-v] [-s] [-pon] [-ifile] input [output] X XThe square brackets indicate an optional parameter. Interpretation of the Xparameters is as follows: X.nap X.in +10 X.define opt X.need 5 X.sp X.ti -5 X.bd X$1 X.br X.en X.opt +n XStart the printing of the document at the first page with Xnumber n. X.opt -n XStop printing at the first page numbered higher than n. X.opt -v XVerbose mode. PROFF indicates the source files being included into Xdocument, and produces a summary of the number of textlines read in, the number Xof lines and actual pages generated. A memory usage summary of internal Xstorage for macros, stacks and tables is also displayed. X.opt -s XStop before each page, including the first one to allow paper Xadjustment. A prompt is given just before the first page. For each Xpage thereafter, the terminal bell is rung to indicate that another sheet Xof paper is needed. X.opt -pon XSets the page offset to n. This is equivalent to ".po" command within Xthe document. It is recommended that -pon option be used instead of Xembedding the offset value within the document. X.opt -ifile XIncludes the given file to the formatted document. This is equivalent to Xa ".include file" command within the document. This option may be Xrepeated more than once, -ifile1 -ifile2 etc. X.opt input XSpecifies the input file to be formatted. PROFF does not impose any Xfile extension. The recommended extension is ".PRF". X.opt output XSpecifies the output file for the formatted document. If this is omitted, Xoutput is directed to the user's terminal. X.in -10 X XFollowing are some examples of PROFF command lines: X X.ti +5 XA>PROFF -v proffman.prf X XFormat this document (proffman.prf) in verbose mode, and output the Xformatted document to the Xterminal. X X.ti +5 XA>PROFF +5 -imacros.pma proffman.prf X XFormat this document, include the external file MACROS.PMA, skip the first Xfour pages and output the formatted document to the terminal. X X.ti +5 XA>PROFF -po10 proffman.prf proff.man X XFormat this document, shift the entire document by 10 spaces to right and Xoutput to a file called proff.man. X.bp X.cl X.sect 0 5.0 Tips on using PROFF X.ap X.sect 1 5.1 Care and Feeding of Memory X PROFF uses a dynamic memory allocation scheme for some of its operations. XThese are macro definitions, contents lines, variables and save context Xoperation. XRunning PROFF under microcomputers with limited memory resources (64k or less) Xrequire some care in using these commands: X.list 3 X.item a) XDo not declare macros that are not needed within the document. X.item b) XDo not use comments within macros. Due to delayed evaluation, comments Xwill also be stored as a part of the macro definition. X.item c) XWhere possible, avoid using too much text within macros. It is just as Xeasy to pass the information during the macro call. X.item d) XUse only the shortest form of commands within macros. X.item e) XBe brief in contents line text. X.item f) XUse short variable names as long as it is not so cryptic as to be confusing. X.item g) XAvoid unnecessary blanks within the variable definitions. X.item h) XAvoid too many context saves without a corresponding restore. The restore Xoperation reclaims the memory used for a save. X.nolist X Even if the formatter is used with a system of large memory resources, Xsome of the precautions above are applicable. (Utz's 4th law of Computer XProgramming: Any given program will eventually expand to fill all the Xavailable memory.) Using the -v option under memory-restricted systems Xmay be useful in determining the memory usage. X X.sect 1 5.2 Formatting without fuss X PROFF, using its default settings, may provide reasonably formatted output Xin many situations. XAs an example, examine the document PROFF.TUT. This document does not use XANY formatting commands. All formatting is done with the default settings. X X.sect 1 5.3 Variables within macros X Variable expansions may be performed within the macros. Typically, one Xof the parameters of the macro is assumed to be a variable, which is expanded Xonly after the macro is used. Thus: X.in +5 X.nf X X| X|.define xx X|.ce X|_$_$1 X|.cl _$_$1 X|.en X| X X.in -5 X.fi XThe macro xx assumes the first parameter to be a variable, which is Xcentered on the page, and also entered in the table of contents. XNote the usage of "_$_$1". The lines within a macro are scanned from Xright to left for parameter expansion. Thus, "_$1" is expanded first, Xresulting in "_$<first parameter>". This is later expanded as a variable. X X.bp X.cl X.sect 0 6.0 Example macros X X.nf X.in +5 X.cc \ X.! X.! macros to create a point-form lists. X.! note the use of number registers within X.! the macros. X.!------------ X.define list X.nr a _$1 X.in _$1 X.en X.!------------ X.define item X.sp X.ti -_@na X_$1 X.en X.!------------ X.define nolist X.in -_@na X.sp X.en X.!------------ X X\in -5 X\fi XThe "list" macro is used to generate point-form lists. The first parameter Xis an indent value, size of point-str + 1. A typical usage may be as Xfollows: X\need 16 X\in +5 X X\nf X| X|Project work involves: X|.sp X|.list 3 { size-of-point-str + 1 } X|.item a) { "a)" is the point-str } X|choosing a topic X|.item b) X|defining the topic X|.item c) X|research X|.item d) X|organizing the notes X|{etc.} X|.nolist { readjusts the indent } X| X\in -5 X XThe above usage will produce the following: X\need 12 X\in +5 X X| X|Project work involves: X| X|a) choosing a topic X| X|b) defining the topic X| X|c) research X| X|d) organizing the notes X| X X\in -5 X\fi XThe point-form recommendations under section 5.1 (Care and Feeding of XMemory) were generated with the same set of macros described above. X\cc . X.bp X.cl X.sect 0 7.0 Acknowledgements X This document was edited by Terry Lim and Steven Tress. XThe format of the document is largely based on The Freshwater Institute XRUNOFF User's Guide. The Quotes for the various formatting examples are Xfrom THE QUOTABLE NOTHING BOOK and from 1001 LOGICAL LAWS, ACCURATE XAXIOMS, PROFOUND PRINCIPLES, TRUSTY TRUISMS, HOMEY HOMILIES, COLORFUL XCOROLLARIES, QUOTABLE QUOTES, AND RAMBUNCTIOUS RUMINATIONS FOR ALL XWALKS OF LIFE, by Peers, Bennet and Booth, Fawcett Columbine Books, XNew York. X.bp X.cl X.sect 0 Appendix A X.he /1.0/Appendix A/#/ X.cc \ X\nf X\nap X\ce XSummary of Commands X X---------------------------------------------------------- X$FILL X default: initial: yes break: yes X begin filling output lines X---------------------------------------------------------- X$NOFILL X default: initial: no break: yes X stop filling X---------------------------------------------------------- X$JUST X default: initial: yes break: yes X begin justifying filled lines X---------------------------------------------------------- X$NOJUST X default: initial: no break: yes X stop justifying X---------------------------------------------------------- X$BREAK X default: initial: break: yes X cause a break and output current line X---------------------------------------------------------- X$INDENT X default: 0 inital: 0 break: yes X set left margin to column n+1 X---------------------------------------------------------- X$TINDENT X default: 0 initial: break: yes X temporarily indent next output n spaces X---------------------------------------------------------- X$SPACETO X default: 0 initial: break: yes X space to line +n from top X space to line -n from bottom X---------------------------------------------------------- X$SPACE X default: 1 initial: break: yes X space n lines except at top of page X---------------------------------------------------------- X$CENTER X default: 1 initial break: yes X center next n lines X center until turned off X---------------------------------------------------------- X$UNDLINE X default: 1 initial break: no X underline next n lines X underline until turned off X---------------------------------------------------------- X\bp X---------------------------------------------------------- X$CUNDLINE X default: words initial: words break: no X set mode for underline - words or all X---------------------------------------------------------- X$BOLD X default: 1 initial: break: no X boldface (overstrike) next n lines X boldface until turned off X---------------------------------------------------------- X$DBO X default: initial: no break: no X disable bolding X---------------------------------------------------------- X$EBO X default: initial: yes break: no X enable bolding X---------------------------------------------------------- X$LS X default: 1 initial: 1 break: no X set line spacing to n X---------------------------------------------------------- X$BP X default: +1 initial: 1 break: yes X begin a new page and number it n X---------------------------------------------------------- X$PN X default: initial: arabic break: no X set page numbering to arabic or roman X---------------------------------------------------------- X$NPA X default: initial: no break: yes X disable paging X---------------------------------------------------------- X$PA X default: initial: yes break: yes X enable paging X---------------------------------------------------------- X$NE X default: 0 initial: break: yes/no X need n lines. Break and generate a new page X if not available X---------------------------------------------------------- X$HE X default: null initial: null break: no X set header to text (/left/center/right/) X---------------------------------------------------------- X$FO X default: null initial: null break: no X set footer to text (/lef/center/right/) X---------------------------------------------------------- X\bp X---------------------------------------------------------- X$OHE X default: null initial: null break: no X set header on odd pages to text X---------------------------------------------------------- X$EHE X default: null initial: null break: no X set header on even pages to text X---------------------------------------------------------- X$OFO X default: null initial: null break: no X set footer on odd pages to text X---------------------------------------------------------- X$EFO X default: null initial: null break: no X set footer on odd pages to text X---------------------------------------------------------- X$PO X default: 0 initial: 0 break: yes X set page offset to n spaces X---------------------------------------------------------- X$RM X default: 65 initial: 65 break: no X set right margin to column n X---------------------------------------------------------- X$PL X default: 66 initial: 66 break: no X set page length to n lines X---------------------------------------------------------- X$M1 X default: 3 initial: 3 break: no X lines between top of page and header X---------------------------------------------------------- X$M2 X default: 2 initial: 2 break: no X lines between header and text X---------------------------------------------------------- X$M3 X default: 2 initial: 2 break: no X lines between text and footer X---------------------------------------------------------- X$M4 X default: 3 initial: 3 break: no X lines between footer and bottom X---------------------------------------------------------- X$CL X default: initial: break: yes X enter text into table of contents at level X n X---------------------------------------------------------- X\bp X---------------------------------------------------------- X$PC X default: 3 initial: 3 break: yes X print table of contents, indent each level X n spaces X---------------------------------------------------------- X$VSET X default: initial: break: no X set variable to text X---------------------------------------------------------- X$VGET X default: initial: break: no X set variable interactively, using text X as prompt X---------------------------------------------------------- X$VRG X default: 0 initial: 0 break: no X set number register (a-z) to n X---------------------------------------------------------- X$CCHAR X default: "." initial: "." break: no X set command control character to char X---------------------------------------------------------- X$ECHAR X default: "__" initial: "__" break: no X set universal escape character to char X---------------------------------------------------------- X$SOU X default: initial: input break: no X switch input to file X---------------------------------------------------------- X$SAVE X default: initial: break: yes X save the current formatter context on X context stack X---------------------------------------------------------- X$RST X default: initial: break: yes X restore the formatter context from context X stack X---------------------------------------------------------- X$LEX X default: initial: break: no X rename a command X---------------------------------------------------------- X$APR X default: initial: no break: no X enable auto-paragraphing X---------------------------------------------------------- X\bp X---------------------------------------------------------- X$NAP X default: initial: yes break: no X disable auto-paragraphing X---------------------------------------------------------- X$WRT X default: initial: break: no X write a special string to output. line X counter does not change X---------------------------------------------------------- X$DEF X default: initial: break: no X define a macro command - ends at ".en" X---------------------------------------------------------- X$ENM X default: initial: break: no X end the macro definition X---------------------------------------------------------- X\cc . X.bp 1 X.pn roman X.he //// X.fo //- # -// X.ce on XTable Of Contents X XPROFF 1.0 X.ce off X.pc SHAR_EOF if test 46207 -ne "`wc -c 'proffman.prf'`" then echo shar: error transmitting "'proffman.prf'" '(should have been 46207 characters)' fi # End of shell archive exit 0 -- Usenet: [decvax|allegra|linus|ihnp4]!utzoo!yetti!oz Bitnet: oz@[yusol|yuyetti] In the beginning, there was Word all right, except it wasn't fixed number of bits.