ref: c7c03b58d38c1be91e1bee9f3cb22eddee3a46aa
parent: 2172c4b1a72bf8a7870eb263bf5f5c35ba50d38d
author: Ali Gholami Rudi <ali@rudi.ir>
date: Thu Apr 18 12:18:38 EDT 2013
ren: add .ns and .rs
--- a/ren.c
+++ b/ren.c
@@ -16,6 +16,7 @@
int prev_d; /* previous \(.d value */
int prev_h; /* previous \(.h value */
int prev_mk; /* previous .mk internal register */
+ int prev_ns; /* previous .ns value */
};
static struct div divs[NPREV]; /* diversion stack */
static struct div *cdiv; /* current diversion */
@@ -62,18 +63,20 @@
memset(cdiv, 0, sizeof(*cdiv));
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));
sbuf_append(&cdiv->sbuf, DIV_BEG "\n");
+ ren_f = 0;
+ ren_s = 0;
+ cdiv->prev_d = n_d;
+ cdiv->prev_h = n_h;
+ cdiv->prev_mk = n_mk;
+ cdiv->prev_ns = n_ns;
n_d = 0;
n_h = 0;
n_mk = 0;
- ren_f = 0;
- ren_s = 0;
+ n_ns = 0;
} else if (cdiv) {
sbuf_putnl(&cdiv->sbuf);
sbuf_append(&cdiv->sbuf, DIV_END "\n");
@@ -84,6 +87,7 @@
n_d = cdiv->prev_d;
n_h = cdiv->prev_h;
n_mk = cdiv->prev_mk;
+ n_ns = cdiv->prev_ns;
cdiv = cdiv > divs ? cdiv - 1 : NULL;
ren_f = 0;
ren_s = 0;
@@ -237,14 +241,16 @@
prev_d = n_d;
if (els_neg)
ren_sp(-els_neg);
- ren_sp(0);
- out_line(out, w, ll, li, lt);
+ if (!n_ns || w || els_neg || els_pos) {
+ ren_sp(0);
+ out_line(out, w, ll, li, lt);
+ n_ns = 0;
+ }
if (els_pos)
ren_sp(els_pos);
if (!ren_traps(prev_d, n_d, 0))
ren_pagelimit(0);
- if (els_pos >= 0)
- n_a = els_pos;
+ n_a = els_pos;
}
}
@@ -258,7 +264,8 @@
{
if (args[0][0] == '.')
ren_br(1);
- down(args[1] ? eval(args[1], 0, 'v') : n_v);
+ if (!n_ns)
+ down(args[1] ? eval(args[1], 0, 'v') : n_v);
}
void tr_sv(char **args)
@@ -271,6 +278,16 @@
n_sv = n;
}
+void tr_ns(char **args)
+{
+ n_ns = 1;
+}
+
+void tr_rs(char **args)
+{
+ n_ns = 0;
+}
+
void tr_os(char **args)
{
if (n_sv)
@@ -302,7 +319,7 @@
void tr_bp(char **args)
{
- if (!cdiv) {
+ if (!cdiv && (args[1] || !n_ns)) {
bp_force = 1;
if (args[1])
bp_next = eval(args[1], n_pg, 0);
--- a/tr.c
+++ b/tr.c
@@ -474,6 +474,7 @@
{"ne", tr_ne},
{"nf", tr_nf},
{"nr", tr_nr, mkargs_reg1},
+ {"ns", tr_ns},
{"os", tr_os},
{"pl", tr_pl},
{"pn", tr_pn},
@@ -482,6 +483,7 @@
{"rm", tr_rm},
{"rn", tr_rn},
{"rr", tr_rr},
+ {"rs", tr_rs},
{"rt", tr_rt},
{"so", tr_so},
{"sp", tr_sp},
--- a/xroff.h
+++ b/xroff.h
@@ -131,9 +131,11 @@
void tr_mk(char **args);
void tr_ne(char **args);
void tr_nf(char **args);
+void tr_ns(char **args);
void tr_os(char **args);
void tr_pn(char **args);
void tr_ps(char **args);
+void tr_rs(char **args);
void tr_rt(char **args);
void tr_sp(char **args);
void tr_sv(char **args);
@@ -212,6 +214,7 @@
#define n_l0 (*nreg(REG(0, 'l'))) /* last .l */
#define n_mk (*nreg(REG(0, 'm'))) /* .mk internal register */
#define n_na (*nreg(REG(0, 'n'))) /* .na mode */
+#define n_ns (*nreg(REG(0, 'N'))) /* .ns mode */
#define n_o0 (*nreg(REG(0, 'o'))) /* last .o */
#define n_s0 (*nreg(REG(0, 's'))) /* last .s */
#define n_sv (*nreg(REG(0, 'S'))) /* .sv value */