ref: 3f75e6b03cac20d823466414ad8d72dc02232e26
parent: efde0d26267c0cc73323abd95d5fa5357383ecf1
author: Ali Gholami Rudi <[email protected]>
date: Thu Jul 25 12:10:18 EDT 2013
ren: add .it
--- a/reg.c
+++ b/reg.c
@@ -29,6 +29,7 @@
"ln", ".f", ".i", ".j", ".l",
".L", ".nI", ".nm", ".nM", ".nn",
".nS", ".m", ".s", ".u", ".v",
+ ".it", ".itn",
"\0c", "\0f", "\0h", "\0i", "\0l",
"\0L", "\0n", "\0m", "\0p", "\0s",
"\0t", "\0T", "\0v",
--- a/ren.c
+++ b/ren.c
@@ -935,6 +935,8 @@
}
if (c == '\n' || ren_nl) /* end or start of input line */
n_lb = f_hpos();
+ if (c == '\n' && n_it && --n_itn == 0)
+ trap_exec(n_it);
if (c == '\n' && !wb_part(wb))
n_ce = MAX(0, n_ce - 1);
if (c != ' ') {
--- a/roff.h
+++ b/roff.h
@@ -332,6 +332,8 @@
#define n_f (*nreg(REG('.', 'f')))
#define n_h (*nreg(REG('.', 'h')))
#define n_i (*nreg(REG('.', 'i')))
+#define n_it (*nreg(map(".it"))) /* .it trap macro */
+#define n_itn (*nreg(map(".itn"))) /* .it lines left */
#define n_j (*nreg(REG('.', 'j')))
#define n_l (*nreg(REG('.', 'l')))
#define n_L (*nreg(REG('.', 'L')))
--- a/tr.c
+++ b/tr.c
@@ -481,6 +481,16 @@
dev_setbd(dev_pos(args[1]), args[2] ? eval(args[2], 'u') : 0);
}
+static void tr_it(char **args)
+{
+ if (args[2]) {
+ n_it = map(args[2]);
+ n_itn = eval(args[1], 0);
+ } else {
+ n_it = 0;
+ }
+}
+
static char *arg_regname(char *s, int len)
{
char *e = n_cp ? s + 2 : s + len;
@@ -687,6 +697,7 @@
{"if", tr_if, mkargs_null},
{"ig", tr_ig},
{"in", tr_in},
+ {"it", tr_it},
{"kn", tr_kn},
{"lg", tr_lg},
{"ll", tr_ll},