NetBSD Problem Report #58074

From www@netbsd.org  Sun Mar 24 15:17:28 2024
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 050B41A9239
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 24 Mar 2024 15:17:28 +0000 (UTC)
Message-Id: <20240324151726.856DF1A923A@mollari.NetBSD.org>
Date: Sun, 24 Mar 2024 15:17:26 +0000 (UTC)
From: uwe@stderr.spb.ru
Reply-To: uwe@stderr.spb.ru
To: gnats-bugs@NetBSD.org
Subject: .Lk mishandles missing anchor-text
X-Send-Pr-Version: www-1.0

>Number:         58074
>Category:       bin
>Synopsis:       .Lk mishandles missing anchor-text
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Mar 24 15:20:00 +0000 2024
>Closed-Date:    Mon Mar 25 16:36:38 +0000 2024
>Last-Modified:  Mon Mar 25 16:36:38 +0000 2024
>Originator:     Valery Ushakov
>Release:        NetBSD 10
>Organization:
>Environment:
NetBSD snips 10.0_RC3 NetBSD 10.0_RC3 (GENERIC) #0: Wed Jan 17 21:22:02 MSK 2024  uwe@majava:/home/uwe/work/netbsd/cvs/src-release-10/sys/arch/macppc/compile/GENERIC macppc

>Description:
From source code inspection .Lk with a missing anchor-text but with
the trailing punctuation is intended to do the right thing, but
doesn't.  E.g. in distrib/notes/common/main

revision 1.574
date: 2024-03-24 16:18:02 +0300;  author: martin;  state: Exp;  lines: +3 -4;  commitid: caZuafzIoIV5Mp3F;
Use single-arg "Lk" macro for a link so we can get reasonable results
both in .more and .html output (still a bit odd, but better than before IMHO).

had to drop the trainling dot from what should have been

  .Lk https://www.NetBSD.org/ .

b/c the above is currently misformatted as:

  For more information please visit .: https://www.NetBSD.org/

instead of

  For more information please visit https://www.NetBSD.org/.

>How-To-Repeat:
Use

  .Lk http://some/url .

in a mdoc document.

>Fix:
From a quick source code inspection Lk seems to have the intention to
handle the above properly.  The Lk macro is defined to

  .de Lk
  .  ds doc-str-Lk Sy \$@
  .
  .  ie (\n[.$] > 1) \{\
  .    doc-get-arg-type \$2
  .    ie (\n[doc-arg-type] < 3) \{\
  .      Em \)\$2:
  .      ds doc-str-Lk Sy "\$1"
  .      doc-get-width "\$1"
  .      shift 2
  .      if \n[.$] \
  .        as doc-str-Lk " \$@
  .    \}
  .    el \
  .      doc-get-width "\$1"
  .  \}
  .  el \
  .    doc-get-width "\$1"

i.e. if the second argument is a punctuation (doc-arg-type is 3 or
more), it is not treated as an anchor-text (cf. the top-level else for
the case of just one argument).

