bug-groff
[Top][All Lists]
Advanced

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

[bug #61646] [me] line numbering doesn't work as documented


From: G. Branden Robinson
Subject: [bug #61646] [me] line numbering doesn't work as documented
Date: Sat, 1 Jan 2022 07:56:14 -0500 (EST)
User-agent: Lynx/2.8.9rel.1 libwww-FM/2.14 SSL-MM/1.4.1 GNUTLS/3.6.7

Follow-up Comment #4, bug #61646 (project groff):

As promised, here's how I propose to deal with the problems
identified in comment #3.

Let me re-present my input since I've made it more illustrative.


.if r mypo .po \n[mypo]u
.if !d C .ds C\" empty
.pp
Feck, vex loping bad jazz: quench my thirst.
Feck, vex loping bad jazz: quench my thirst.
.pp
.n1 \*C
Jackdaws love my big sphinx of quartz.
Jackdaws love my big sphinx of quartz.
Jackdaws love my big sphinx of quartz.
.pp
How vexingly quick daft zebras jump!
.pp
.n2 +6
Waltz, bad nymph, for quick jigs vex.
Waltz, bad nymph, for quick jigs vex.
.pp
.n2 99
Pack my box with five dozen liquor jugs.
Pack my box with five dozen liquor jugs.
Pack my box with five dozen liquor jugs.
.pp
.n2
The five boxing wizards jump quickly.
The five boxing wizards jump quickly.


Here's the corresponding output from groff 1.22.4.


$ nroff -me EXPERIMENTS/n1n2.me | cat -s

     Feck, vex loping bad jazz: quench my thirst.  Feck, vex
loping bad jazz: quench my thirst.

  1      Jackdaws love my big sphinx  of  quartz.   Jackdaws
  2 love  my  big  sphinx  of  quartz.  Jackdaws love my big
  3 sphinx of quartz.

  4      How vexingly quick daft zebras jump!

6      Waltz, bad nymph, for quick jigs vex.   Waltz,  bad
7 nymph, for quick jigs vex.

99      Pack  my  box with five dozen liquor jugs.  Pack my
100 box with five dozen liquor jugs.  Pack my box with  five
101 dozen liquor jugs.

 The  five  boxing  wizards  jump quickly.  The five
boxing wizards jump quickly.


We can identify a seventh problem, in that the line length for
the final, unnumbered paragraph is clearly too short.

Now for output with my fixes applied.


$ ./build/test-groff -Tutf8 -me EXPERIMENTS/n1n2.me | cat -s
e.tmac:EXPERIMENTS/n1n2.me:7: page offset is negative (-96u)

     Feck, vex loping bad jazz: quench my thirst.  Feck, vex
loping bad jazz: quench my thirst.

1      Jackdaws  love  my big sphinx of quartz.  Jackdaws love
2 my big sphinx of quartz.  Jackdaws love  my  big  sphinx  of
3 quartz.

4      How vexingly quick daft zebras jump!

10      Waltz,  bad  nymph,  for  quick  jigs  vex.  Waltz, bad
11 nymph, for quick jigs vex.

99      Pack my box with five dozen liquor jugs.  Pack  my  box
100 with  five  dozen  liquor jugs.  Pack my box with five dozen
101 liquor jugs.

     The five boxing wizards jump quickly.  The five  boxing
wizards jump quickly.


First, I've added a diagnostic that complains about the negative
page offset that results when the me(7) line numbering feature
is used when the page offset is zero or too narrow to
accommodate the line numbers.  There are a couple of ways around
this problem, as we shall see.

The above result might still be useful, if the document author
does not care about have a consistent amount of space set aside
for it--for the traditional application of previewing a
document, for instance.  The space required to set the line
number (plus one numeral-width space) is grafted onto the
beginning of the line irrespective of the line length, so we see
the lines grow steadily, but predictably, longer.

BSD me(7) always used a page offset in nroff mode; GNU me(7)
does not.  This line numbering feature is the only place I know
of where that bites us or causes output to look weird; that is
why I introduced the diagnostic.

How have the problems been addressed?

#1: We haven't asked for "roff(1) compatibility" so we didn't
get it.

#2: The space allocated to the line number is predictable.

#3: The line number in the "waltz" paragraph is incremented as
requested.

#4: The "waltz" paragraph (and the others) are adjusted
predictably given the caveat above.

#5: The effective page offset of the "Pack" paragraph is
similarly predictable.

#6: The final, unnumbered paragraph is indented by 5n exactly
like the first unnumbered paragraph.

#7: The line length of the final paragraph is exactly 60n, just
like the first unnumbered paragraph.

Okay, so what about the page offset issue?

Approach #1:

Use a "roff(1) compatibility" argument to the macros.  As
discussed earlier, I've moved this argument, a GNU extension,
from the `n2` macro to `n1` where I think it makes more sense.
I've also made its detection case-insensitive.  I will change
"meref.me" to document only an uppercase "C" for this purpose,
for that is consistent with other letter arguments used by the
me(7) package (see, e.g., `(l`, `(b`, `(z`, `EQ`, `EN`, `TS`,
`GS`, `++`, and `+c`).

As can be seen from the input exhibit, passing in a `C` string
defined as "C" is enough to cause this to happen for this
document.


$ ./build/test-groff -dCC -Tutf8 -me EXPERIMENTS/n1n2.me \
| cat -s

     Feck, vex loping bad jazz: quench my thirst.  Feck, vex
loping bad jazz: quench my thirst.

  1      Jackdaws  love  my  big sphinx of quartz.  Jackdaws
  2 love my big sphinx of  quartz.   Jackdaws  love  my  big
  3 sphinx of quartz.

  4      How vexingly quick daft zebras jump!

 10      Waltz,  bad  nymph, for quick jigs vex.  Waltz, bad
 11 nymph, for quick jigs vex.

 99      Pack my box with five dozen liquor jugs.   Pack  my
100 box  with five dozen liquor jugs.  Pack my box with five
101 dozen liquor jugs.

     The five boxing wizards jump quickly.  The five  boxing
wizards jump quickly.



The line length is 60n consistently throughout.  The space for
the line number is borrowed from the original length, it is
consistent in amount, and that space is "returned" when
numbering is turned off.  We see a straight right margin.

The other way to address this problem is to give the output
device a page offset that is enough to accommodate the line
number, just as troff devices have.


$ ./build/test-groff -rmypo=4n -Tutf8 -me EXPERIMENTS/n1n2.me \
| cat -s

         Feck, vex loping bad jazz: quench my thirst.  Feck, vex
    loping bad jazz: quench my thirst.

  1      Jackdaws  love  my big sphinx of quartz.  Jackdaws love
  2 my big sphinx of quartz.  Jackdaws love  my  big  sphinx  of
  3 quartz.

  4      How vexingly quick daft zebras jump!

 10      Waltz,  bad  nymph,  for  quick  jigs  vex.  Waltz, bad
 11 nymph, for quick jigs vex.

 99      Pack my box with five dozen liquor jugs.  Pack  my  box
100 with  five  dozen  liquor jugs.  Pack my box with five dozen
101 liquor jugs.

         The five boxing wizards jump quickly.  The five  boxing
    wizards jump quickly.



(In principle, using me(7)'s `po` register directly should work,
particularly on the command line so it is seen as early as
possible--but it doesn't.  That's a separate issue, and one I
might look into.)

There's not a lot to say about the above except that it resolves
the same 7 problems and looks much like troff/PostScript output
(if you set the `pp` register to 18 at the beginning of the
document, the lines even break in the same places [again,
setting the register on the command line is not fruitful]).

Something I still need to do is see for myself how the line
numbering feature behaves in old roff(1).  For that I'll need to
fire up SIMH and see if it exists in my Unix V7 environment.

I'm attaching a patch to e.tmac if anyone else wants to try it
out.


(file #52592)
    _______________________________________________________

Additional Item Attachment:

File name: 61646.diff                     Size:1 KB
    <https://file.savannah.gnu.org/file/61646.diff?file_id=52592>



    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?61646>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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