source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mandoc: Rudimentatary implementation of the read-only number register
@ 2025-01-03 16:34 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2025-01-03 16:34 UTC (permalink / raw)
  To: source

Log Message:
-----------
Rudimentatary implementation of the read-only number register \(.l,
which is supposed to contain the line length in basic units,
by setting it to a constant width of 78 characters,
no matter what the output width (-O width) is actually set to.

This occurs in man(7) code produced by DocBook XSL, for example 
in DocBook XSL version 1.79.2, and hence it shows up in real-world 
manual pages.  For example, tb@ reported finding it in git-reset(1) 
last year.

Of course, setting this register to a constant value defeats the very
purpose the register is supposed to serve in the first place.
However, the most fundamental design principle of mandoc(1) is that
the parse tree is independent of the output mode.  That's not merely
a technical restriction but helps to make sure that the *content* of
documentation shown to the user does not depend on the output mode.
So allowing this register to depend on the "-O width" argument would
result in a layering violation that might, in the worst case,
cause a reliability issue.

Modified Files:
--------------
    mandoc:
        roff.c
    mandoc/regress/roff/nr:
        predef.in
        predef.out_ascii

Revision Data
-------------
Index: roff.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/roff.c,v
diff -Lroff.c -Lroff.c -u -p -r1.400 -r1.401
--- roff.c
+++ roff.c
@@ -1,6 +1,6 @@
 /* $Id$ */
 /*
- * Copyright (c) 2010-2015, 2017-2023 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010-2015, 2017-2024 Ingo Schwarze <schwarze@openbsd.org>
  * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
  *
  * Permission to use, copy, modify, and distribute this software for any
@@ -3062,6 +3062,8 @@ roff_getregro(const struct roff *r, cons
 		return 24;
 	case 'j':  /* Always adjust left margin only. */
 		return 0;
+	case 'l':  /* Fixed line width for DocBook. */
+		return 78 * 24;
 	case 'T':  /* Some output device is always defined. */
 		return 1;
 	case 'V':  /* Fixed vertical resolution. */
Index: predef.out_ascii
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/roff/nr/predef.out_ascii,v
diff -Lregress/roff/nr/predef.out_ascii -Lregress/roff/nr/predef.out_ascii -u -p -r1.4 -r1.5
--- regress/roff/nr/predef.out_ascii
+++ regress/roff/nr/predef.out_ascii
@@ -4,14 +4,15 @@ N\bNA\bAM\bME\bE
      nr-predef - pre-defined read-only integer number registers
 
 D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
-     ascii mode: 0
-     groff mode: 1
-     horizontal resolution: 24
-     adjustment mode: 0
-     output device defined: 1 1
-     vertical resolution: 40
+     ascii mode: 0 = off
+     groff mode: 1 = on
+     horizontal resolution: 24 dots per character
+     adjustment mode: 0 = flush left
+     line width: 1872 dots per line
+     output device defined: 1 1 = yes
+     vertical resolution: 40 dots per line
      user defined macro with 0 arguments:
      user defined macro with 1 arguments: one
      user defined macro with 2 arguments: one two
 
-OpenBSD                         August 29, 2015                   NR-PREDEF(1)
+OpenBSD                         January 3, 2025                   NR-PREDEF(1)
Index: predef.in
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/roff/nr/predef.in,v
diff -Lregress/roff/nr/predef.in -Lregress/roff/nr/predef.in -u -p -r1.3 -r1.4
--- regress/roff/nr/predef.in
+++ regress/roff/nr/predef.in
@@ -1,5 +1,5 @@
 .\" $OpenBSD: predef.in,v 1.4 2020/10/24 22:52:34 schwarze Exp $
-.TH NR-PREDEF 1 "August 29, 2015"
+.TH NR-PREDEF 1 "January 3, 2025"
 .SH NAME
 nr-predef \- pre-defined read-only integer number registers
 .SH DESCRIPTION
@@ -11,15 +11,17 @@ user defined macro with \\n(.$ arguments
 .nr .g 111
 .nr .H 111
 .nr .j 111
+.nr .l 111
 .nr .T 111
 .nr .V 111
 .nr .$ 111
-ascii mode: \n(.A
-groff mode: \n(.g
-horizontal resolution: \n(.H
-adjustment mode: \n(.j
-output device defined: \n(.T \n[.T]
-vertical resolution: \n(.V
+ascii mode: \n(.A = off
+groff mode: \n(.g = on
+horizontal resolution: \n(.H dots per character
+adjustment mode: \n(.j = flush left
+line width: \n(.l dots per line
+output device defined: \n(.T \n[.T] = yes
+vertical resolution: \n(.V dots per line
 .mym
 .mym one
 .mym one two
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-01-03 16:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-03 16:34 mandoc: Rudimentatary implementation of the read-only number register schwarze

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).