groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Groff] Bug in groff MM macros' MC macro?


From: T. Kurt Bond
Subject: [Groff] Bug in groff MM macros' MC macro?
Date: Sat, 5 Aug 2000 15:07:37 -0400 (EDT)

Hello,

I think I have run into a bug in the groff versions of the MM macros.
The MC macro, which starts multicolumn mode, doesn't seem to calculate
the number of columns which can fit on a page correctly, and so one
fewer columns are printed than there should be.  I think I have a fix;
a patch is included below the following discussion.

                           GROFF Bug Report
GROFF VERSION: groff 1.11 (mm version 1.27) and groff 1.16.1 [current
from CVS] (mm version 1.2? See {Note Confused Versions}).

MACHINE: Pentium II 350 Mhz, 256 Mb RAM

OS: GNU/Linux, Redhat 6.2

COMPILER: for groff 1.11 what ever Redhat used.  For groff 1.16.1:

    gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)

(I haven't upgraded gcc on this machine; I assume the above is also
what Redhat used to compile groff 1.11.)

INPUT FILES:

Here is a file that shows the bug, (indented 4 characters):

    .\" MC.mm -- Show bug in groff MM's MC macro.
    .\" groff -rW4.25i -rL3.5i -Xps -mm MC.mm
    .\" The following is a paragraph to show where the margins are.
    .P
    Science is emphatically an important part of culture today, as
    scientific knowledge and its applications continue to transform the
    world, and and condition every aspect of teh relations between men and
    nations.
    \(em Vabnnevar Bush, \fIScience Is Not Enough\fP, 1967.
    .SP 1v
    .\" 2i + 0.25i + 2i = 4.25i, so we should have space for two columns,
    .\" but with the current groff MM macros we only get one space.
    .MC 2i 0.25i
    .P
    What we take to be our strongest tower of delight, only stands at the
    caprice of teh minutest event \(em the falling of a leaf, the hearing
    of a voice, or the receipt of one little bit of paper scratched over
    with a few small characters by a sharpened feather.
    \(em Herman Mevlille, \fIMoby-Dick\fP, 1851.
    .\" end of MC.mm

COMMAND LINE: 

If you format the above file (after deleting the indentation) with the
command 

    groff -rW4.25i -rL3.5i -Xps -mm MC.mm

DESCRIPTION OF INCORRECT BEHAVIOR:

you'll see that there is a paragraph that spans the entire width
(4.25i), followed by a paragraph in the left column, followed by a
page break, followed by another paragraph in the left column.
No text was printed in the right column.

This happens with the MM macros in groff 1.11 (mm version 1.27) and
groff 1.16.1 (the current version from CVS; mm version 1.2? See {Note
Confused Versions}).

SUGGESTED FIX:

I think the problem is line 1464 in tmac.m: 
    
    .nr pg*cols-per-page (u;\\n[.l]/(\\n[pg*column-size]+\\n[pg*column-sep]+1))

That seems to me to be ignoring the fact that there is one fewer
gutter (pg*column-sep) than there are columns.  (I don't understand
why there is a +1 at the end of the expression, but I don't think it
changes the problem.)

I think that line should be replaced with a loop that counts up the
number of columns, separated (not terminated) by gutters, that can fit
on a page.  Something like this:

    .nr pg*cols-per-page 0
    .\" pg*mc-acc is an accumulator
    .nr pg*mc-acc \\n[pg*column-size]
    .while \\n[pg*mc-acc]<=\\n[.l] \{\
    .  nr pg*cols-per-page \\n[pg*cols-per-page]+1
    .  nr pg*mc-acc \\n[pg*mc-acc]+\\n[pg*column-sep]+\\n[pg*column-size]
    .\}

I've tested this, and it seems to work fine.  The above test file
works.

{Note Confused Versions}
    BTW, I was a little unclear as to which version of MM is the most
    recent, and where it is kept, and to whom I should report this
    bug.  The README file in the groff/contrib/mm directory says

        Newest version is available with anonymous FTP
        at ftp://ftp.efd.lth.se/pub/groff/mm<something>.gz
        or ftp://ftp.axis.se/pub/groff/mm<something>.gz

    But the first ftp site only has files only up to mm1.29.tar.gz (of
    6 September 1996); the later ftp site has up to mm1.32.tar.gz (of
    3 September 1999). Oddly enough, the tmac.m file in mm1.32.tar.gz
    from the later ftp site has an RCS id of 1.32 from 1999/09/03, but
    the tmac.m in the most recent groff CVS has a RCS id of 1.2, yet
    is from 2000/02/21.  I'm assuming the groff CVS version of MM is
    the newest, and the date and the actual code in that version seem
    to confirm this (there are additional bugfixes in the groff CVS
    copy, it seems to me).

    Perhaps the groff/contrib/mm/README could clear this up some, and
    make clear the relationship, if any between the current groff CVS
    copy and the copies on the ftp sites mentioned in the README?

In any case, I'm sending this to the groff list address@hidden and to
the address mentioned in the groff/contrib/mm/README, and to
address@hidden, which is mentioned in the file groff/BUG-REPORT.
(BTW, does anybody use address@hidden any more?)

BTW, I find the groff MM macros very useful.  Thanks!

Anyway, here's a patch made with diff -au:

--- tmac.m.orig Sat Aug  5 17:37:05 2000
+++ tmac.m      Sat Aug  5 17:38:25 2000
@@ -1461,7 +1461,15 @@
 .ie ''\\$2' .nr pg*column-sep \\n[pg*column-size]/15
 .el .nr pg*column-sep (n;\\$2)
 .\"
-.nr pg*cols-per-page (u;\\n[.l]/(\\n[pg*column-size]+\\n[pg*column-sep]+1))
+.nr pg*cols-per-page 0
+.\" pg*mc-acc is an accumulator
+.nr pg*mc-acc \\n[pg*column-size]
+.while \\n[pg*mc-acc]<=\\n[.l] \{\
+.  nr pg*cols-per-page \\n[pg*cols-per-page]+1
+.  nr pg*mc-acc \\n[pg*mc-acc]+\\n[pg*column-sep]+\\n[pg*column-size]
+.\}
+.ie !\\n[pg*cols-per-page]>0 \
+.  ab \\n[.F]:\\n[.c]: MC: Column size too large for even one column on the 
page
 .nr pg*cur-column 0 1
 .nr pg*cur-po address@hidden
 .ll \\n[pg*column-size]u

-- 
T. Kurt Bond, address@hidden


reply via email to

[Prev in Thread] Current Thread [Next in Thread]