summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-08-24 13:56:51 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-08-24 13:56:51 +0000
commit4b8b77f4eb349054321581a56bff586160457e68 (patch)
tree71ac3b8dff944e6df781504e3797a4323e0613f8
parentc161c4dd10ba225a35fed081c68ad54b6fa225cb (diff)
downloadmandoc-4b8b77f4eb349054321581a56bff586160457e68.tar.gz
Handle nested, recursive mathematical subexpressions. This is
definitely not general, but it's good enough for pod2man definitions (after I clean up the roff, which will be addressed in later fixes).
-rw-r--r--mandoc.c25
-rw-r--r--out.c20
2 files changed, 44 insertions, 1 deletions
diff --git a/mandoc.c b/mandoc.c
index 9ff748ea..c93ec25d 100644
--- a/mandoc.c
+++ b/mandoc.c
@@ -128,6 +128,27 @@ mandoc_special(char *p)
p++;
}
+ /* Handle embedded numerical subexp or escape. */
+
+ if ('(' == *p) {
+ while (*p && ')' != *p)
+ if ('\\' == *p++) {
+ i = mandoc_special(--p);
+ if (0 == i)
+ return(0);
+ p += i;
+ }
+
+ if (')' == *p++)
+ break;
+
+ return(0);
+ } else if ('\\' == *p) {
+ if (0 == (i = mandoc_special(p)))
+ return(0);
+ p += i;
+ }
+
break;
#if 0
case ('Y'):
@@ -172,7 +193,9 @@ mandoc_special(char *p)
case ('z'):
len = 1;
if ('\\' == *p) {
- p += mandoc_special(p);
+ if (0 == (i = mandoc_special(p)))
+ return(0);
+ p += i;
return(*p ? (int)(p - sv) : 0);
}
break;
diff --git a/out.c b/out.c
index d1a9e79d..99288f57 100644
--- a/out.c
+++ b/out.c
@@ -279,6 +279,26 @@ a2roffdeco(enum roffdeco *d, const char **word, size_t *sz)
i++;
}
+ /* Handle embedded numerical subexp or escape. */
+
+ if ('(' == wp[i]) {
+ while (wp[i] && ')' != wp[i])
+ if ('\\' == wp[i++]) {
+ /* Handle embedded escape. */
+ *word = &wp[i];
+ i += a2roffdeco(&dd, word, sz);
+ }
+
+ if (')' == wp[i++])
+ break;
+
+ *d = DECO_NONE;
+ return(i - 1);
+ } else if ('\\' == wp[i]) {
+ *word = &wp[++i];
+ i += a2roffdeco(&dd, word, sz);
+ }
+
break;
case ('['):
*d = DECO_SPECIAL;