summaryrefslogtreecommitdiffstats
path: root/out.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2011-01-30 16:05:37 +0000
committerIngo Schwarze <schwarze@openbsd.org>2011-01-30 16:05:37 +0000
commit45f655402ed9aece7ea3dfffb8007a8c753d6f4a (patch)
treea5347280c09b16427b521363bd2553cffd890bf8 /out.c
parent640a3cb4e4b0817868c63e57d68bbbf3229fb254 (diff)
downloadmandoc-45f655402ed9aece7ea3dfffb8007a8c753d6f4a.tar.gz
Implement the \N'number' (numbered character) roff escape sequence.
Don't use it in new manuals, it is inherently non-portable, but we need it for backward-compatibility with existing manuals, for example in Xenocara driver pages. ok kristaps@ jmc@ and tested by Matthieu Herrb (matthieu at openbsd dot org)
Diffstat (limited to 'out.c')
-rw-r--r--out.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/out.c b/out.c
index d76a9702..be54abcd 100644
--- a/out.c
+++ b/out.c
@@ -1,6 +1,7 @@
/* $Id$ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
+ * Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -251,6 +252,49 @@ a2roffdeco(enum roffdeco *d, const char **word, size_t *sz)
break;
}
break;
+
+ case ('N'):
+
+ /*
+ * Sequence of characters: backslash, 'N' (i = 0),
+ * starting delimiter (i = 1), character number (i = 2).
+ */
+
+ *word = wp + 2;
+ *sz = 0;
+
+ /*
+ * Cannot use a digit as a starting delimiter;
+ * but skip the digit anyway.
+ */
+
+ if (isdigit((int)wp[1]))
+ return(2);
+
+ /*
+ * Any non-digit terminates the character number.
+ * That is, the terminating delimiter need not
+ * match the starting delimiter.
+ */
+
+ for (i = 2; isdigit((int)wp[i]); i++)
+ (*sz)++;
+
+ /*
+ * This is only a numbered character
+ * if the character number has at least one digit.
+ */
+
+ if (*sz)
+ *d = DECO_NUMBERED;
+
+ /*
+ * Skip the terminating delimiter, even if it does not
+ * match, and even if there is no character number.
+ */
+
+ return(++i);
+
case ('h'):
/* FALLTHROUGH */
case ('v'):