The bug seems to be that while the doc-get-arg-type is documented to
expect the width of the argument in `doc-width', Lk doesn't do that
(cf. other uses of these macros elsewhere in doc.tmac).  The fix is
probably just:

--- doc.tmac.~1.2.~	2016-01-13 22:01:59.000000000 +0300
+++ doc.tmac	2024-03-24 18:12:18.401745081 +0300
@@ -6416,6 +6416,7 @@
 .  ds doc-str-Lk Sy \$@
 .
 .  ie (\n[.$] > 1) \{\
+.    doc-get-width \$2
 .    doc-get-arg-type \$2
 .    ie (\n[doc-arg-type] < 3) \{\
 .      Em \)\$2:

which seems to do the right thing for the release notes with

  .Lk https://www.NetBSD.org/ .

in distrib/notes/common/main, getting

  <a href="https://www.NetBSD.org/">https://www.NetBSD.org/</a>.

and

    https://www.NetBSD.org/.

(with the url in bold and dot not in bold).

>Release-Note:

>Audit-Trail:
From: Valery Ushakov <uwe@stderr.spb.ru>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: bin/58074: .Lk mishandles missing anchor-text
Date: Mon, 25 Mar 2024 02:24:23 +0300

 We have such .Lk instances in several man pages, e.g. mq_open(3) or
 iwctl(8).  mandoc(1) formats them as expected, but groff's mdoc adds
 the bogus ".:"

 Surprisingly, savecore(8) has an instance of this as well but groff
 formats it correctly, probably doc-width (a global variable) just
 happens to have the right value by luck in that specific point in the
 document (that same .Lk does get formatted incorrectly if put in
 another location).

 -uwe

From: "Valery Ushakov" <uwe@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/58074 CVS commit: src/external/gpl2/groff/dist/tmac
Date: Sun, 24 Mar 2024 23:39:21 +0000

 Module Name:	src
 Committed By:	uwe
 Date:		Sun Mar 24 23:39:21 UTC 2024

 Modified Files:
 	src/external/gpl2/groff/dist/tmac: doc.tmac

 Log Message:
 doc.tmac: .Lk - handle punctuation without anchor-text correctly

 doc-get-arg-type expects that doc-width is set beforehand, so call
 doc-get-width to make sure doc-get-arg-type detects the trailing
 punctuation correctly.

 PR bin/58074


 To generate a diff of this commit:
 cvs rdiff -u -r1.2 -r1.3 src/external/gpl2/groff/dist/tmac/doc.tmac

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Valery Ushakov" <uwe@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/58074 CVS commit: src/distrib/notes/common
Date: Mon, 25 Mar 2024 13:35:29 +0000

 Module Name:	src
 Committed By:	uwe
 Date:		Mon Mar 25 13:35:28 UTC 2024

 Modified Files:
 	src/distrib/notes/common: main

 Log Message:
 distrib/notes: add back the sentence final dot after .Lk

 It was omitted in previous b/c of a bug in .Lk that was fixed
 in PR bin/58074


 To generate a diff of this commit:
 cvs rdiff -u -r1.574 -r1.575 src/distrib/notes/common/main

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/58074 CVS commit: [netbsd-10] src
Date: Mon, 25 Mar 2024 15:23:50 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Mon Mar 25 15:23:50 UTC 2024

 Modified Files:
 	src/distrib/notes/common [netbsd-10]: main
 	src/external/gpl2/groff/dist/tmac [netbsd-10]: doc.tmac

 Log Message:
 Pull up following revision(s) (requested by uwe in ticket #646):

 	external/gpl2/groff/dist/tmac/doc.tmac: revision 1.3
 	distrib/notes/common/main: revision 1.575

 doc.tmac: .Lk - handle punctuation without anchor-text correctly
 doc-get-arg-type expects that doc-width is set beforehand, so call
 doc-get-width to make sure doc-get-arg-type detects the trailing
 punctuation correctly.
 PR bin/58074

 distrib/notes: add back the sentence final dot after .Lk
 It was omitted in previous b/c of a bug in .Lk that was fixed
 in PR bin/58074


 To generate a diff of this commit:
 cvs rdiff -u -r1.570.2.4 -r1.570.2.5 src/distrib/notes/common/main
 cvs rdiff -u -r1.2 -r1.2.26.1 src/external/gpl2/groff/dist/tmac/doc.tmac

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/58074 CVS commit: [netbsd-9] src/external/gpl2/groff/dist/tmac
Date: Mon, 25 Mar 2024 15:51:47 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Mon Mar 25 15:51:47 UTC 2024

 Modified Files:
 	src/external/gpl2/groff/dist/tmac [netbsd-9]: doc.tmac

 Log Message:
 Pull up following revision(s) (requested by uwe in ticket #1823):

 	external/gpl2/groff/dist/tmac/doc.tmac: revision 1.3

 doc.tmac: .Lk - handle punctuation without anchor-text correctly
 doc-get-arg-type expects that doc-width is set beforehand, so call
 doc-get-width to make sure doc-get-arg-type detects the trailing
 punctuation correctly.

 PR bin/58074


 To generate a diff of this commit:
 cvs rdiff -u -r1.2 -r1.2.18.1 src/external/gpl2/groff/dist/tmac/doc.tmac

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/58074 CVS commit: [netbsd-8] src/external/gpl2/groff/dist/tmac
Date: Mon, 25 Mar 2024 15:58:08 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Mon Mar 25 15:58:08 UTC 2024

 Modified Files:
 	src/external/gpl2/groff/dist/tmac [netbsd-8]: doc.tmac

 Log Message:
 Pull up following revision(s) (requested by uwe in ticket #1952):

 	external/gpl2/groff/dist/tmac/doc.tmac: revision 1.3

 doc.tmac: .Lk - handle punctuation without anchor-text correctly
 doc-get-arg-type expects that doc-width is set beforehand, so call
 doc-get-width to make sure doc-get-arg-type detects the trailing
 punctuation correctly.

 PR bin/58074


 To generate a diff of this commit:
 cvs rdiff -u -r1.2 -r1.2.8.1 src/external/gpl2/groff/dist/tmac/doc.tmac

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: uwe@NetBSD.org
State-Changed-When: Mon, 25 Mar 2024 16:36:38 +0000
State-Changed-Why:
Fixed and pulled up.
.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2024 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.