[comp.bugs.4bsd] C/A/T troff bug with -mm macros

stevens@hsi.UUCP (Richard Stevens) (12/16/89)

I have found a bug with the old C/A/T version of troff that's
shipped with 4.3BSD.  The bug shows up with the -mm macro
package.  The following test file

	.tm MM page at start = \nP
	This is the start of page one.
	.tm MM page after line of text = \nP
	.bp
	.tm MM page at top of page two = \nP
	This is the top of page two.

generates the following output with the C/A/T troff (and it's
corresponding version of nroff too):  (extraneous blank lines have
been removed)

	MM page at start = 0
	
	 - 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -
	
	MM page after line of text = 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001
	This is the start of page one.
	
	 - 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002 -
	
	MM page at top of page two = 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002
	This is the top of page two.


But, DWB 2.0 ditroff handles this just fine.  I realize that there
are few people who use -mm with 4.3BSD, but I was wondering if anyone
has encountered this before and already has a fix ??  Thanks.

	Richard Stevens
	Health Systems International, New Haven, CT
	   stevens@hsi.com
           ... { uunet | yale } ! hsi ! stevens

rick@pcrat.uucp (Rick Richardson) (12/16/89)

In article <927@hsi86.hsi.UUCP> stevens@hsi.UUCP (Richard Stevens) writes:
>I have found a bug with the old C/A/T version of troff that's
>shipped with 4.3BSD.  The bug shows up with the -mm macro
>	MM page at start = 0
>	
>	 - 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -

I believe this is because the MM macros use the \g (return register
format) escape sequence, which does not exist in C/A/T troff.  There
are several places in the macros that you'll have to fix.
Sorry, I don't have the fixes around here.  What you need to do
is find all the number registers whose format is referenced
with \g (backslash g).  Then, every place that those number registers
have their format changed with ".af" you will need to remember the
format in a string register that isn't used (.ds xx format, one
string reg per number reg).  Then, you need to replace the \g's
with references to your string registers.

-Rick

-- 
Rick Richardson |       Looking for FAX software for UNIX/386 ??????     mention
PC Research,Inc.|                  WE'RE SHIPPING			 your
uunet!pcrat!rick|    Ask about FaxiX - UNIX Facsimile System (tm)        FAX #
(201) 389-8963  | Or JetRoff - troff postprocessor for the HP {Laser,Desk}Jet

tut%cairo@Sun.COM (Bill "Bill" Tuthill) (12/17/89)

In <1989Dec16.133059.6190@pcrat.uucp>, rick@pcrat.uucp (Rick Richardson) writes:
> In article <927@hsi86.hsi.UUCP> stevens@hsi.UUCP (Richard Stevens) writes:
> >I have found a bug with the old C/A/T version of troff that's
> >shipped with 4.3BSD.  The bug shows up with the -mm macro
> >	MM page at start = 0
> >	
> >	 - 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 -
> 
> I believe this is because the MM macros use the \g (return register
> format) escape sequence, which does not exist in C/A/T troff.

It's easy enough to add support for \g -- even I could do it.  This was
many moons ago, so I hope these diffs are sufficient.

% sccs diffs -r1.3 n1.c
------- n1.c -------
613a620,622
>               case 'g':       /* return format of number reg */
>                       setaf();
>                       goto g0;

% sccs diffs -r1.3 n4.c
------- n4.c -------
481a505,519
> setaf()         /* return format of number register */
> {
>       register int i, j;
> 
>       if ((i = usedr(getsn())) == -1) /* no such register */
>               return;
>       cp = cbuf;
>       if (fmt[i] > 20)        /* probably a A i I */
>               *cp++ = fmt[i];
>       else
>               for (j = (fmt[i] ? fmt[i] : 1); j; j--)
>                       *cp++ = '0';
>       *cp = 0;
>       cp = cbuf;
> }

jbw@bucsf.bu.edu (Joe Wells) (12/18/89)

In article <927@hsi86.hsi.UUCP> stevens@hsi.UUCP (Richard Stevens) writes:

   I have found a bug with the old C/A/T version of troff that's
   shipped with 4.3BSD.  The bug shows up with the -mm macro
   package.

As several people have already pointed out, this is because of the missing
\g command in your version of troff.  I'm including a diff to the MM macro
package to make it work without \g.  The diff also fixes some other bugs.

Enjoy,

