ref: b71732ca1b5129e0575afda791300457beb19b5d
parent: 8caa9b49f50c87a48c0981d503f3aad70fcb9571
author: Ali Gholami Rudi <ali@rudi.ir>
date: Fri Apr 26 13:54:00 EDT 2013
in: add .ex and .nx
--- a/in.c
+++ b/in.c
@@ -49,7 +49,7 @@
buf->nl = 1;
}
-void in_source(char *path)
+void in_so(char *path)
{
FILE *fin = path && path[0] ? fopen(path, "r") : stdin;
if (fin) {
@@ -78,10 +78,25 @@
free(old);
}
+void in_nx(char *path)
+{
+ while (buf)
+ in_pop();
+ if (path)
+ in_so(path);
+}
+
+void in_ex(void)
+{
+ while (buf)
+ in_pop();
+ cfile = nfiles;
+}
+
static int in_nextfile(void)
{
while (!buf && cfile < nfiles)
- in_source(files[cfile++]);
+ in_so(files[cfile++]);
return !buf;
}
--- a/tr.c
+++ b/tr.c
@@ -285,9 +285,20 @@
static void tr_so(char **args)
{
if (args[1])
- in_source(args[1]);
+ in_so(args[1]);
}
+static void tr_nx(char **args)
+{
+ if (args[1])
+ in_nx(args[1]);
+}
+
+static void tr_ex(char **args)
+{
+ in_ex();
+}
+
static char *arg_regname(char *s, int len)
{
char *e = s + 2;
@@ -469,6 +480,7 @@
{"dt", tr_dt},
{"el", tr_el, mkargs_null},
{"ev", tr_ev},
+ {"ex", tr_ex},
{"fi", tr_fi},
{"fp", tr_fp},
{"ft", tr_ft},
@@ -484,6 +496,7 @@
{"nf", tr_nf},
{"nr", tr_nr, mkargs_reg1},
{"ns", tr_ns},
+ {"nx", tr_nx},
{"os", tr_os},
{"pl", tr_pl},
{"pn", tr_pn},
--- a/xroff.h
+++ b/xroff.h
@@ -103,19 +103,23 @@
int in_next(void); /* input layer */
int cp_next(void); /* copy-mode layer */
int tr_next(void); /* troff layer */
+
void in_push(char *s, char **args);
void in_pushnl(char *s, char **args);
-void in_source(char *path); /* .so request */
-void in_queue(char *path); /* next input file */
+void in_so(char *path); /* .so request */
+void in_nx(char *path); /* .nx request */
+void in_ex(void); /* .nx request */
+void in_queue(char *path); /* .ex request */
char *in_arg(int i); /* look up argument */
int in_nargs(void); /* number of arguments */
void in_back(int c); /* push back input character */
int in_top(void); /* the first pushed-back character */
char *in_filename(void); /* current filename */
+
void cp_blk(int skip); /* skip or read the next line or block */
void cp_wid(int enable); /* control inlining \w requests */
-void tr_first(void); /* read until the first non-command line */
#define cp_back in_back /* cp.c is stateless */
+void tr_first(void); /* read until the first non-command line */
/* rendering */
void render(void); /* read from in.c and print the output */