bugGNU roff - Bugs: bug #64438, [ms] validation of `PS` macro...

 
 

bug #64438: [ms] validation of `PS` macro arguments too strict

Submitter:  G. Branden Robinson <gbranden>
Submitted:  Mon 17 Jul 2023 10:55:57 PM UTC
   
 
Category:  Macro ms Severity:  4 - Important
Item Group:  Incorrect behaviour Status:  Fixed
Privacy:  Public Assigned to:  gbranden
Open/Closed:  Closed Planned Release:  1.24.0
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 18 Jul 2023 03:03:01 PM UTC, comment #6: 


commit a3deb17968d8a04cf5d2c1df34d59c198d60c4ae
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Mon Jul 17 19:16:56 2023 -0500

    [ms]: Fix Savannah #64438.

    * tmac/s.tmac (@PS): Stop treating excess arguments as erroneous,
      foregoing preparation for pic(1) output.  Fixes regression from groff
      1.22.4.

    Fixes <https://savannah.gnu.org/bugs/?64438>.  Thanks to Doug McIlroy
    for the report, Dave Kemper for root-cause analysis, and Deri James for
    usability feedback.


G. Branden Robinson <gbranden>
Group administrator
Tue 18 Jul 2023 12:42:42 PM UTC, comment #5: 

Good points, Dave and Deri.

I'll drop the second hunk of the patch.

G. Branden Robinson <gbranden>
Group administrator
Tue 18 Jul 2023 10:28:04 AM UTC, comment #4: 

One use for the extra parameters may be for captioning, i.e.

.PS "An example"

The user could then use .am PS to add captioning code to the picture and a pdf bookmark. I'm in favour of silently ignoring excess parameters.

Deri James <deri>
Group Member
Tue 18 Jul 2023 12:27:30 AM UTC, comment #3: 

comment #2:

> Any problem with warning about the excess arguments?  I feel an
> urge to do so because the macro package does nothing with them


Well, silently ignoring extraneous arguments also has a long pedigree, and at least one point in favor: see comment 3 of bug #61450.

Dave <barx>
Group Member
Tue 18 Jul 2023 12:09:26 AM UTC, comment #2: 

To clarify, the bug stops `ne` and `in` requests from being issued for pic pictures.  Omitting the former could cause a picture to be truncated by the bottom of the page.  The latter means that the picture will likely not be correctly centered.

Proposed fix:


diff --git a/tmac/s.tmac b/tmac/s.tmac
index 5fc1237eb..5f9452ee8 100644
--- a/tmac/s.tmac
+++ b/tmac/s.tmac
@@ -2095,7 +2095,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 .de @PS
 .br
 .sp \\n[DD]u
-.ie !\\n[.$]=2 \{\
+.ie \\n[.$]<2 \{\
 .      ds pic*msg .PS: expected 2 arguments, got \\n[.$]\"
 .      as pic*msg ; not preprocessed with pic?\"
 .      @error \\*[pic*msg]
@@ -2105,6 +2105,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 .      ds@need (u;\\$1)+1v
 .      in +(u;\\n[.l]-\\n[.i]-\\$2/2>?0)
 .\}
+.if \\n[.$]>2 \
+.      @warning .PS: ignoring excess arguments
 .HTML-IMAGE
 ..
 .de PF


Any problem with warning about the excess arguments?  I feel an urge to do so because the macro package does nothing with them (DWB 3.3 ms didn't, either).  I wouldn't want a pic/ms user to assume that these extra arguments become a figure caption or something fancy like that.

G. Branden Robinson <gbranden>
Group administrator
Mon 17 Jul 2023 11:48:45 PM UTC, comment #1: 

It doesn't appear that I forgot anything.  Doug is using a vaguely documented interface, apparently one of long pedigree.

CSTR #116 (May 1991 revision) says on p. 18:

> Pic copies the .PS and .PE lines from input to output intact,
> except that it adds two things on the same line as the .PS:
>
> .PS h w
>
> h and w are the picture height and width in units.  The -ms macro
> package has definitions for .PS and .PE that cause pictures to be
> centered and offset a bit from surrounding text.  (See the
> appendix).


(Does "adds" mean "prefixes" or "suffixes" [existing arguments]?  "Prefixes" is what is actually done.)

Consulting the appendix on p. 26, we see:

> This is the default definition of the .PS and .PE macros:
>
> .de PS \" start picture; $1 is height, $2 is width, in inches
> .sp .3
> .in (\\n(.lu-\\$2)/2u
> .ne \\$1
> ..
> .de PE \" end of picture
> .in
> .sp .6
> ..


I'm pretty sure this is what I went by when updating the `@PS` macro definition in groff ms.

Permit me to register my desire to send a Daffy Duck tantrum about this imprecision back to Murray Hill in a DeLorean^W^Wthe 1980s.

Anyway, I'll fix groff ms and add some documentation to our pic(1) page documenting this detail (that arguments to `PS` in the input are shifted, and their interpretation is the province of the macro definition).

G. Branden Robinson <gbranden>
Group administrator
Mon 17 Jul 2023 10:55:57 PM UTC, original submission:  
G. Branden Robinson <gbranden>
Group administrator

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by deri (Posted a comment)
  • -email is unavailable- added by barx (Posted a comment)
  • -email is unavailable- added by gbranden (Submitted the item)
  • -email is unavailable- added by gbranden (original reporter; root-cause analyzer)
  • -email is unavailable- added by gbranden (original reporter; root-cause analyzer)
  •  

    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 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-07-18 gbranden StatusIn Progress Fixed
        Open/ClosedOpen Closed
        Planned ReleaseNone 1.24.0
    2023-07-18 gbranden StatusConfirmed In Progress
    2023-07-17 gbranden StatusNone Confirmed
    2023-07-17 gbranden Carbon-Copy- Added -email is unavailable-
        Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code