ref: 2172c4b1a72bf8a7870eb263bf5f5c35ba50d38d
parent: 2a1f13657e6ae1eb707f00f5af95a9f4164e35fd
author: Ali Gholami Rudi <ali@rudi.ir>
date: Thu Apr 18 09:04:13 EDT 2013
ren: add .sv and .os
--- a/ren.c
+++ b/ren.c
@@ -171,7 +171,7 @@
static int ren_traps(int beg, int end, int dosp)
{
int pos = trap_pos(beg);
- if (pos >= 0 && pos < n_p && pos <= end) {
+ if (pos >= 0 && (cdiv || pos < n_p) && pos <= end) {
if (dosp && pos > beg)
ren_sp(pos - beg);
trap_exec(trap_reg(beg));
@@ -259,6 +259,23 @@
if (args[0][0] == '.')
ren_br(1);
down(args[1] ? eval(args[1], 0, 'v') : n_v);
+}
+
+void tr_sv(char **args)
+{
+ int n = eval(args[1], 0, 'v');
+ n_sv = 0;
+ if (n_d + n < f_nexttrap())
+ down(n);
+ else
+ n_sv = n;
+}
+
+void tr_os(char **args)
+{
+ if (n_sv)
+ down(n_sv);
+ n_sv = 0;
}
void tr_mk(char **args)
--- a/tr.c
+++ b/tr.c
@@ -474,6 +474,7 @@
{"ne", tr_ne},
{"nf", tr_nf},
{"nr", tr_nr, mkargs_reg1},
+ {"os", tr_os},
{"pl", tr_pl},
{"pn", tr_pn},
{"po", tr_po},
@@ -484,6 +485,7 @@
{"rt", tr_rt},
{"so", tr_so},
{"sp", tr_sp},
+ {"sv", tr_sv},
{"ti", tr_ti},
{"tm", tr_tm, mkargs_eol},
{"vs", tr_vs},
--- a/xroff.h
+++ b/xroff.h
@@ -131,10 +131,12 @@
void tr_mk(char **args);
void tr_ne(char **args);
void tr_nf(char **args);
+void tr_os(char **args);
void tr_pn(char **args);
void tr_ps(char **args);
void tr_rt(char **args);
void tr_sp(char **args);
+void tr_sv(char **args);
void tr_ti(char **args);
void tr_wh(char **args);
@@ -212,6 +214,7 @@
#define n_na (*nreg(REG(0, 'n'))) /* .na 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 */
#define n_v0 (*nreg(REG(0, 'v'))) /* last .v */
/* functions for implementing read-only registers */