diff -dpru --unidirectional-new-file groff/contrib/hdtbl/examples/chess_board.roff new-groff/contrib/hdtbl/examples/chess_board.roff
--- groff/contrib/hdtbl/examples/chess_board.roff	2022-06-09 01:21:02.000000000 +0000
+++ new-groff/contrib/hdtbl/examples/chess_board.roff	2022-06-09 01:08:27.000000000 +0000
@@ -43,7 +43,7 @@ along with this program.  If not, see <h
 ..
 .af *y a
 .H Chessboard
-.TBL border=0 csp=.05n bgc= cols=10 width=1.6c tal=c
+.TBL border=0 csp=.05n bgc= cols=10 width=1.5c tal=c
 .TR vl= hal=c\" height=1c
 .TD hl=
 .nr *y 0
diff -dpru --unidirectional-new-file groff/contrib/hdtbl/hdmisc.tmac new-groff/contrib/hdtbl/hdmisc.tmac
--- groff/contrib/hdtbl/hdmisc.tmac	2022-06-09 01:21:02.000000000 +0000
+++ new-groff/contrib/hdtbl/hdmisc.tmac	2022-06-09 01:19:56.000000000 +0000
@@ -23,8 +23,12 @@ along with this program.  If not, see <h
 ..
 .
 .
-.if d t*getarg \
+.\" %beginstrip%
+.
+.if d t*getarg \{\
+.  tm \n[.F]: File has already been read, skip it now.
 .  nx
+.\}
 .
 .
 .\"	******************************************************************
@@ -156,7 +160,12 @@ along with this program.  If not, see <h
 .  length $2 \\$2
 .  nr * 0-1 1
 .
