* mdocml: Handle nested, recursive mathematical subexpressions.
@ 2010-08-24 13:56 kristaps
0 siblings, 0 replies; only message in thread
From: kristaps @ 2010-08-24 13:56 UTC (permalink / raw)
To: source
Log Message:
-----------
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).
Modified Files:
--------------
mdocml:
mandoc.c
out.c
Revision Data
-------------
Index: mandoc.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandoc.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -Lmandoc.c -Lmandoc.c -u -p -r1.32 -r1.33
--- mandoc.c
+++ 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;
Index: out.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/out.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -Lout.c -Lout.c -u -p -r1.27 -r1.28
--- out.c
+++ out.c
@@ -279,6 +279,26 @@ a2roffdeco(enum roffdeco *d, const char
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;
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-08-24 13:56 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-24 13:56 mdocml: Handle nested, recursive mathematical subexpressions kristaps
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).