summaryrefslogtreecommitdiff
path: root/usr.bin/mandoc/mandoc.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/mandoc/mandoc.c')
-rw-r--r--usr.bin/mandoc/mandoc.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/usr.bin/mandoc/mandoc.c b/usr.bin/mandoc/mandoc.c
index e816496638b..716940f257c 100644
--- a/usr.bin/mandoc/mandoc.c
+++ b/usr.bin/mandoc/mandoc.c
@@ -1,4 +1,4 @@
-/* $Id: mandoc.c,v 1.28 2011/09/18 15:54:48 schwarze Exp $ */
+/* $Id: mandoc.c,v 1.29 2011/10/24 20:29:21 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -157,8 +157,7 @@ mandoc_escape(const char **end, const char **start, int *sz)
case ('V'):
/* FALLTHROUGH */
case ('Y'):
- if (ESCAPE_ERROR == gly)
- gly = ESCAPE_IGNORE;
+ gly = ESCAPE_IGNORE;
/* FALLTHROUGH */
case ('f'):
if (ESCAPE_ERROR == gly)
@@ -218,10 +217,7 @@ mandoc_escape(const char **end, const char **start, int *sz)
case ('L'):
/* FALLTHROUGH */
case ('l'):
- /* FALLTHROUGH */
- case ('N'):
- if (ESCAPE_ERROR == gly)
- gly = ESCAPE_NUMBERED;
+ gly = ESCAPE_NUMBERED;
/* FALLTHROUGH */
case ('S'):
/* FALLTHROUGH */
@@ -237,6 +233,26 @@ mandoc_escape(const char **end, const char **start, int *sz)
term = numeric = '\'';
break;
+ /*
+ * Special handling for the numbered character escape.
+ * XXX Do any other escapes need similar handling?
+ */
+ case ('N'):
+ if ('\0' == cp[i])
+ return(ESCAPE_ERROR);
+ *end = &cp[++i];
+ if (isdigit((unsigned char)cp[i-1]))
+ return(ESCAPE_IGNORE);
+ while (isdigit((unsigned char)**end))
+ (*end)++;
+ if (start)
+ *start = &cp[i];
+ if (sz)
+ *sz = *end - &cp[i];
+ if ('\0' != **end)
+ (*end)++;
+ return(ESCAPE_NUMBERED);
+
/*
* Sizes get a special category of their own.
*/