URL:
  <https://savannah.gnu.org/bugs/?68214>

                 Summary: [mdoc] throws "warning: start and end index of
substring out of range" when using `Bl` with a `-width` of zero
                   Group: GNU roff
               Submitter: gbranden
               Submitted: Mon 06 Apr 2026 05:03:44 AM UTC
                Category: Macro package mdoc
                Severity: 2 - Minor
              Item Group: Warning/Suspicious behaviour
                  Status: In Progress
                 Privacy: Public
             Assigned to: gbranden
             Open/Closed: Open
         Discussion Lock: Unlocked
         Planned Release: None


    _______________________________________________________

Follow-up Comments:


-------------------------------------------------------
Date: Mon 06 Apr 2026 05:03:44 AM UTC By: G. Branden Robinson <gbranden>
Reproducible all the way back to _groff_ 1.22.3.

So not something I broke.  Hooray!


$ sed -n 435p ./pkg/docs/pkg.8
.Bl -tag -width ""
$ ~/groff-1.22.3/bin/nroff -ww -mandoc ./pkg/docs/pkg.8 >/dev/null
./pkg/docs/pkg.8:56: warning [p 1, 2.0i]: can't break line
./pkg/docs/pkg.8:435: warning: start and end index of substring out of range
$ ~/groff-1.22.4/bin/nroff -ww -mandoc ./pkg/docs/pkg.8 >/dev/null
troff: ./pkg/docs/pkg.8:56: warning [p 1, 2.0i]: can't break line
troff: ./pkg/docs/pkg.8:435: warning: start and end index of substring out of
range
$ ~/groff-1.23.0/bin/nroff -ww -mandoc -z ./pkg/docs/pkg.8
troff:./pkg/docs/pkg.8:56: warning [p 1, 2.0i]: cannot break line
troff:./pkg/docs/pkg.8:435: warning: start and end index of substring out of
range
$ ~/groff-1.24.0/bin/nroff -ww -mandoc -z ./pkg/docs/pkg.8
troff:./pkg/docs/pkg.8:56: warning [page 1, line 13]: cannot break line;
overset by 9n
troff:./pkg/docs/pkg.8:435: warning: start and end index of substring out of
range
$ ~/groff-1.24.1/bin/nroff -ww -mandoc -z ./pkg/docs/pkg.8
troff:./pkg/docs/pkg.8:56: warning [page 1, line 13]: cannot break line;
overset by 9n
troff:./pkg/docs/pkg.8:435: warning: start and end index of substring out of
range


Let's get a backtrace:


$ ~/groff-1.24.1/bin/nroff -b -ww -W break -mandoc -z ./pkg/docs/pkg.8
troff: backtrace: 'doc.tmac':3520: macro 'doc-do-Bl-args'
troff: backtrace: 'doc.tmac':3431: macro 'Bl'
troff: backtrace: file './pkg/docs/pkg.8':435
troff:./pkg/docs/pkg.8:435: warning: start and end index of substring out of
range


Here's the macro logic:


$ nl tmac/doc.tmac | sed -n 3517,3535p
  3517  .  el \{ .ie "\*[doc-arg\n[doc-arg-ptr]]"-width" \{\
  3518  .    nr doc-arg-ptr +1
  3519  .    ds doc-str-dBla "\*[doc-arg\n[doc-arg-ptr]]
  3520  .    substring doc-str-dBla 0 0
  3521  .    ie '.'\*[doc-str-dBla]' \{\
  3522  .      ds doc-str-dBla "\*[doc-arg\n[doc-arg-ptr]]
  3523  .      substring doc-str-dBla 1
  3524  .      doc-first-parameter \*[doc-str-dBla]
  3525  .      doc-get-width "\*[doc-str-dfp]
  3526  .      doc-get-arg-type "\*[doc-str-dfp]
  3527  .      ie (\n[doc-arg-type] == 1) \
  3528  .        nr doc-reg-dBla1 1
  3529  .      el \
  3530  .        nr doc-reg-dBla1 0
  3531  .    \}
  3532  .    el \
  3533  .      nr doc-reg-dBla1 0
  3534  .    ds doc-str-dBla "\*[doc-arg\n[doc-arg-ptr]]
  3535  .


Probably want something like this:


$ git diff tmac/
diff --git a/tmac/doc.tmac b/tmac/doc.tmac
index 881ee2381..e6adab890 100644
--- a/tmac/doc.tmac
+++ b/tmac/doc.tmac
@@ -3517,7 +3517,7 @@ .de doc-do-Bl-args
 .  el \{ .ie "\*[doc-arg\n[doc-arg-ptr]]"-width" \{\
 .    nr doc-arg-ptr +1
 .    ds doc-str-dBla "\*[doc-arg\n[doc-arg-ptr]]
-.    substring doc-str-dBla 0 0
+.    if \w'\?\*[doc-str-dBla]\?' .substring doc-str-dBla 0 0
 .    ie '.'\*[doc-str-dBla]' \{\
 .      ds doc-str-dBla "\*[doc-arg\n[doc-arg-ptr]]
 .      substring doc-str-dBla 1


Result?


$ ~/src/GIT/groff/build/test-groff -ww -mandoc -z -T utf8 ./pkg/docs/pkg.8;
echo DONE
troff:./pkg/docs/pkg.8:56: warning [page 1, line 13]: cannot break line;
overset by 9n
DONE









    _______________________________________________________

Reply to this item at:

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

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

Attachment: signature.asc
Description: PGP signature

Reply via email to