aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mandoc.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2011-10-24 20:30:57 +0000
committerIngo Schwarze <schwarze@openbsd.org>2011-10-24 20:30:57 +0000
commitc079e75b0cd4178c6a18f1e0aa6c6843f8c85438 (patch)
treebe8aadd15fe7126d9fd00233e864a2018fe83a71 /mandoc.c
parent3e8d323f254c6e5d369fed97c845b79131d36e76 (diff)
downloadmandoc-c079e75b0cd4178c6a18f1e0aa6c6843f8c85438.tar.gz
mandoc-c079e75b0cd4178c6a18f1e0aa6c6843f8c85438.tar.zst
mandoc-c079e75b0cd4178c6a18f1e0aa6c6843f8c85438.zip
Handle \N numbered character escapes the same way as groff:
If \N is followed by a digit, ignore \N and the digit. If \N is followed by a non-digit, the next non-digit ends the character number; the two delimiters need not match. Kristaps calls that "gross, but not our fault". For now, i'm fixing \N only. Other escapes taking numeric arguments may or may not need similar handling, but \N is by far the most important for practical purposes. ok kristaps@
Diffstat (limited to 'mandoc.c')
-rw-r--r--mandoc.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/mandoc.c b/mandoc.c
index 42bc8abc..9fdf9f98 100644
--- a/mandoc.c
+++ b/mandoc.c
@@ -1,4 +1,4 @@
-/* $Id: mandoc.c,v 1.59 2011/09/18 14:14:15 schwarze Exp $ */
+/* $Id: mandoc.c,v 1.60 2011/10/24 20:30:57 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -161,8 +161,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)
@@ -222,10 +221,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 */
@@ -241,6 +237,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.
*/