From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from krisdoz.my.domain (kristaps@localhost [127.0.0.1]) by krisdoz.my.domain (8.14.3/8.14.3) with ESMTP id o7ODuqUX020206 for ; Tue, 24 Aug 2010 09:56:52 -0400 (EDT) Received: (from kristaps@localhost) by krisdoz.my.domain (8.14.3/8.14.3/Submit) id o7ODuqUj004220; Tue, 24 Aug 2010 09:56:52 -0400 (EDT) Date: Tue, 24 Aug 2010 09:56:52 -0400 (EDT) Message-Id: <201008241356.o7ODuqUj004220@krisdoz.my.domain> X-Mailinglist: mdocml-source Reply-To: source@mdocml.bsd.lv MIME-Version: 1.0 From: kristaps@mdocml.bsd.lv To: source@mdocml.bsd.lv Subject: mdocml: Handle nested, recursive mathematical subexpressions. X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 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