-.  while (\\n+[*] < \\n[**]) \{\
+.  if \\n[$2]>\\n[**] \{\
+.    nr t*index 0
+.    return
+.  \}
+.
+.  while (\\n+[*] < (\\n[**]-\\n[$2]) ) \{\
 .    ds * \\$1\"
 .    substring * \\n[*] (\\n[*] + \\n[$2] - 1)
 .    \" The surrounding \? escapes emulate string comparison.
@@ -164,7 +173,7 @@ along with this program.  If not, see <h
 .      break
 .  \}
 .
-.  ie (\\n[*] == \\n[**]) \
+.  ie (\\n[*] == (\\n[**]-\\n[$2]) ) \
 .    nr t*index 0
 .  el \
 .    nr t*index (\\n[*] + 1)
@@ -181,6 +190,13 @@ along with this program.  If not, see <h
 .\"	**	Seitenanfang zurueckgesetzt.				**
 .\"	**	ganz richtig ist .sp + .br = .br + .sp = .sp		**
 .\"	******************************************************************
+.\" Initialize register '<<'.  The meaning is unknown.  It is only
+.\"   used once (undefined) in the macro "t*SP".
+.if !r<< .nr << 0
+.
+.\" Initialize register 'M#'
+.nr M# 0
+.
 .de t*SP
 .  if (\\n[nl] < 0) \
 .    br			\"	start very first page
@@ -296,7 +312,10 @@ along with this program.  If not, see <h
 .de t*DI
 .  nr * \\n[.u]
 .  nf		\"	diversion is already formatted - output it unchanged
-.  \\$1		\"	output the diversion ...
+.\" Avoid getting a tab character added to the argument, otherwise
+.\" (with groff -ww):
+.\" troff: ... warning: tab character in unquoted macro argument
+.  \\$1\"	\"	output the diversion ...
 .  rm \\$1	\"	... and remove it
 .  if \\n[*] \
 .    fi		\"	reactivate formatting
@@ -325,3 +344,4 @@ along with this program.  If not, see <h
 .\" fill-column: 72
 .\" End:
 .\" vim: set filetype=groff textwidth=72:
+.tm The filename of the used macro file is \n[.F]
diff -dpru --unidirectional-new-file groff/contrib/hdtbl/hdtbl.tmac new-groff/contrib/hdtbl/hdtbl.tmac
--- groff/contrib/hdtbl/hdtbl.tmac	2022-06-09 01:21:02.000000000 +0000
+++ new-groff/contrib/hdtbl/hdtbl.tmac	2022-06-09 01:19:56.000000000 +0000
@@ -22,14 +22,17 @@ along with this program.  If not, see <h
 
 ..
 .
+.\" %beginstrip%
 .
 .\"	*****************************************************************
 .\"	*		hdtbl - Heidelberger table macros		*
 .\"	*			Vers. 0.91 December 2005		*
 .\"	*****************************************************************
 .
-.if d TBL \
+.if d TBL \{\
+.  tm \n[.F]: File has already been read, skip it now.
 .  nx
+.\}
 .
 .mso hdmisc.tmac
 .mso 62bit.tmac
@@ -67,7 +70,6 @@ along with this program.  If not, see <h
             ".ad l" \
             "\m[\\*[t*fgc]]Table \\n+[t*cptn]:\0\k*\c"\"
 .
-.
 .\" for better error messages
 .ds nth-1 st\"
 .ds nth-2 nd\"
@@ -78,6 +80,8 @@ along with this program.  If not, see <h
 .nr t*numb 0 1	\"	held table diversion #
 .
 .ds *#trc*
+.ds t*held
+.ds t*kept
 .
 .
 .\"	*****************************************************************
@@ -368,18 +372,19 @@ along with this program.  If not, see <h
 .  nr * 0 1
 .  nr *r \\n[t*r#\\n[t*#]]
 .
-.  if (\\n[rowspan] - 1) \
+.  if (\\n[rowspan] - 1) \{\
 .    while (\\n+[*] <= \\n[rowspan]) \{\
 .      nr rspan\\n[t*#]*\\n[*r]*\\n[c#\\*[#t#r]] \\n[colspan]
 .      if (\\n[*] > 1) \
 .        nr cspan\\n[t*#]*\\n[*r]*\\n[c#\\*[#t#r]] \\n[colspan]
 .      nr *r +1
 .    \}
+.  \}
 .
 .  nr * 1 1
 .  nr *c \\n[c#\\*[#t#r]]
 .
-.  if (\\n[colspan] - 1) \{\
+.  ie (\\n[colspan] - 1) \{\
 .    nr vline\\*[*#trc*] 0-1		\"	set 'no vl' flag
 .
 .    while (\\n+[*] <= \\n[colspan]) \{\
@@ -390,6 +395,8 @@ along with this program.  If not, see <h
 .      nr c#\\*[#t#r] +1
 .    \}
 .  \}
+.  el \
+.    nr vline\\*[*#trc*] 0
 .
 .  if (\\n[c#\\n[t*#]*\\n[t*r#\\n[t*#]]] > \\n[t*cols\\n[t*#]]) \{\
 .    ds * are\"
@@ -452,9 +459,12 @@ along with this program.  If not, see <h
 .  t*divs                        \"	print this table
 .
 .  sp \\n[b/2\\n[t*#]]u
-.  t*cptn\\n[t*#]
+.  if d t*cptn\\n[t*#] \
+.    t*cptn\\n[t*#]
 .  nr t*# -1
 .
+.  if !r *cl\\n[t*#] \
+.    nr *cl\\n[t*#] \\n[.H]u     \"     line length must now be non-null
 .  ll \\n[*cl\\n[t*#]]u          \"	restore ll outside this table
 .  in 0                          \"	reset indent
 .  gcolor \\*[t*m\\n[t*#]]       \"	reset previous fgc
@@ -469,16 +479,16 @@ along with this program.  If not, see <h
 .        t*DI t*tbl0
 .      el \{\
 .        rn t*tbl0 t*tbl\\n+[t*numb]
-.        ds t*kept \\*[t*kept] t*tbl\\n[t*numb] \\n[dn]\"
+.        as t*kept " t*tbl\\n[t*numb] \\n[dn]\"
 .      \}
 .    \}
 .    el \{\
 .      rn t*tbl0 t*hold\\n+[t*numb]
 .      tm \\n[.F]:\\n[.c]: Table t*hold\\n[t*numb] held.
-.      ds t*held \\*[t*held] t*hold\\n[t*numb] \\n[dn]\"
+.      as t*held " t*hold\\n[t*numb] \\n[dn]\"
 .    \}
 .
-.    ev				\"	restore previous environment
+.    ev\"				\"	restore previous environment
 .  \}
 .
 .  t*P1 \\*[args]
@@ -523,7 +533,7 @@ along with this program.  If not, see <h
 .    \}
 .    el \{\
 .      rn \\*[*] t*tbl\\n+[t*numb]
-.      ds t*kept \\*[t*kept] t*tbl\\n[t*numb] \\n[*]\"
+.      as t*kept " t*tbl\\n[t*numb] \\n[*]\"
 .    \}
 .
 .    if !(\\n-[**] - 1) \
@@ -556,6 +566,8 @@ along with this program.  If not, see <h
 .  while (\\n+[#r] <= \\n[t*r#\\n[t*#]]) \{\
 .    \" TODO: insert code here for multipage tables
 .    nr * (\\n[#r] - 1)
+.    if !r dntr\\n[t*#]*\\n[*] \
+.      nr dntr\\n[t*#]*\\n[*] 0
 .    nr topdiv +(\\n[dntr\\n[t*#]*\\n[*]] + \\n[cscp] + \\n[cscpb])
 .
 .    \" if table still smaller than specified table height, increase it
@@ -579,6 +591,8 @@ along with this program.  If not, see <h
 .
 .      \" if we have spanned rows, calculate resulting row height
 .      \" and position of lower horizontal line
+.      if !r *rsp*\\*[#trc] \
+.        nr *rsp*\\*[#trc] 0
 .      if \\n[*rsp*\\*[#trc]] \{\
 .        nr * \\n[#r] 1
 .        nr rspan\\*[#trc] 0-1		\"	set 'no hl' flag
@@ -604,6 +618,8 @@ along with this program.  If not, see <h
 .
 .      \" paint cell background
 .      nr * (2 * \\n[t*cpd\\n[t*#]] + \\n[cll\\*[#trc]])\"	background width
+.      if !r dn\\*[#trc] \
+.        nr dn\\*[#trc] 0
 .      nr $1 (\\n[$1] >? \\n[dn\\*[#trc]])\"	cell height
 .
 .      if !"\\*[t*bgc\\*[#trc]]"=" \{\
@@ -632,6 +648,8 @@ along with this program.  If not, see <h
 .      if (1 + \\n[t*b\\n[t*#]]) \{\
 .        if !"\\*[t*bc\\n[t*#]]"=" \{\
 .          \" draw horizontal line between this cell and the one below
+.          if !r rspan\\*[#trc] \
+.            nr rspan\\*[#trc] 0
 .          if (\\n[t*r#\\n[t*#]] - \\n[#r] + \\n[rspan\\*[#trc]]) \{\
 .            if !"\\*[t*hl\\*[#trc]]"=" \{\
 .              sp \\n[$1]u
@@ -753,7 +771,7 @@ along with this program.  If not, see <h
 .        ie \B\\$[\\n[*]] \
 .          nr $\\n[*] \\$[\\n[*]]
 .        el \
-.          tm \\n[.F]:\\n[.c]: Invalid cell width '\\$[\\n[*]]'.
+.          tm \\n[.F]:\\n[.c]: Invalid cell width '\\$h[\\n[*]]'.
 .    \}\}
 .
 .    nr ll\\n[t*#] +\\n[$\\n[*]]
@@ -822,8 +840,10 @@ along with this program.  If not, see <h
 .  ds #t#r \\n[t*#]*\\n[t*r#\\n[t*#]]\"		refresh table row identifier
 .
 .  if \\n[c#\\*[#t#r]] \{\
-.    di					\"	close diversion
+.    di\"					\"	close diversion
 .    nr dn\\$4 \\n[dn]			\"	save height of this cell
+.    if !r rspan\\*[#trc] \
+.      nr rspan\\*[#trc] 0
 .    if !\\n[rspan\\*[#trc]] \{\
 .      \" update row height if not in a row span
 .      nr dntr\\*[#t#r] (\\n[dntr\\*[#t#r]] >? \\n[dn])
@@ -1001,3 +1021,4 @@ along with this program.  If not, see <h
 .\" mode: nroff
 .\" End:
 .\" vim: filetype=groff:
+.tm The filename of the used macro file is \n[.F]