-- 
Joe Wells <jbw@bucsf.bu.edu>
jbw%bucsf.bu.edu@bu-it.bu.edu
...!harvard!bu-cs!bucsf!jbw
(617) 375-6893
200-202 Bay State Rd., Box 1486, Boston, MA 02215, USA
----------------------------------------------------------------------
*** mmt.old	Wed May 31 16:32:52 1989
--- mmt	Mon Jun  5 18:51:29 1989
***************
*** 619,643 ****
  .tmERROR:(\\n(.F)input line \\n(.c:\\$1
  .if!\\nD .ab \&
  ..
  .deTB
! .nr!1 1
! .ie.)F TABLE 1 \\n+(Tb "\\$1" "\\n(H1-" 0
! .el.)F TABLE 1 \\n+(Tb "\\$1" "\\$2" 0\\$3
  ..
  .deEC
! .nr!2 1
! .ie.)F Equation 2 \\n+(Ec "\\$1" "\\n(H1-" 0
! .el.)F Equation 2 \\n+(Ec "\\$1" "\\$2" 0\\$3
  ..
  .deEX
! .nr!3 1
! .ie.)F Exhibit 3 \\n+(Ex "\\$1" "\\n(H1-" 0
! .el.)F Exhibit 3 \\n+(Ex "\\$1" "\\$2" 0\\$3
  ..
  .deFG
! .nr!0 1
! .ie.)F Figure 0 \\n+(Fg "\\$1" "\\n(H1-" 0
! .el.)F Figure 0 \\n+(Fg "\\$1" "\\$2" 0\\$3
  ..
  .de)F
  .nr;0 \w\\$5
--- 619,657 ----
  .tmERROR:(\\n(.F)input line \\n(.c:\\$1
  .if!\\nD .ab \&
  ..
+ .\"	Fixed numbering on exhibits, tables, figures, etc.
+ .\"	Used to be like this:
+ .\"		.deTB
+ .\"		.nr!1 1
+ .\"		.ie.)F TABLE 1 \\n+(Tb "\\$1" "\\n(H1-" 0
+ .\"		.el.)F TABLE 1 \\n+(Tb "\\$1" "\\$2" 0\\$3
+ .\"		..
+ .\"	Notice the syntax error (missing condition) on the .ie line.
+ .\"	N=5 means do section numbering for figures.
+ .\"	--Joe Wells
  .deTB
! .nr !1 1
! .nr Tb +1
! .ie \\nN=5 .)F TABLE 1 \\n(Tb "\\$1" "\\n(H1-" 0
! .el .)F TABLE 1 \\n(Tb "\\$1" "\\$2" 0\\$3
  ..
  .deEC
! .nr !2 1
! .nr Ec +1
! .ie \\nN=5 .)F Equation 2 \\n(Ec "\\$1" "\\n(H1-" 0
! .el .)F Equation 2 \\n(Ec "\\$1" "\\$2" 0\\$3
  ..
  .deEX
! .nr !3 1
! .nr Ex +1
! .ie \\nN=5 .)F Exhibit 3 \\n(Ex "\\$1" "\\n(H1-" 0
! .el .)F Exhibit 3 \\n(Ex "\\$1" "\\$2" 0\\$3
  ..
  .deFG
! .nr !0 1
! .nr Fg +1
! .ie \\nN=5 .)F Figure 0 \\n(Fg "\\$1" "\\n(H1-" 0
! .el .)F Figure 0 \\n(Fg "\\$1" "\\$2" 0\\$3
  ..
  .de)F
  .nr;0 \w\\$5
***************
*** 1143,1149 ****
  .sp|1.1i-1v
  \t\s36\(bs\s0
  .vs.3i
! .if\w\\*(}2 \t\s16\f3\\*(}2\fP\s0
  .vs12p
  .sp|1.9i
  .mk:2
--- 1157,1169 ----
  .sp|1.1i-1v
  \t\s36\(bs\s0
  .vs.3i
! .\"	Fixed display of company name so that it works properly for a
! .\"	long name.
! .\"	Used to be this:
! .\"		.if\w\\*(}2 \t\s16\f3\\*(}2\fP\s0
! .\"	String }2 is the company name.
! .\"	--Joe Wells
! .if\w"\\*(}2" \s16\f3\h'|\\nWu-\w"\\*(}2"u'\\*(}2\fP\s0
  .vs12p
  .sp|1.9i
  .mk:2
***************
*** 1192,1199 ****
  .rs
  .ie\\n(;3 \{\
  .ie\\n(:t=2 \{\
! .af!S \\gP 
! .afP i
  .]t  
  .in+\\n(:3u
  .>3  
--- 1212,1227 ----
  .rs
  .ie\\n(;3 \{\
  .ie\\n(:t=2 \{\
! .\"	We keep track of the format of register P in string Pf, because
! .\"	the \g command does not work in our version of troff.  The \g
! .\"	command returns the display format of a numeric register.
! .\"	Next three lines used to be this:
! .\"		.af!S \\gP
! .\"		.afP i
! .\"	--Joe Wells
! .ds !S \\*(Pf
! .ds Pf i
! .afP \\*(Pf
  .]t  
  .in+\\n(:3u
  .>3  
***************
*** 1203,1209 ****
  .wh0 )k  
  .bp
  .nrP 1  
! .afP \\g(!S 
  .]t  
  .wh0 )h  
  .if\\n(:G \{\
--- 1231,1241 ----
  .wh0 )k  
  .bp
  .nrP 1  
! .\"	Next two lines used to be this:
! .\"		.afP \\g(!S
! .\"	--Joe Wells
! .ds Pf \\*(!S
! .af P \\*(Pf
  .]t  
  .wh0 )h  
  .if\\n(:G \{\
***************
*** 1854,1859 ****
  .ie\\*(]w 'ch )f -\\n(:ou
  .el'ch )f -(\\n(:ou+1v)
  ..
  .dePH
  .ds}t "\\$1
  ..
--- 1886,1899 ----
  .ie\\*(]w 'ch )f -\\n(:ou
  .el'ch )f -(\\n(:ou+1v)
  ..
+ .\"	Purposes of some macros:
+ .\"	}t = page header
+ .\"	}e = even page header
+ .\"	}o = odd page header
+ .\"	}b = page footer
+ .\"	}f = even page footer
+ .\"	}p = odd page footer
+ .\"	--Joe Wells
  .dePH
  .ds}t "\\$1
  ..
***************
*** 1875,1885 ****
  .deTP
  'sp
  .)K
! .af;P \\gP
! .afP 1
! .nr;P \\nP
! .afP \\g(;P
! .af;P 1
  .ie\\n(Pv \{\
  .ie(\\n(Pv=1)&(\\n(;P>1) 'sp 2
  .el\{\
--- 1915,1932 ----
  .deTP
  'sp
  .)K
! .\"	Next five lines are altered from original.  Used to be:
! .\"		.af;P \\gP
! .\"		.afP 1
! .\"		.nr;P \\nP
! .\"		.afP \\g(;P
! .\"		.af;P 1
! .\"	--Joe Wells
! .af ;P 1
! .af P 1
! .nr ;P \\nP
! .if '\\*(Pf'' .ds Pf 1
! .af P \\*(Pf
  .ie\\n(Pv \{\
  .ie(\\n(Pv=1)&(\\n(;P>1) 'sp 2
  .el\{\
***************
*** 1890,1895 ****
  .if!\\n(;P-1 .if \\nN 'sp
  .if!\\n(;P-1 .if \\n(:S .tl \\*(}t
  .if!\\n(;P-1 .if !\\nN .tl \\*(}t
  .if\\n(;P-1 .ie \w'\\*(]n' .tl '\\*(]n - \\nP'''
  .el.tl \\*(}t
  'if!\\n(;P%2 'tl \\*(}e
--- 1937,1944 ----
  .if!\\n(;P-1 .if \\nN 'sp
  .if!\\n(;P-1 .if \\n(:S .tl \\*(}t
  .if!\\n(;P-1 .if !\\nN .tl \\*(}t
+ .\" 	String ]n is addressee of letter.
+ .\"	--Joe Wells
  .if\\n(;P-1 .ie \w'\\*(]n' .tl '\\*(]n - \\nP'''
  .el.tl \\*(}t
  'if!\\n(;P%2 'tl \\*(}e
***************
*** 1928,1938 ****
  .tlBell System except under written agreement. \}
  .if\\n(!K .tl 
  .)R
! .af;P \\gP
! .afP 1
! .nr;P \\nP
! .afP \\g(;P
! .af;P 1
  .ie!\\n(;P%2 .tl \\*(}f
  .el.tl \\*(}p
  .ie\\n(;P=1 \{\
--- 1977,1994 ----
  .tlBell System except under written agreement. \}
  .if\\n(!K .tl 
  .)R
! .\"	Next five lines used to be:
! .\"		.af;P \\gP
! .\"		.afP 1
! .\"		.nr;P \\nP
! .\"		.afP \\g(;P
! .\"		.af;P 1
! .\"	--Joe Wells
! .af ;P 1
! .af P 1
! .nr ;P \\nP
! .if '\\*(Pf'' .ds Pf 1
! .af P \\*(Pf
  .ie!\\n(;P%2 .tl \\*(}f
  .el.tl \\*(}p
  .ie\\n(;P=1 \{\
***************
*** 2625,2634 ****
  .tmERROR: MM package read twice
  .ab	\}
  .ds]Z MM DEFINED
! .if!\w'\gE' .nr E 1
  .if!\nL .nr L 11i
  .pl\nLu
! .if!\w'\gO' .nr O .963i
  .po\nOu
  .if\nP .nr P -1
  .nrP \nP 1
--- 2681,2701 ----
  .tmERROR: MM package read twice
  .ab	\}
  .ds]Z MM DEFINED
! .\"	Next line used to be:
! .\"		.if!\w'\gE' .nr E 1
! .\"	Note, register E can no longer be set from the command line to
! .\"	zero.  No big loss.  Numeric register E controls the font of the
! .\"	subject/date/from fields.
! .\"	--Joe Wells
! .if !\nE .nr E 1
  .if!\nL .nr L 11i
  .pl\nLu
! .\" 	The next line used to be this:
! .\"		.if!\w'\gO' .nr O .963i
! .\" 	Note, you can no longer set register O from the command line
! .\"	to zero.  Register O controls the page offset.
! .\"	--Joe Wells
! .if!\nO .nr O .963i
  .po\nOu
  .if\nP .nr P -1
  .nrP \nP 1

brown@vidiot.UUCP (Vidiot) (12/20/89)

In article <JBW.89Dec17214350@bucsf.bu.edu> jbw@bucsf.bu.edu (Joe Wells) writes:
<In article <927@hsi86.hsi.UUCP> stevens@hsi.UUCP (Richard Stevens) writes:
<
<   I have found a bug with the old C/A/T version of troff that's
<   shipped with 4.3BSD.  The bug shows up with the -mm macro
<   package.
<
<As several people have already pointed out, this is because of the missing
<\g command in your version of troff.  I'm including a diff to the MM macro
<package to make it work without \g.  The diff also fixes some other bugs.

Wait-a-minute!  What is a \g command?  My UNIX documentation books don't have
any mention of it.  This includes a book that cover DWB2.0.
-- 
                harvard\     att!nicmad\
Vidiot            ucbvax!uwvax..........!astroatc!vidiot!brown
                rutgers/  decvax!nicmad/
        ARPA/INTERNET: <@spool.cs.wisc.edu,@astroatc:brown@vidiot>

henry%angel@Sun.COM (Henry McGilton -- Software Products) (12/20/89)

In article <336@vidiot.UUCP>, brown@vidiot.UUCP (Vidiot) writes:

    *  Wait-a-minute!  What is a \g command?

The  \g  escape sequence reads out the current interpolation format
of a specified number register.

    *  My UNIX documentation books don't have any mention of it.
    *  This includes a book that cover DWB2.0.

Use  \gx  to obtain the interpolation format for register x.

Use  \g(xy  to obtain the interpolation format for register xy.

See the  .af  request for an explanation of interpolation formats.

As for your documentation, the documentation for DWB has
not been substantially updated or improved since 1976.
There were some perfunctory additions in the form of a
memorandum in 1982, and that's about it.  If you get DWB
documentation from A. T. T. today, you'll get essectially
the 1976 documentation plus a bunch of memoranda that
consitute updates to the original stuff.  Don't expect this
situation to change any time in the near future.  Keep
reading comp.text and comp.unix.questions for knowledge
about troff and friends.  This problem with the \g
sequence versus C/A/T troff comes up about once a month.

Amazing, really, that they are unable to use the so-called
Documentor's Workbench to write some new documentation.

When I was ready to post this, I noticed that it was cross posted
to comp.bugs.4bsd.  The original poster should really have checked
first before screaming `Bug!' on the net.  It's not a bug, it's
a result of zero support for C/A/T troff, and little more
than zero for ditroff.

	................ Henry
+-------------------+--------------------------+---------------------------+
| Henry McGilton    | Timesharing was the mass |                           |
| Sun Microsystems  | psychosis of the 1970's, | arpa: hmcgilton@sun.com   |
| 2550 Garcia       |   induced by invalid     | uucp: ...!sun!angel!henry |
| Mountain View, CA |   accounting methods.    |                           |
+-------------------+--------------------------+---------------------------+