summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mdocml.css5
-rw-r--r--mlg.c55
-rw-r--r--roff.c25
-rw-r--r--roff.h42
4 files changed, 103 insertions, 24 deletions
diff --git a/mdocml.css b/mdocml.css
index 61e0bf7a..fb5e79e6 100644
--- a/mdocml.css
+++ b/mdocml.css
@@ -13,6 +13,8 @@
span.inline-Nd:before { content: ' \2014 '; }
span.inline-Fl:before { content: '-'; }
span.inline-Fl { font-weight: bolder; }
+ span.inline-Cm { font-weight: bolder; }
+ span.inline-Cd { font-weight: bolder; }
span.inline-Nm { font-weight: bolder; }
span.inline-Ar { text-decoration: underline; }
span.inline-Pa { text-decoration: underline; }
@@ -30,6 +32,9 @@
span.inline-Va { text-decoration: underline; }
span.inline-Vt { text-decoration: underline; }
span.inline-Em { font-style: italic; }
+ span.inline-Ft { text-decoration: underline; }
+ span.inline-Fd { font-weight: bolder; }
+ span.inline-Ic { font-weight: bolder; }
span.inline-Op:before { content: '['; }
span.inline-Op:after { content: ']'; }
span.inline-Qq:before { content: '\"'; }
diff --git a/mlg.c b/mlg.c
index 948e93fe..6021589b 100644
--- a/mlg.c
+++ b/mlg.c
@@ -234,6 +234,8 @@ mlg_fmt(int tok)
"is returned and the global variable "
"<span class=\"inline-Va\">errno</span> "
"is set to indicate the error.");
+ case (ROFF_In):
+ return("#include &lt;%s&gt;");
default:
break;
}
@@ -614,6 +616,52 @@ mlg_roffspecial(void *arg, int tok, const char *start,
break;
}
+ /*
+ * Handle macros put into different-token tags.
+ */
+
+ switch (tok) {
+ case (ROFF_Fn):
+ assert(*more);
+ if ( ! mlg_begintag(p, MD_NS_INLINE, tok, NULL, more))
+ return(0);
+ if ( ! ml_putstring(p->mbuf, *more++, &p->pos))
+ return(0);
+ if ( ! mlg_endtag(p, MD_NS_INLINE, tok))
+ return(0);
+ if (*more) {
+ if ( ! ml_nputs(p->mbuf, "(", 1, &p->pos))
+ return(0);
+ p->flags |= ML_OVERRIDE_ONE;
+ if ( ! mlg_begintag(p, MD_NS_INLINE,
+ ROFF_Fa, NULL, more))
+ return(0);
+ if ( ! ml_putstring(p->mbuf, *more++, &p->pos))
+ return(0);
+ if ( ! mlg_endtag(p, MD_NS_INLINE, ROFF_Fa))
+ return(0);
+ while (*more) {
+ if ( ! ml_nputs(p->mbuf, ", ", 2, &p->pos))
+ return(0);
+ if ( ! mlg_begintag(p, MD_NS_INLINE, ROFF_Fa, NULL, more))
+ return(0);
+ if ( ! ml_putstring(p->mbuf, *more++, &p->pos))
+ return(0);
+ if ( ! mlg_endtag(p, MD_NS_INLINE, ROFF_Fa))
+ return(0);
+ }
+ if ( ! ml_nputs(p->mbuf, ")", 1, &p->pos))
+ return(0);
+ }
+ return(1);
+ default:
+ break;
+ }
+
+ /*
+ * Now handle macros in their environments.
+ */
+
if ( ! mlg_begintag(p, MD_NS_INLINE, tok, NULL, more))
return(0);
@@ -656,15 +704,18 @@ mlg_roffspecial(void *arg, int tok, const char *start,
/* FALLTHROUGH */
case (ROFF_Nm):
assert(*more);
- if ( ! ml_puts(p->mbuf, *more++, &p->pos))
+ if ( ! ml_putstring(p->mbuf, *more++, &p->pos))
return(0);
assert(NULL == *more);
break;
-
+
+ case (ROFF_In):
+ /* NOTREACHED */
case (ROFF_Ex):
/* NOTREACHED */
case (ROFF_Rv):
assert(*more);
+ /* FIXME: *more must be ml-filtered. */
(void)snprintf(buf, sizeof(buf),
mlg_fmt(tok), *more++);
if ( ! ml_puts(p->mbuf, buf, &p->pos))
diff --git a/roff.c b/roff.c
index 6c45e8be..cc09d8f6 100644
--- a/roff.c
+++ b/roff.c
@@ -640,6 +640,13 @@ roffspecial(struct rofftree *tree, int tok, const char *start,
break;
roff_err(tree, start, "invalid `At' arg");
return(0);
+
+ case (ROFF_Fn):
+ if (0 != sz)
+ break;
+ roff_err(tree, start, "`%s' expects at least "
+ "one arg", toknames[tok]);
+ return(0);
case (ROFF_Nm):
if (0 == sz) {
@@ -1201,9 +1208,11 @@ roff_ordered(ROFFCALL_ARGS)
if ( ! roffparseopts(tree, tok, &argv, argcp, argvp))
return(0);
- if (NULL == *argv)
+ if (NULL == *argv) {
+ ordp[0] = NULL;
return(roffspecial(tree, tok, p, argcp,
(const char **)argvp, 0, ordp));
+ }
i = 0;
while (*argv && i < ROFF_MAXLINEARG) {
@@ -1281,6 +1290,8 @@ roff_text(ROFFCALL_ARGS)
* terminating punctuation. If we encounter it and all
* subsequent tokens are punctuation, then stop processing (the
* line-dominant macro will print these tokens after closure).
+ * If the punctuation is followed by non-punctuation, then close
+ * and re-open our scope, then continue.
*/
i = 0;
@@ -1312,8 +1323,20 @@ roff_text(ROFFCALL_ARGS)
break;
if (argv[j]) {
+ if (ROFF_LSCOPE & tokens[tok].flags) {
+ if ( ! roffdata(tree, 0, *argv++))
+ return(0);
+ continue;
+ }
+ if ( ! (*tree->cb.roffout)(tree->arg, tok))
+ return(0);
if ( ! roffdata(tree, 0, *argv++))
return(0);
+ if ( ! (*tree->cb.roffin)(tree->arg, tok,
+ argcp, argvp))
+ return(0);
+
+ i = 0;
continue;
}
diff --git a/roff.h b/roff.h
index 4687ddd1..23b06859 100644
--- a/roff.h
+++ b/roff.h
@@ -111,27 +111,27 @@ static const struct rofftok tokens[ROFF_MAX] = {
{ roff_noop, NULL, roffparent_El, NULL, ROFF_Bl, ROFF_LAYOUT, 0 }, /* El */
{ roff_layout, NULL, roffparent_It, NULL, ROFF_It, ROFF_LAYOUT, ROFF_PARSED | ROFF_SHALLOW }, /* It */
{ roff_text, NULL, NULL, NULL, 0, ROFF_TEXT, ROFF_PARSED | ROFF_CALLABLE }, /* Ad */ /* FIXME */
- { roff_text, roffarg_An, NULL, NULL, 0, ROFF_TEXT, ROFF_PARSED }, /* An */
- { roff_text, NULL, NULL, NULL, 0, ROFF_TEXT, ROFF_PARSED | ROFF_CALLABLE }, /* Ar */
- { roff_text, NULL, NULL, NULL, 0, ROFF_TEXT, 0 }, /* Cd */ /* XXX man.4 only */
- { roff_text, NULL, NULL, NULL, 0, ROFF_TEXT, ROFF_PARSED | ROFF_CALLABLE }, /* Cm */
- { roff_text, NULL, NULL, NULL, 0, ROFF_TEXT, ROFF_PARSED | ROFF_CALLABLE }, /* Dv */ /* XXX needs arg */
- { roff_text, NULL, NULL, NULL, 0, ROFF_TEXT, ROFF_PARSED | ROFF_CALLABLE }, /* Er */ /* XXX needs arg */
- { roff_text, NULL, NULL, NULL, 0, ROFF_TEXT, ROFF_PARSED | ROFF_CALLABLE }, /* Ev */ /* XXX needs arg */
- {roff_ordered, roffarg_Ex, NULL, NULL, 0, ROFF_TEXT, 0 }, /* Ex */
- { roff_text, NULL, NULL, NULL, 0, ROFF_TEXT, ROFF_PARSED | ROFF_CALLABLE }, /* Fa */ /* XXX needs arg */
- { roff_text, NULL, NULL, NULL, 0, ROFF_TEXT, 0 }, /* Fd */
- { roff_text, NULL, NULL, NULL, 0, ROFF_TEXT, ROFF_PARSED | ROFF_CALLABLE }, /* Fl */
- {roff_ordered, NULL, NULL, NULL, 0, ROFF_TEXT, /*XXX*/ -1 }, /* Fn */
- { roff_text, NULL, NULL, NULL, 0, ROFF_TEXT, ROFF_PARSED }, /* Ft */
- { roff_text, NULL, NULL, NULL, 0, ROFF_TEXT, ROFF_PARSED | ROFF_CALLABLE }, /* Ic */ /* XXX needs arg */
- { roff_text, NULL, NULL, NULL, 0, ROFF_TEXT, 0 }, /* In */
- { roff_text, NULL, NULL, NULL, 0, ROFF_TEXT, ROFF_PARSED | ROFF_CALLABLE }, /* Li */
- { roff_text, NULL, NULL, NULL, 0, ROFF_TEXT, 0 }, /* Nd */
- {roff_ordered, NULL, NULL, NULL, 0, ROFF_TEXT, ROFF_PARSED | ROFF_CALLABLE }, /* Nm */
- { roff_text, NULL, NULL, NULL, 0, ROFF_TEXT, ROFF_PARSED | ROFF_CALLABLE | ROFF_LSCOPE }, /* Op */
- { roff_depr, NULL, NULL, NULL, 0, ROFF_TEXT, 0 }, /* Ot */
- { roff_text, NULL, NULL, NULL, 0, ROFF_TEXT, ROFF_PARSED | ROFF_CALLABLE }, /* Pa */
+ { roff_text, roffarg_An, NULL, NULL, 0, ROFF_TEXT, ROFF_PARSED }, /* An */ /* FIXME: no-args? */
+/*Ok*/ { roff_text, NULL, NULL, NULL, 0, ROFF_TEXT, ROFF_PARSED | ROFF_CALLABLE }, /* Ar */
+/*Ok*/ { roff_text, NULL, NULL, NULL, 0, ROFF_TEXT, 0 }, /* Cd */ /* FIXME: section. */
+/*Ok*/ { roff_text, NULL, NULL, NULL, 0, ROFF_TEXT, ROFF_PARSED | ROFF_CALLABLE }, /* Cm */
+/*Ok*/ { roff_text, NULL, NULL, NULL, 0, ROFF_TEXT, ROFF_PARSED | ROFF_CALLABLE }, /* Dv */ /* XXX needs arg */
+/*Ok*/ { roff_text, NULL, NULL, NULL, 0, ROFF_TEXT, ROFF_PARSED | ROFF_CALLABLE }, /* Er */ /* XXX needs arg */ /* FIXME: section. */
+/*Ok*/ { roff_text, NULL, NULL, NULL, 0, ROFF_TEXT, ROFF_PARSED | ROFF_CALLABLE }, /* Ev */ /* XXX needs arg */
+/*Ok*/ {roff_ordered, roffarg_Ex, NULL, NULL, 0, ROFF_TEXT, 0 }, /* Ex */ /* FIXME: sections. */
+ {roff_ordered, NULL, NULL, NULL, 0, ROFF_TEXT, ROFF_PARSED | ROFF_CALLABLE }, /* Fa */ /* XXX needs arg */
+/*Ok*/ { roff_text, NULL, NULL, NULL, 0, ROFF_TEXT, 0 }, /* Fd */ /* FIXME: section/linebreak. */
+/*Ok*/ { roff_text, NULL, NULL, NULL, 0, ROFF_TEXT, ROFF_PARSED | ROFF_CALLABLE }, /* Fl */
+/*Ok*/ {roff_ordered, NULL, NULL, NULL, 0, ROFF_TEXT, ROFF_PARSED | ROFF_CALLABLE }, /* Fn */ /* FIXME: section/linebreak. */
+/*Ok*/ { roff_text, NULL, NULL, NULL, 0, ROFF_TEXT, ROFF_PARSED }, /* Ft */ /* FIXME: section/linebreak. */
+/*Ok*/ { roff_text, NULL, NULL, NULL, 0, ROFF_TEXT, ROFF_PARSED | ROFF_CALLABLE }, /* Ic */ /* FIXME: needs arg */
+/*Ok*/ {roff_ordered, NULL, NULL, NULL, 0, ROFF_TEXT, 0 }, /* In */ /* FIXME: section/linebreak. */
+/*OK*/ { roff_text, NULL, NULL, NULL, 0, ROFF_TEXT, ROFF_PARSED | ROFF_CALLABLE }, /* Li */
+/*Ok*/ { roff_text, NULL, NULL, NULL, 0, ROFF_TEXT, 0 }, /* Nd */ /* FIXME: section. */
+/*Ok*/ {roff_ordered, NULL, NULL, NULL, 0, ROFF_TEXT, ROFF_PARSED | ROFF_CALLABLE }, /* Nm */ /* FIXME: sections. */
+/*Ok*/ { roff_text, NULL, NULL, NULL, 0, ROFF_TEXT, ROFF_PARSED | ROFF_CALLABLE | ROFF_LSCOPE }, /* Op */
+/*Ok*/ { roff_depr, NULL, NULL, NULL, 0, ROFF_TEXT, 0 }, /* Ot */
+/*Ok*/ { roff_text, NULL, NULL, NULL, 0, ROFF_TEXT, ROFF_PARSED | ROFF_CALLABLE }, /* Pa */
/*Ok*/ {roff_ordered, roffarg_Rv, NULL, NULL, 0, ROFF_TEXT, 0 }, /* Rv */
/*Ok*/ {roff_ordered, roffarg_St, NULL, NULL, 0, ROFF_TEXT, ROFF_PARSED | ROFF_CALLABLE }, /* St */
/*Ok*/ { roff_text, NULL, NULL, NULL, 0, ROFF_TEXT, ROFF_PARSED | ROFF_CALLABLE }, /* Va */