diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2010-08-24 13:56:51 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2010-08-24 13:56:51 +0000 |
commit | 92d36306307652f916347656b5c31928db651c45 (patch) | |
tree | 42c414f7d6f8442b851bfc7b4916ccc14808d38a /mandoc.c | |
parent | d99e0a75f565996f4d42d4f40627fc4951d4e98c (diff) | |
download | mandoc-92d36306307652f916347656b5c31928db651c45.tar.gz mandoc-92d36306307652f916347656b5c31928db651c45.tar.zst mandoc-92d36306307652f916347656b5c31928db651c45.zip |
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).
Diffstat (limited to 'mandoc.c')
-rw-r--r-- | mandoc.c | 27 |
1 files changed, 25 insertions, 2 deletions
@@ -1,4 +1,4 @@ -/* $Id: mandoc.c,v 1.32 2010/08/24 13:39:37 kristaps Exp $ */ +/* $Id: mandoc.c,v 1.33 2010/08/24 13:56:51 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv> * @@ -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; |