bugGNU roff - Bugs: bug #24049, [mm] signature (SG) under MT 5...

 
 

bug #24049: [mm] signature (SG) under MT 5 (external letter) puts spurious hyphens in output

Submitter:  Werner LEMBERG <wl>
Submitted:  Tue 12 Aug 2008 05:02:27 PM UTC
   
 
Category:  Macro mm Severity:  2 - Minor
Item Group:  Incorrect behaviour Status:  Fixed
Privacy:  Public Assigned to:  gbranden
Open/Closed:  Closed Planned Release:  1.23.0
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 19 Dec 2022 01:42:35 AM UTC, comment #3: 


commit b37c1e440ab839b62a04df57f9df65a654701ed3
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Sat Dec 17 14:58:44 2022 -0600

    [mm]: Fix Savannah #24049.

    * m.tmac (let*mt-sign): Check strings populated by optional arguments to
      `AU` macro for existence before interpolating them.

    Fixes <https://savannah.gnu.org/bugs/?24049>.  Thanks to Werner Lemberg
    for the report.


G. Branden Robinson <gbranden>
Group administrator
Sat 17 Dec 2022 08:52:29 PM UTC, comment #2: 

DWB 3.3 mm and Heirloom Doctools mm don't do this.

They also don't require a title for memorandum type 5 (external letter), though this is clearly implied by the DWB 3.3 manual, which is worth quoting for two reasons.

> In the external-letter style (`.MT 5`), only the title (without
> "subject") and the date are printed in the upper left and right
> corners, respectively, on the first page.  It is expected that
> preprinted stationary [sic] will be used providing the author's
> company logo and address.


(The claim about the date being in the upper-right "corner" is either approximate, or wrong.  What all of these mm macro packages do with the date more closely resembles a traditional U.S. business letter than a hyper-literal interpretation of the quote above.)

Example input:


$ cat EXPERIMENTS/letter-with-signature.mm
.ND 2022-12-17
.TL
Our Automobile Requisition
.AU "S.\& Clown"
.MT 5
Dear Regional Manager,
.P 1
It's circuses all the way down.
.FC
.SG


DWB 3.3 mm output:


$ DWBHOME=. ./bin/nroff -mm ~/src/GIT/groff/EXPERIMENTS/letter-with-signature.mm | ul | cat -n
     1
     2
     3
     4
     5         Our Automobile Requisition
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15                                                      2022-12-17
    16
    17
    18         Dear Regional Manager,
    19
    20              It's circuses all the way down.
    21
    22                                       Yours very truly,
    23
    24
    25
    26                                       S. Clown
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66


There is a minor difference in vertical spacing between DWB mm and Heirloom Doctools mm.


--- /tmp/dwbmm.txt      2022-12-17 14:33:01.286672580 -0600
+++ /tmp/heirmm.txt     2022-12-17 14:33:28.854556501 -0600
@@ -10,20 +10,20 @@
     10
     11
     12
-    13
+    13                                                     2022-12-17
     14
-    15                                                     2022-12-17
-    16
+    15
+    16        Dear Regional Manager,
     17
-    18        Dear Regional Manager,
+    18             It's circuses all the way down.
     19
-    20             It's circuses all the way down.
+    20                                      Yours very truly,
     21
-    22                                      Yours very truly,
+    22
     23
-    24
+    24                                      S. Clown
     25
-    26                                      S. Clown
+    26
     27
     28
     29


And here is groff 1.22.4 output.


$ nroff -mm ~/src/GIT/groff/EXPERIMENTS/letter-with-signature.mm | cat -n
     1
     2
     3
     4
     5         Our Automobile Requisition
     6
     7
     8
     9                                                           2022‐12‐17
    10
    11
    12
    13         Dear Regional Manager,
    14
    15              It’s circuses all the way down.
    16
    17                                       Yours very truly,
    18
    19
    20
    21         ‐‐                            S. Clown
    22
    23
[blank lines to 66]


There is a more substantial difference in vertical spacing here.  My guess is that this is because, as the DWB mm manual says, the user of preprinted stationery is expected.

Backward compatibility and reasonable accommodation of users who don't have such stationery both seem reasonable, particularly since these days it is more likely that users will employ Encapsulated PostScript or something like that instead.

What we could do is add an extension option to reduce the space reserved for preprinted stationery, decide on a reasonable default, and document this.

But that's an issue for another day.

The bigger problem here is line 21 in the last example.

This turned out to be easy.  All one had to do was turn on GNU troff warnings and one was led directly to the problems.

Jörgen Hägg interpolated strings that might be undefined.  Specifically, if the document author didn't lard `AU` calls with at least 4 parameters.

So here's a patch.


