koreth@panarthea.ebay.sun.com (Steven Grimm) (11/15/89)
Submitted-by: rosenkra@hall.cray.com (Bill Rosenkranz) Posting-number: Volume 3, Issue 8 Archive-name: nroff/part01 this is source for a partially complete nroff(1) for atariST TOS. it should port to minix-ST (it runs on 4BSD). part01/03 -bill rosenkra@hall.cray.com rosenkra@boston.cray.com ---------cut here-------------------cut here-----------------cut here------- #!/bin/sh # This is a shell archive. Remove anything before this line, # then unpack it by saving it in a file and typing "sh file". # # Wrapped by hall!rosenkra on Sun Nov 12 16:35:26 CST 1989 # Contents: README MANIFEST Makefile Makefile.bsd nroff.1 tmac.an nroff.h # version.h echo x - README sed 's/^@//' > "README" <<'@//E*O*F README//' nroff (TOS) v0.90 ALPHA 11/12/89 wjr ------------------------------------ This is a preliminary release of a version of nroff for atariST. It was written under TOS, USG, and 4BSD but should port easily to Minix ST as well. I doubt it will be easy to port to Minix PC unless the static arrays are changed to be malloc'd. Much of this works. The things that don't are all the hard things (natch): diversions, traps, conditionals, etc. Font switching, underlining, etc. are limited to reverse video on the screen, though stdout will contain underlines as "_^H" for printers. There is a crude man package included (tmac.an) which is not right but needs diversions to become right. It should handle most man tasks, though, except .IP and similar commands. For porting info, look in nroff.h and the makefile. I have to fix my ctime(3) so as implemented, it is slightly incorrect. The standard dri/alcyon libraries are limited so I have my own extensions. Only ctime(3) and getenv(3) are used, as I recall. If you use dLibs or MWC you should be in good shape (SOMEDAY I'll switch to dLibs). Minix should also have no problems. As it stands, I have a >300k stack set up (plenty of memory on a Mega4 *8^) and this should be fine for a 1040ST. If it is not, and you don't/can't recompile, consider dumping some of your DA's. You could also binary edit the executable, looking for a long in the bss segment which defines the stack size for the startup (I use a hacked up gemstart.s). Look for 0x00055555L long near the end (NB: 0x55 is "U"). I think is is at offset $a9e0 in the file. If you do hack away, I would appreciate you sending me the changes so I can keep this centralized. Eventually, this may be good enough for FSF (GNUroff?). -Bill Rosenkranz net: rosenkra@hall.cray.com, rosenkra@boston.cray.com CIS: 71460,17 GENIE: W.ROSENKRANZ @//E*O*F README// chmod u=rw,g=r,o=r README echo x - MANIFEST sed 's/^@//' > "MANIFEST" <<'@//E*O*F MANIFEST//' -rw-r--r-- 1 rosenkra 906 Nov 12 15:40 MANIFEST -rw-r--r-- 1 rosenkra 1195 Nov 12 15:40 Makefile -rw-r--r-- 1 rosenkra 1268 Nov 12 16:28 Makefile.bsd -rw-r--r-- 1 rosenkra 1841 Nov 12 15:40 README -rw-r--r-- 1 rosenkra 16799 Nov 12 15:40 command.c -rw-r--r-- 1 rosenkra 17014 Nov 12 15:53 escape.c -rw-r--r-- 1 rosenkra 3444 Nov 12 15:40 io.c -rw-r--r-- 1 rosenkra 10846 Nov 12 15:40 low.c -rw-r--r-- 1 rosenkra 9095 Nov 12 15:40 macros.c -rw-r--r-- 1 rosenkra 15924 Nov 12 16:16 main.c -rw-r--r-- 1 rosenkra 20809 Nov 12 16:05 nroff.1 -rw-r--r-- 1 rosenkra 13272 Nov 12 15:40 nroff.h -rw-r--r-- 1 rosenkra 4920 Nov 12 15:40 strings.c -rw-r--r-- 1 rosenkra 11452 Nov 12 15:40 text.c -rw-r--r-- 1 rosenkra 547 Nov 12 15:40 tmac.an -rw-r--r-- 1 rosenkra 292 Nov 12 15:40 version.h @//E*O*F MANIFEST// chmod u=rw,g=r,o=r MANIFEST echo x - Makefile sed 's/^@//' > "Makefile" <<'@//E*O*F Makefile//' # makefile for nroff (TOS) # CFLAGS = -new -Dalcyon # LDFLAGS for no symbols (-s) and to specify _STKSIZ in crt0.o (-stksiz) LDFLAGS = -new -s -stksiz SRCS = main.c command.c text.c io.c macros.c strings.c escape.c low.c OBJS = main.o command.o text.o io.o macros.o strings.o escape.o low.o # LIBS is to get my own getenv, ctime, etc. LIBS = -llibc TARGET = nroff.ttp MANPAGE = nroff.1 MAN_MACRO = tmac.an #MS_MACRO = tmac.s #ME_MACRO = tmac.e # set these as per your system (for install) TMACDIR = c:\lib\tmac BINDIR = c:\bin MANDIR = c:\man\man1 # main target # $(TARGET): $(OBJS) $(CC) $(LDFLAGS) -o $(TARGET) $(OBJS) $(LIBS) # install target # install: $(TARGET) cp $(TARGET) $(BINDIR)\$(TARGET) cp $(MANPAGE) $(MANDIR)\$(MANPAGE) cp $(MAN_MACRO) $(TMACDIR)\$(MAN_MACRO) # cp $(MS_MACRO) $(TMACDIR)\$(MS_MACRO) # cp $(ME_MACRO) $(TMACDIR)\$(ME_MACRO) clean: rm $(OBJS) clobber: rm $(OBJS) rm $(TARGET) # dependencies # nroff.h: version.h touch nroff.h main.o: main.c nroff.h command.o: command.c nroff.h text.o: text.c nroff.h io.o: io.c nroff.h macros.o: macros.c nroff.h strings.o: strings.c nroff.h escape.o: escape.c nroff.h low.o: low.c nroff.h @//E*O*F Makefile// chmod u=rw,g=r,o=r Makefile echo x - Makefile.bsd sed 's/^@//' > "Makefile.bsd" <<'@//E*O*F Makefile.bsd//' # makefile for nroff (BSD) # CFLAGS = -O LDFLAGS = SRCS = main.c command.c text.c io.c macros.c strings.c escape.c low.c OBJS = main.o command.o text.o io.o macros.o strings.o escape.o low.o LIBS = TARGET = nroff MANPAGE = nroff.1 MAN_MACRO = tmac.an #MS_MACRO = tmac.s #ME_MACRO = tmac.e # set these as per your system (for install) TMACDIR = /usr/local/lib/tmac BINDIR = /usr/local/bin MANDIR = /usr/local/man/man1 # main target # $(TARGET): $(OBJS) $(CC) $(LDFLAGS) -o $(TARGET) $(OBJS) $(LIBS) # install target # install: $(TARGET) cp $(TARGET) $(BINDIR)/$(TARGET) cp $(MANPAGE) $(MANDIR)/$(MANPAGE) cp $(MAN_MACRO) $(TMACDIR)/$(MAN_MACRO) # cp $(MS_MACRO) $(TMACDIR)/$(MS_MACRO) # cp $(ME_MACRO) $(TMACDIR)/$(ME_MACRO) clean: /bin/rm -f $(OBJS) clobber: /bin/rm -f $(OBJS) /bin/rm -f $(TARGET) shar: shar README MANIFEST Makefile Makefile.bsd nroff.1 tmac.an \ *.h >part01 shar main.c command.c text.c io.c >part02 shar escape.c low.c macros.c strings.c >part03 # dependencies # nroff.h: version.h touch nroff.h main.o: main.c nroff.h command.o: command.c nroff.h text.o: text.c nroff.h io.o: io.c nroff.h macros.o: macros.c nroff.h strings.o: strings.c nroff.h escape.o: escape.c nroff.h low.o: low.c nroff.h @//E*O*F Makefile.bsd// chmod u=rw,g=r,o=r Makefile.bsd echo x - nroff.1 sed 's/^@//' > "nroff.1" <<'@//E*O*F nroff.1//' @.\" a macro to do a dangling tag starting with a "." @.de XT @.br @.sp @.ne 3 @.ti -6 \&\fI$0\fR $1 $2 $3 $4 $5 $6 $7 $8 $9 @.br @.. @.TH NROFF 1 "Commands Manual" "Version 1.0" "Sept 1989" @.SH NAME nroff - text processor @.SH SYNOPSIS \fInroff\fR [\fIoptions\fR] \fIfile\fR [\fI...\fR] @.SH DESCRIPTION \fINroff\fR is a text processor and formatter based on the design provided in "Software Tools" by Kernighan and Plauger. It has been modified to closely resemble the Unix(tm) nroff command. The text and commands found in the \fIfile(s)\fR are processed to generate formatted text. Note that one (and only one) of the files can be "-" which reads input from stdin at that point. The output always goes to stdout which can be redirected by the shell. @.\" Using the command line option \fI-l\fR will cause the output to @.\" be sent to the printer instead. The \fI-o\fR option lets you redirect error output to the specified file rather than stderr. Debugging information always goes to the file "nroff.dbg" and is generally used only for program development. @.SH OPTIONS The following command line options are available: @.nf \fI-a\fR Changes font (not implemented). \fI-b\fR Allows backspaces to appear in the output text when underlining or overstriking. This has the same effect as the \fI\.bs\fR command with a non-zero argument. \fI-d\fR Set debug mode. \fI-h\fR Hold screen before desktop (TOS only). \fI-l\fR Send output to printer (not implemented). \fI-m<name>\fR Process macro file tmac.<name>. Thus -man would cause the file tmac.an to be loaded. Note that files processed in this way should contain only macro definitions, no immediate output should be generated from this file (see ENVIRONMENT). \fI-o\fR \fIfile\fR Set error log file (default is stderr). \fI-po<n>\fR Shift output right n spaces (like \fI.po\fR). \fI-pn<n>\fR Initial page number (like \fI.pn\fR). \fI-v\fR Prints the version information to stdout. \fI+<n>\fR Causes output to start with page n. \fI-<n>\fR Causes output to stop after page n. \fI-\fR Input from stdin. @.fi @.SH ENVIRONMENT Nroff recognizes the following environment variables from the shell: @.br @.in +6 @.XT TMACDIR An alternate directory to find the files tmac.* ("." for example). The default is c:\\lib\\tmac under TOS. @.br @.in -6 @.SH FILES @.nf c:\\lib\\tmac\\tmac.* predefined macros (see ENVIRONMENT) nroff.dbg debugging output stderr default error output stream stdout output stream @.fi @.SH COMMANDS Commands typically are distinguished by a period in column one of the input followed by a two character abbreviation for the command funtion. The abbreviation may then be followed by an optional numeric or character argument. The numeric argument may be an absolute value such as setting the right margin to a particular column, or the argument may be preceded by a plus sign or a minus sign to indicate that the parameter should be modified relative to a previous setting. The following commands are recognized (those marked "extension" are requests added to the basic set): @.br @.in +6 @.XT .bo (extension) causes the following lines of text to appear in boldface. The optional argument specifies the number of lines to be typed in boldface. Boldface and underlining are mutually exclusive features. The appearance of a boldface command will cause any underlining to cease. @.XT .bp (extension) causes succeeding text to appear at the top of a new page. The optional argument specifies the page number for the new page. The initial value is one and the default value is one more than the previous page number. @.XT .br causes succeeding text to start on a new line at the current left margin. There is no numeric argument for this command. @.XT .bs (extension) enables or disables the appearance of backspaces in the output text. Underlining and boldface options are implemented by inserting character - backspace - character combinations into the output buffer. This is fine for devices which properly recognize the backspace character. Some printers, however, do not recognize backspaces, so the option is provided to overprint one line buffer with another. The first line buffer is terminated with just a carriage return rather than the carriage return - linefeed combination. A zero argument or no argument to the backspace command removes backspaces from the output. A non-zero argument leaves them in the output. The default is to remove backspaces. @.XT .cc changes the \fInroff\fR command character to that specified by the character argument. If no argument is provided, the default is a period. @.XT .ce causes the next line of text to appear centered on the output. The optional argument specifies if more than one line is to be centered. @.XT .c2 changes the \fInroff\fR no break character to that specified by the character argument. If no argument is provided, the default is a single quote. @.XT .de causes all text and commands following to be used to define a macro. The definition is terminated by a \fI\.en\fR command or the default \fI\.\.\fR terminator. The first two characters of the argument following the \fI\.de\fR command become the name of the new command. It should be noted that upper and lower case arguments are considered different. Thus, the commands \fI\.PP\fR and \fI\.pp\fR could define two different macros. Care should be exercised since existing commands may be redefined. @.PP A macro may contain up to ten arguments. In the macro definition, the placement of arguments is designated by the two character sequences, $0, $1, ... $9. When the macro is invoked, each argument of the macro command line is substituted for its corresponding designator in the expansion. The first argument of the macro command is substituted for the $0 in the expansion, the second argument for the $1, and so forth. Arguments are typically strings which do not contain blanks or tabs. If an argument is to contain blanks, then it should be surrounded by either single or double quotes. @.XT .cu causes the next line(s) of text to be continuously underlined. Unlike the underline command (see \fI\.ul\fR) which underlines only alphanumerics, continuous underlining underlines all printable characters. The optional argument specifies the number of lines of text to underlined. Any normal underlining or boldface commands currently in effect will be terminated. @.XT .ec changes the \fInroff\fR escape character to that specified by the character argument. If no argument is provided, the default is a backslash. @.XT .ef (extension) specifies the text for the footer on even numbered pages. The format is the same as for the footer command (see \fI\.fo\fR). @.XT .eh (extension) specifies the text for the header on even numbered pages. The format is the same as for the footer command (see \fI\.fo\fR). @.XT .en (extension) designates the end of a macro definition. @.XT .fi causes the input text to be rearranged or filled to obtain the maximum word count possible between the previously set left and right margins. No argument is expected. @.XT .fl causes the output buffer to be flushed immediately. @.XT .fo (extension) specifies text to be used for a footer. The footer text contains three strings seperated by a delimiter character. The first non-blank character following the command is designated as the delimiter. The first text string is left justified to the current indentation value (specified by \fI\.in\fR). The second string is centered between the current indentation value and the current right margin value (specified by \fI\.rm\fR). The third string is right justified to the current right margin value. The absence of footer text will result in the footer being printed as one blank line. The presence of the page number character (set by \fI\.pc\fR) in the footer text results in the current page number being inserted at that position. Multiple occurrances of the page number character are allowed. @.XT .ft changes the current font. The choices are R (Times Roman), I (Times Italic), B (Times Bold), S (math special), and P used to request the previous font. P resets the next previous font to be the one just changed, amounting to a swap. @.XT .he (extension) specifies text to be used for a header. The format is the same as for the footer (see \fI\.fo\fR). @.XT .in indents the left margin to the column value specified by the argument. The default left margin is set to zero. @.XT .ju (extension) causes blanks to be inserted between words in a line of output in order to align or justify the right margin. The default is to justify. @.XT .ll sets the current line length. The default is eighty. @.XT .ls sets the line spacing to the value specified by the argument. The default is for single spacing. @.XT .m1 (extension) specifies the number of lines in the header margin. This is the space from the physical top of page to and including the header text. A value of zero causes the header to not be printed. A value of one causes the header to appear at the physical top of page. Larger argument values cause the appropriate number of blank lines to appear before the header is printed. @.XT .m2 (extension) specifies the number of blank lines to be printed between the header line and the first line of the processed text. @.XT .m3 (extension) specifies the number of blank lines to be printed between the last line of processed text and the footer line. @.XT .m4 (extension) specifies the number of lines in the footer margin. This command affects the footer the same way the \fI\.m1\fR command affects the header. @.XT .ne specifies a number of lines which should not be broken across a page boundary. If the number of lines remaining on a page is less than the value needed, then a new output page is started. @.XT .nf specifies that succeeding text should be printed without rearrangement, or with no fill. No argument is expected. @.XT .nj (extension) specifies that no attempt should be made to align or justify the right margin. No argument is expected. @.XT .nr causes the value of a number register to be set or modified. A total of twenty-six number registers are available designated \\na through \\nz (either upper or lower case is allowed). When the sequence \\nc is imbedded in the text, the current value of number register c replaces the sequence, thus, such things as paragraph numbering can be accomplished with relative ease. @.XT .of (extension) specifies the text for the footer on odd numbered pages. The format is the same as the footer command (see \fI\.fo\fR). @.XT .oh (extension) specifies the text for the header on odd numbered pages. The format is the same as the footer command (see \fI\.fo\fR). @.XT .pc specifies the page number character to be used in headers and footers. The occurrance of this character in the header or footer text results in the current page number being printed. The default for this character is the percent sign (%). @.XT .pl specifies the page length or the number of lines per output page. The default is sixty-six. @.XT .po specifies a page offset value. This allows the formatted text to be shifted to the right by the number of spaces specified. This feature may also be invoked by a switch on the command line. @.XT .pn changes the page number of the current page and all subsequent pages to its argument. If no argument is given, the command is ignored. @.XT .so causes input to be retrieved from the file specified by the command's character string argument. The contents of the new file are inserted into the output stream until an EOF is detected. Processing of the original file is then resumed. Command nesting is allowed. @.XT .sp specifies a number of blank lines to be output before printing the next line of text. @.XT .ti temporarily alters the indentation or left margin value for a single succeeding input line. @.XT .tl specifies text to be used for a page title. The format is the same as for the header (see \fI\.he\fR). @.XT .ul causes the next line(s) of text to be underlined. Unlike the \fI\.cu\fR command, this command causes only alphanumerics to be underlined, skipping punctuation and white space. Underline and boldface are mutually exclusive. @.br @.in -6 @.SH ESCAPE SEQUENCES Escape sequences are used to access special characters (such as Greek letters) which may be outside the normal printable ASCII character set. The are also used to toggle certain actions such as font selection. @.PP @.ne 5 The escape sequences include: @.sp @.eo @.nf \\ backslash character \" beginning of comment \(xx special character named xx \fc font change (c = R,I,B,S,P) \nx interpolate number register x @.fi @.PP @.ne 5 The special characters include: @.sp @.nf \(co copyrite \(rg registered \(tm trademark \(12 1/2 \(14 1/4 \(p2 exponent 2 \(p3 exponent 3 \(pn exponent n \(aa acute \(ga grave \(de degree \(dg dagger \(ct cent \(bu bullet \(pp paragraph \(^g ring bell \(ua up arrow \(da dn arrow \(-> rt arrow \(<- lf arrow \(di divide \(sr sq root \(== == \(>= >= \(<= <= \(+- +- \(~= ~= \(ap approx \(no not \(mo memeber \(ca intersect \(cu union \(*a alpha \(*b beta \(*g gamma \(*d delta \(*s sigma \(*p pi \(*m mu @.fi @.ec @.PP @.SH REQUEST SUMMARY The following table summarizes the nroff requests: @.nf @.ne 8 @.cc + Request Form Initial Default Notes Explanation -------------- ------- ------- ------- ---------------------- Font and Character Size Control @.ps \(+-N 10pt prev E point size @.ss N 12/36em ignored E space-char size @.cs F N M off - P constant space mode @.bd F N off - P embolden font F @.bd S F N off - P embolden special font @.ft F Roman prev E change to font F @.fp N F R,I,B,S ignored - font F in position N +ne 4 Page Control @.pl \(+-N 11in 11in v page length @.bp \(+-N N=1 - B,v eject page @.pn \(+-N N=1 ignored - next page number N @.po \(+-N 0 prev v page offset @.ne N - N=1V D,v need N vertical space @.mk R none intern D mark current V in R @.rt \(+-N none intern D,v return (up) to mark +ne 4 Text Filling, Adjusting, and Centering @.br - - B break @.fi fill - B,E fill mode @.nf fill - B,E no fill or adjust @.ad c adj,both adjust E adjust output, mode c @.na adjust - E no adjust @.ce N off N=1 B,E center N lines +ne 4 Vertical Spacing @.vs N 1/6in prev E,p vert. baseline space @.ls N N=1 prev E output N-1 Vs @.sp N - N=1V B,v space vertical @.sv N - N=1V v save vertical dist N @.os - - D output saved vert dist @.ns space - D no-space mode on @.rs - - D restore spacing +ne 4 Line Length and Indenting @.ll \(+-N 6.5i prev E,m line length @.in \(+-N N=0 prev B,E,m indent @.ti \(+-N - ignored B,E,m temporary indent +ne 4 Macros, Strings, Diversions, and Position Traps @.de xx yy - .yy=.. - define macro xx @.am xx yy - .yy=.. - append to macro xx @.ds xx str - ignored - define string xx @.as xx str - ignored - append to string xx @.rm xx - ignored - remove macro, string @.rn xx yy - ignored - rename macro, string @.di xx - end D divert output to xx @.da xx - end D divert and append to xx @.wh N xx - - v set location trap @.ch xx N - - v change trap location @.dt N xx - off D,v set diversion trap @.it N xx - off E set line count trap @.em xx none none - end macro is xx +ne 4 Number Registers @.nr R \(+-N M - u define and set num reg @.af R c arabic - - assign format to reg @.rr R - - - remove register +ne 4 Tabs, Leaders, and Fields @.ta Nt ... 0.8 none E,m tab set @.tc c none none E tab repeat char @.lc c . none E leader repeat char @.fc a b off off - set field delim, pad +ne 4 I/O Conventions and Character Translation @.ec c \ \ - set escape char @.eo on - - turn off escape mech @.lg N - on - ligature mode if N>0 @.ul N off N=1 E underline N lines @.cu N off N=1 E cont. underline @.uf F Italic Italic - underline font @.cc c . . E set control char @.c2 c ' ' E set nobreak control char @.tr abcd... none - O translate a-b, etc +ne 4 Hyphenation @.nh hyphen - E no hyphenation @.hy N hyphen hyphen E hyphenate, N=mode @.hc c \% \% E hyphanation char @.hw word1 ... none ignored - exception words +ne 4 Three-part Titles @.tl 'l'c'r' - - three-part title @.pc c % off - page number char @.lt \(+-N 6.5in prev E,m length of title +ne 4 Output Line Numbering @.nm \(+-N M S I off E number mode @.nn N - N=1 E do not number N lines +ne 4 Conditional Acceptance of Input @.if c ... - - if condition c true @.if !c ... - - if condition c false @.if N ... - u if expression N>0 @.if !N ... - u if expression N<=0 @.if 's1's2' ... - - if strings identical @.if !'s1's2' ... - - if strings differ @.ie c ... - u if portion of if/else @.ie !c ... - u if portion of if/else @.ie N ... - u if portion of if/else @.ie !N ... - u if portion of if/else @.ie 's1's2' ... - u if portion of if/else @.ie !'s1's2' ... - u if portion of if/else @.el ... - u else portion of if/else +ne 4 Environment Switching @.ev N N=0 prev - environment switched +ne 4 Insertions From the Standard Input @.rd prompt - BEL - read insertion @.ex - - - exit nroff +ne 4 Input/Output File Switching @.so filename - - switch source file @.nx filename EOF - next file @.pi program - - pipe output to program +ne 4 Miscellaneous @.mc c N - off E,m set margin char @.tm string - newline - terminal message @.ig yy - .yy=.. - ignore till call to yy @.pm t - all - print macro names @.fl - - B flush output buffer +ne 4 Notes B causes a break D mode or parameters associated with current diversion level E relevant parameters are a part of the current environment O must stay in effect until logical output P mode must be still or again in effect at time of physical output v,p,m,u default scale indicators +cc @.fi @.SH AUTHOR @.nf Adapted for atariST/TOS by Bill Rosenkranz 11/89 net: rosenkra@hall.cray.com CIS: 71460,17 GENIE: W.ROSENKRANZ Original author: Stephen L. Browning 5723 North Parker Avenue Indianapolis, Indiana 46220 History: - Originally written in BDS C - Adapted for standard C by W. N. Paul - Heavily hacked up to conform to "real" nroff by Bill Rosenkranz @.fi @//E*O*F nroff.1// chmod u=rw,g=r,o=r nroff.1 echo x - tmac.an sed 's/^@//' > "tmac.an" <<'@//E*O*F tmac.an//' @.\" -man package for nro @.\" not quite unix, but working... @.\" @.de TH \" main page heading @.m1 1 @.in 0 @.lt 65 @.ll 65 @.tl |$0 ($1)|$2|$0 ($1)| @.fo |$3|$4|%| @.in 5 @.ll 60 @.. @.de pp \" start a new indented paragraph @.sp 1 @.ti +5 @.. @.de PP \" start a new unindented paragraph @.sp 1 @.. @.de SH \" section heading @.sp 1 @.ne 3 @.ti -5 @.bo $0 $1 $2 $3 $4 $5 $6 $7 $8 $9 @.br @.. @.de SS \" subsection heading, same indent @.sp 1 @.ne 3 @.bo $0 $1 $2 $3 $4 $5 $6 $7 $8 $9 @.br @.sp 1 @.. @.de I \" italic text \fB$0 $1 $2 $3 $4 $5 $6 $7 $8 $9\fR @.. @//E*O*F tmac.an// chmod u=rw,g=r,o=r tmac.an echo x - nroff.h sed 's/^@//' > "nroff.h" <<'@//E*O*F nroff.h//' #ifndef NRO_H #define NRO_H #ifdef alcyon #define ALCYON /* for gemdos version, alcyon C */ /* otherwise minix/unix */ #endif /* * nroff.h - stuff for nroff * * adapted for atariST/TOS by Bill Rosenkranz 10/89 * net: rosenkra@hall.cray.com * CIS: 71460,17 * GENIE: W.ROSENKRANZ * * things to look for here: * 1) TMAC definition for default macro package lib * 2) configuration sizes (see _STKSIZ below if alcyon/dri) * 3) libc should have getenv() and ctime() * 4) look in version.h for *printer file name (included below) * * original author: * * Stephen L. Browning * 5723 North Parker Avenue * Indianapolis, Indiana 46220 * * history: * * - Originally written in BDS C; * - Adapted for standard C by W. N. Paul * - Heavily hacked up to conform to "real" nroff by Bill Rosenkranz */ #include <ctype.h> /* * default prefix of macro files. files will be of the form "tmac.an" * (for -man), "tmac.s" (for -ms), "tmac.e" (for -me), etc. first * checks environment for TMACDIR which would be path (e.g. "c:\lib\tmac" * or ".", no trailing slash char!). */ #ifdef ALCYON #define TMACFULL "c:\\lib\\tmac\\tmac." #define TMACPRE "\\tmac." #else /*unix/minix???*/ #define TMACFULL "/usr/lib/tmac/tmac." #define TMACPRE "/tmac." #endif /* * command codes... */ #define MACRO 0 /* macro definition */ #define BP 1 /* begin page */ #define BR 2 /* break */ #define CE 3 /* center */ #define FI 4 /* fill */ #define FO 5 /* footer */ #define HE 6 /* header */ #define IN 7 /* indent */ #define LS 8 /* line spacing */ #define NF 9 /* no fill */ #define PL 10 /* page length */ #define RM 11 /* remove macro */ #define SP 12 /* line space */ #define TI 13 /* temp indent */ #define UL 14 /* underline */ #define JU 15 /* justify */ #define NJ 16 /* no justify */ #define M1 17 /* top margin */ #define M2 18 /* second top margin */ #define M3 19 /* first bottom margin */ #define M4 20 /* bottom-most margin */ #define BS 21 /* allow/disallow '\b' in output */ #define NE 22 /* need n lines */ #define PC 23 /* page number character (%) */ #define CC 24 /* control character (.) */ #define PO 25 /* page offset */ #define BO 26 /* bold face */ #define EH 27 /* header for even numbered pages */ #define OH 28 /* header for odd numbered pages */ #define EF 29 /* footer for even numbered pages */ #define OF 30 /* footer for odd numbered pages */ #define SO 31 /* source file */ #define CU 32 /* continuous underline */ #define DE 33 /* define macro */ #define EN 34 /* end macro definition */ #define NR 35 /* set number register */ #define EC 36 /* escape character (\) */ #define FT 37 /* font change (R,B,I,S,P) */ #define EO 38 /* turn escape parsing off */ #define LL 39 /* line length (same as RM) */ #define FL 40 /* flush output NOW */ #define PN 41 /* page number for next page */ #define RR 42 /* remove register */ #define C2 43 /* nobreak char */ /* these 3 not done yet... */ # define TR 44 /* translate character */ # define LT 45 /* length of title */ # define FC 46 /* field delimeter */ #define TL 47 /* like HE */ #define AF 48 /* assign format to nr */ #define AD 49 /* adjust line */ #define NA 50 /* no adjust */ #define DS 51 /* define string */ #define PM 52 /* print macro names */ #define IF 53 /* if */ #define IE 54 /* if/else */ #define EL 55 /* else */ /* these aren't done yet either... */ # define PS 56 /* point size */ # define SS 57 /* space char size */ # define CS 58 /* constant char space */ # define BD 59 /* bold font */ # define FP 60 /* font position */ # define MK 61 /* mark vertical place */ # define RT 62 /* return to marked vert place */ # define VS 63 /* vertical baseline spacing */ # define SV 64 /* save vertical distance */ # define OS 65 /* output saved vertical distance */ # define NS 66 /* no-space mode */ # define RS 67 /* restore spacing mode */ # define AM 68 /* append to macro */ # define AS 69 /* append to string */ # define RN 70 /* rename */ # define DI 71 /* divert to macro */ # define DA 72 /* divert/append to macro */ # define WH 73 /* set location trap */ # define CH 74 /* change trap location */ # define DT 75 /* set diversion trap */ # define IT 76 /* set input line trap */ # define EM 77 /* end macro */ # define TA 78 /* tab settings */ # define TC 79 /* tab repetition char */ # define LC 80 /* leader repetition char */ # define LG 81 /* ligature mode */ # define UF 82 /* underline font */ # define NH 83 /* no hyphenation */ # define HY 84 /* hyphenate */ # define HC 85 /* hyphenation indication char */ # define HW 86 /* hyphenation exception words */ # define NM 87 /* number mode */ # define NN 88 /* no number next lines */ # define EV 89 /* environment switch */ # define RD 90 /* read insertion */ # define EX 91 /* exit */ # define NX 92 /* next file */ # define PI 93 /* pipe to program */ # define MC 94 /* set margin char */ # define TM 95 /* print to terminal */ # define IG 96 /* ignore */ #define COMMENT 1000 /* comment (.\") */ #define UNKNOWN -1 /* * MAXLINE is set to a value slightly larger than twice the longest * expected input line. Because of the way underlining is handled, the * input line which is to be underlined, can almost triple in length. * Unlike normal underlining and boldfacing, continuous underlining * affects all characters in the buffer, and represents the worst case * condition. If the distance between the left margin and the right * margin is greater than about 65 characters, and continuous underlining * is in effect, there is a high probability of buffer overflow. */ #define MAXLINE 200 #define PAGELEN 66 #define PAGEWIDTH 80 #define HUGE 256 #define INFINITE 32000 #define LEFT 0 /* indecies into hdr margin lim arrays*/ #define RIGHT 1 #define Nfiles 4 /* nesting depth for input files */ /* * The following parameters may be defined elsewhere so undef/def */ #undef min #undef max #undef YES #define YES 1 #undef NO #define NO 0 #undef ERR #define ERR -1 #define EOS '\0' #undef FALSE #define FALSE 0 #undef TRUE #define TRUE !FALSE #undef OK #define OK !ERR #define ADJ_OFF 0 #define ADJ_LEFT 1 #define ADJ_RIGHT 2 #define ADJ_CENTER 3 #define ADJ_BOTH 4 /* * The parameter values selected for macro definitions are somewhat * arbitrary. MACBUF is the storage area for both macro names and * definitions. Since macro processing is handled by pushing back * the expansion into the input buffer, the longest possible expansion * would be MAXLINE characters. Allowing for argument expansion, * MXMLEN was chosen slightly less than MAXLINE. It is assumed that * most macro definitions will not exceed 20 characters, hence MXMDEF * of 150. */ #define MXMDEF 150 /* max no. of macro definitions */ #define MACBUF 32000 /* macro definition buffer size */ #define MXMLEN 250 /* max length of each macro def */ #define MNLEN 10 /* max length of macro name */ #define MAXREGS 100 /* max number of registers (2-char) */ struct macros { char *mnames[MXMDEF]; /* table of ptrs to macro names */ int lastp; /* index to last mname */ char *emb; /* next char avail in macro defn buf */ char mb[MACBUF]; /* table of macro definitions */ char *ppb; /* pointer into push back buffer */ char pbb[MAXLINE]; /* push back buffer */ }; #define RF_READ 0x0001 /* register flags */ #define RF_WRITE 0x0002 struct regs { char rname[4]; /* 2-char register name */ int rauto; /* autoincrement value */ int rval; /* current value of the register */ int rflag; /* register flags */ char rfmt; /* register format (1,a,A,i,I,...) */ }; /* * control parameters for nro */ struct docctl { int fill; /* fill if YES, init = YES */ int dofnt; /* handle font change, init = YES */ int lsval; /* current line spacing, init = 1 */ int inval; /* current indent, >= 0, init = 0 */ int rmval; /* current right margin, init = 60 */ int llval; /* current line length, init = 60 */ int ltval; /* current title length, init = 60 */ int tival; /* current temp indent, init = 0 */ int ceval; /* number of lines to center, init = 0 */ int ulval; /* number of lines to underline, init = 0 */ int cuval; /* no lines to continuously uline, init = 0 */ int juval; /* justify if YES, init = YES */ int adjval; /* adjust type, init = ADJ_BOTH */ int boval; /* number of lines to bold face, init = 0 */ int bsflg; /* can output contain '\b', init = FALSE */ int prflg; /* print on or off, init = TRUE */ int sprdir; /* direction for spread(), init = 0 */ int flevel; /* nesting depth for source cmd, init = 0 */ int lastfnt; /* previous used font */ int thisfnt; /* current font, init = 1 (1=R,2=I,3=B,4=S) */ int escon; /* whether esc parsing is on, init = YES */ int nr[26]; /* number registers */ int nrauto[26]; /* number registers auto increment */ char nrfmt[26]; /* number registers formats, init = '1' */ /* input code how printed */ /* 1 '1' 1,2,3,... */ /* a 'a' a,b,c,...,aa,bb,cc,... */ /* A 'A' A,B,C,...,AA,BB,CC,... */ /* i 'i' i,ii,iii,iv,v... */ /* I 'I' I,II,III,IV,V... */ /* 01 2 01,02,03,... */ /* 001 3 001,002,003,... */ /* 0..1 8 00000001,00000002,... */ char pgchr; /* page number character, init = '%' */ char cmdchr; /* command character, init = '.' */ char escchr; /* escape char, init = '\' */ char nobrchr; /* nobreak char, init = '\'' */ }; /* * output buffer control parameters */ struct cout { int outp; /* next avail char pos in outbuf, init = 0 */ int outw; /* width of text currently in buffer */ int outwds; /* number of words in buffer, init = 0 */ int lpr; /* output to printer, init = FALSE */ int outesc; /* number of escape char on this line */ char outbuf[MAXLINE];/* output of filled text */ }; /* * page control parameters for nroff */ struct page { int curpag; /* current output page number, init =0 */ int newpag; /* next output page number, init = 1 */ int lineno; /* next line to be printed, init = 0 */ int plval; /* page length in lines, init = 66 */ int m1val; /* margin before and including header */ int m2val; /* margin after header */ int m3val; /* margin after last text line */ int m4val; /* bottom margin, including footer */ int bottom; /* last live line on page = plval - m3val - m4val */ int offset; /* page offset from left, init = 0 */ int frstpg; /* first page to print, init = 0 */ int lastpg; /* last page to print, init = 30000 */ int ehlim[2]; /* left/right margins for headers/footers */ int ohlim[2]; /* init = 0 and PAGEWIDTH */ int eflim[2]; int oflim[2]; char ehead[MAXLINE]; /* top of page title, init = '\n' */ char ohead[MAXLINE]; char efoot[MAXLINE]; /* bottom of page title, init = '\n' */ char ofoot[MAXLINE]; }; /* * forward refs from libc */ char *getenv (); char *ctime (); /* NOTE: my ctime is slightly different */ /* * forward refs from nroff */ char *getmac (); char *getstr (); char *skipwd (); char *skipbl (); char *getfield (); int comand (); int comtyp (); int gettl (); int getval (); int set (); int expesc (); int specialchar (); int fontchange (); int getlin (); int ngetc (); int pbstr (); int putbak (); int prchar (); int put (); int putlin (); int atod (); int robrk (); int ctod (); int space (); int getwrd (); int countesc (); int itoda (); int itoROMAN (); int itoroman (); int itoLETTER (); int itoletter (); int min (); int max (); int defmac (); int colmac (); int putmac (); int maceval (); int main (); int usage (); int init (); int pswitch (); int profile (); int text (); int bold (); int center (); int expand (); int justcntr (); int justleft (); int justrite (); int leadbl (); int pfoot (); int phead (); int puttl (); int putwrd (); int skip (); int spread (); int strkovr (); int underl (); int width (); int findreg (); int set_ireg (); /* * globals. define NRO_MAIN in main.c to define globals there. else * you get extern. */ #ifdef NRO_MAIN struct docctl dc; struct page pg; struct cout co; struct macros mac; struct regs rg[MAXREGS]; FILE *pout; FILE *err_stream; FILE *dbg_stream; FILE *sofile[Nfiles+1]; int hold_screen; int debugging; char *dbgfile = "nroff.dbg"; #ifdef ALCYON char *printer = "prn:"; /* this WON'T work!!! */ #else char *printer = "/dev/lp"; /* this probably won't */ #endif #include "version.h" /* for myname and version */ #ifdef ALCYON /* * this SHOULD be big enough for most needs. only used by startup * code (gemstart.o or crt0.o) */ long _STKSIZ = 0x00055555L; /* about 350000 */ #endif #else /*NRO_MAIN*/ extern struct docctl dc; extern struct page pg; extern struct cout co; extern struct macros mac; extern struct regs rg[MAXREGS]; extern FILE *pout; extern FILE *err_stream; extern FILE *dbg_stream; extern FILE *sofile[Nfiles+1]; extern int hold_screen; extern int debugging; extern char *dbgfile; extern char *printer; extern char *myname; extern char *version; #endif /*NRO_MAIN*/ #endif /*NRO_H*/ @//E*O*F nroff.h// chmod u=rw,g=r,o=r nroff.h echo x - version.h sed 's/^@//' > "version.h" <<'@//E*O*F version.h//' #ifndef VERSION_H #define VERSION_H /* * to get around no valid argv[0]... */ char *myname = "nroff"; #ifdef ALCYON char *version = "nroff (TOS) v0.90 ALPHA 11/12/89 wjr"; #else char *version = "nroff (Minix) v0.90 ALPHA 11/12/89 wjr"; #endif #endif /*VERSION_H*/ @//E*O*F version.h// chmod u=rw,g=r,o=r version.h exit 0