-/* $Id: mandoc.c,v 1.30 2010/08/24 12:18:48 kristaps Exp $ */
+/* $Id: mandoc.c,v 1.35 2010/09/04 20:18:53 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
*
/* FALLTHROUGH */
case ('x'):
/* FALLTHROUGH */
- case ('w'):
- /* FALLTHROUGH */
case ('S'):
/* FALLTHROUGH */
case ('R'):
/* FALLTHROUGH */
- case ('o'):
- /* FALLTHROUGH */
case ('N'):
/* FALLTHROUGH */
case ('l'):
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'):
/* FALLTHROUGH */
case ('n'):
/* FALLTHROUGH */
+#endif
case ('k'):
/* FALLTHROUGH */
-#endif
case ('M'):
/* FALLTHROUGH */
case ('m'):
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 = '\'';
+ break;
+ }
+ /* FALLTHROUGH */
default:
len = 1;
p--;
ptr = calloc(num, size);
if (NULL == ptr) {
perror(NULL);
- exit(MANDOCLEVEL_SYSERR);
+ exit((int)MANDOCLEVEL_SYSERR);
}
return(ptr);
ptr = malloc(size);
if (NULL == ptr) {
perror(NULL);
- exit(MANDOCLEVEL_SYSERR);
+ exit((int)MANDOCLEVEL_SYSERR);
}
return(ptr);
ptr = realloc(ptr, size);
if (NULL == ptr) {
perror(NULL);
- exit(MANDOCLEVEL_SYSERR);
+ exit((int)MANDOCLEVEL_SYSERR);
}
return(ptr);
p = strdup(ptr);
if (NULL == p) {
perror(NULL);
- exit(MANDOCLEVEL_SYSERR);
+ exit((int)MANDOCLEVEL_SYSERR);
}
return(p);