aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mlg.c
diff options
context:
space:
mode:
Diffstat (limited to 'mlg.c')
-rw-r--r--mlg.c57
1 files changed, 54 insertions, 3 deletions
diff --git a/mlg.c b/mlg.c
index db38ca00..bb0b5514 100644
--- a/mlg.c
+++ b/mlg.c
@@ -1,4 +1,4 @@
-/* $Id: mlg.c,v 1.17 2008/12/07 14:38:57 kristaps Exp $ */
+/* $Id: mlg.c,v 1.18 2008/12/07 16:41:04 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -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))