ref: 8c8d21bd37126715c33a0ce5e3d04aa3b0a2b69a
parent: 8826dc408b2d84b4b5d987541a4fac21d3cd6e32
author: Ali Gholami Rudi <ali@rudi.ir>
date: Wed Apr 17 10:18:05 EDT 2013
ren: add \n(.h
--- a/ren.c
+++ b/ren.c
@@ -10,11 +10,12 @@
struct div {
struct sbuf sbuf; /* diversion output */
int reg; /* diversion register */
+ int tpos; /* diversion trap position */
+ int treg; /* diversion trap register */
int dl; /* diversion width */
int prev_d; /* previous \(.d value */
+ int prev_h; /* previous \(.h value */
int prev_mk; /* previous .mk internal register */
- int tpos; /* diversion trap position */
- int treg; /* diversion trap register */
};
static struct div divs[NPREV]; /* diversion stack */
static struct div *cdiv; /* current diversion */
@@ -62,12 +63,15 @@
sbuf_init(&cdiv->sbuf);
cdiv->reg = REG(args[1][0], args[1][1]);
cdiv->prev_d = n_d;
+ cdiv->prev_h = n_h;
cdiv->prev_mk = n_mk;
cdiv->treg = -1;
if (args[0][2] == 'a' && str_get(cdiv->reg)) /* .da */
sbuf_append(&cdiv->sbuf, str_get(cdiv->reg));
- n_d = 0;
sbuf_append(&cdiv->sbuf, DIV_BEG "\n");
+ n_d = 0;
+ n_h = 0;
+ n_mk = 0;
ren_f = 0;
ren_s = 0;
} else if (cdiv) {
@@ -78,6 +82,7 @@
n_dl = cdiv->dl;
n_dn = n_d;
n_d = cdiv->prev_d;
+ n_h = cdiv->prev_h;
n_mk = cdiv->prev_mk;
cdiv = cdiv > divs ? cdiv - 1 : NULL;
ren_f = 0;
@@ -111,6 +116,7 @@
{
n_nl = 0;
n_d = 0;
+ n_h = 0;
n_pg = pg;
bp_next = n_pg + 1;
OUT("p%d\n", pg);
@@ -132,6 +138,8 @@
if (!n && ren_div && !n_u)
return;
n_d += n ? n : n_v;
+ if (n_d > n_h)
+ n_h = n_d;
if (cdiv) {
sbuf_putnl(&cdiv->sbuf);
sprintf(cmd, "'sp %du\n", n ? n : n_v);
--- a/xroff.h
+++ b/xroff.h
@@ -189,6 +189,7 @@
#define n_a (*nreg(REG('.', 'a')))
#define n_d (*nreg(REG('.', 'd')))
#define n_f (*nreg(REG('.', 'f')))
+#define n_h (*nreg(REG('.', 'h')))
#define n_i (*nreg(REG('.', 'i')))
#define n_j (*nreg(REG('.', 'j')))
#define n_k (*nreg(REG('.', 'k')))