X-Git-Url: https://git.cameronkatri.com/mandoc.git/blobdiff_plain/d99e0a75f565996f4d42d4f40627fc4951d4e98c..9c1eaf47face65f05d12c1991f19a92789b433fc:/mandoc.c?ds=sidebyside diff --git a/mandoc.c b/mandoc.c index 78b2967d..56a187de 100644 --- a/mandoc.c +++ b/mandoc.c @@ -1,4 +1,4 @@ -/* $Id: mandoc.c,v 1.32 2010/08/24 13:39:37 kristaps Exp $ */ +/* $Id: mandoc.c,v 1.35 2010/09/04 20:18:53 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons * @@ -59,8 +59,6 @@ mandoc_special(char *p) /* FALLTHROUGH */ case ('R'): /* FALLTHROUGH */ - case ('o'): - /* FALLTHROUGH */ case ('N'): /* FALLTHROUGH */ case ('l'): @@ -128,6 +126,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,10 +191,14 @@ 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; + case ('o'): + /* FALLTHROUGH */ case ('w'): if ('\'' == *p++) { term = '\''; @@ -210,7 +233,7 @@ mandoc_calloc(size_t num, size_t size) ptr = calloc(num, size); if (NULL == ptr) { perror(NULL); - exit(MANDOCLEVEL_SYSERR); + exit((int)MANDOCLEVEL_SYSERR); } return(ptr); @@ -225,7 +248,7 @@ mandoc_malloc(size_t size) ptr = malloc(size); if (NULL == ptr) { perror(NULL); - exit(MANDOCLEVEL_SYSERR); + exit((int)MANDOCLEVEL_SYSERR); } return(ptr); @@ -239,7 +262,7 @@ mandoc_realloc(void *ptr, size_t size) ptr = realloc(ptr, size); if (NULL == ptr) { perror(NULL); - exit(MANDOCLEVEL_SYSERR); + exit((int)MANDOCLEVEL_SYSERR); } return(ptr); @@ -254,7 +277,7 @@ mandoc_strdup(const char *ptr) p = strdup(ptr); if (NULL == p) { perror(NULL); - exit(MANDOCLEVEL_SYSERR); + exit((int)MANDOCLEVEL_SYSERR); } return(p);