diff --git a/contrib/mm/m.tmac b/contrib/mm/m.tmac
index e31a8acb7..cf9d9da53 100644
--- a/contrib/mm/m.tmac
+++ b/contrib/mm/m.tmac
@@ -3333,11 +3333,16 @@ in=\\n[.i] fi=\\n[.u] .d=\\n[.d] nl=\\n[nl] pg=\\n[%]
 .ne \\n[cov*au]u*4v
 .ie \\n[.$]>1 .nr let*k 1
 .el .nr let*k \\n[cov*au]
-.ds let*tmp \\*[cov*au!\\n[let*k]!3]-\\*[cov*au!\\n[let*k]!4]-
+.ds let*tmp \" empty
+.if d cov*au!\\n[let*k]!3 \{\
+.      as let*tmp \\*[cov*au!\\n[let*k]!3]\"
+.      if d cov*au!\\n[let*k]!4 \
+.              as let*tmp -\\*[cov*au!\\n[let*k]!4]-\"
+.\}
 .nr let*i 0 1
 .while \\n+[let*i]<=\\n[cov*au] \{\
-.      if \\n[let*i]>1 .as let*tmp /
-.      as let*tmp \\*[cov*au!\\n[let*i]!2]
+.      if \\n[let*i]>1 .as let*tmp /\"
+.      if d cov*au!\\n[let*i]!2 .as let*tmp \\*[cov*au!\\n[let*i]!2]\"
 .\}
 .if !''\\$1' .as let*tmp -\\$1
 .in (u;\\n[.l]/2)


The solution originally proposed does get rid of the excess hyphens (by using the formatted output comparison operator to test strings derived from `AU` arguments for emptiness), but it still dereferences them, which correctly produces warning diagnostics when enabled.

G. Branden Robinson <gbranden>
Group administrator
Wed 14 Apr 2021 07:36:29 AM UTC, comment #1: 

[Mike Bianchi asked (http://lists.gnu.org/archive/html/groff/2021-02/msg00077.html) who maintains the mm macros, implying it's not him (although he didn't respond to a direct query about this (http://lists.gnu.org/archive/html/groff/2021-04/msg00019.html)).  Thus I'm unassigning this mm bug.]

Dave <barx>
Group Member
Tue 12 Aug 2008 05:02:27 PM UTC, original submission:  

.\" $Id: m.tmac,v 2.24 2004/03/10 06:11:26 wlemb Exp $

Problem (or possibly several interesting features) with formatting of author(s) signature lines under MT 5 (external letter) of the mm macros.

--------------------------
example:
single author, one argurment
get lead dashes at left margin "--" in signature line
with:
.AU "John 1 Rupley"
.SG gives:
        --                            John 1 Rupley

--------------------------
example:
two authors, each with reference data (2 or more args)
reference data at left margin has arg 2 replicated:  "jar2/jar2"
with:
.AU "John 1 Rupley" "jar1"
.AU "John 2 Rupley" "jar2" "Biosci." "Biochem. Mol. Biophys."
.SG gives
John 1 Rupley

Biosci.-Biochem. Mol. Biophys.-jar2/jar2 John 2 Rupley

--------------------------

To demonstrate the above, run the attached file through troff -mm and grops.  The file is configured to show the result of the first example above.  For other examples, reset the ".ig" -- ".." pairs.


Problem is in the macro "let*mt-sign" of m.tmac.

One possible revision of this macro is given on line 73ff of the attached file.  Delete the ".ig" at line 74 to test it.

Werner LEMBERG <wl>
Group administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #16285:  test-sig.mm added by wl (4KiB - text/x-troff-mm)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by gbranden (Posted a comment)
  • -email is unavailable- added by schwarze (Updated the item)
  • -email is unavailable- added by wl (Submitted the item)
  • -email is unavailable- added by wl
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 16 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-12-19 gbranden StatusIn Progress Fixed
        Open/ClosedOpen Closed
    2022-12-17 gbranden StatusConfirmed In Progress
        Assigned toNone gbranden
        Planned ReleaseNone 1.23.0
        Summary[mm] signature (SG) under MT 5 (external letter) [mm] signature (SG) under MT 5 (external letter) puts spurious hyphens in output
    2021-06-04 barx Carbon-CopyRemoved 93119 -
    2021-06-04 barx Summarymm macros -- signature (SG) under MT 5 (external letter) [mm] signature (SG) under MT 5 (external letter)
    2021-04-14 barx Carbon-CopyRemoved 93119 -
    2021-04-14 barx Assigned tombianchi None
    2018-02-16 schwarze CategoryNone Macro mm
        Severity3 - Normal 2 - Minor
        Item GroupNone Incorrect behaviour
        StatusNone Confirmed
    2008-08-12 wl Attached File- Added test-sig.mm, #16285
        Carbon-Copy- Added john rupley <rupley@u.arizona.edu>

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code