summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/mandoc/chars.c15
-rw-r--r--usr.bin/mandoc/mandoc.h3
-rw-r--r--usr.bin/mandoc/term_ascii.c8
3 files changed, 21 insertions, 5 deletions
diff --git a/usr.bin/mandoc/chars.c b/usr.bin/mandoc/chars.c
index 8135c8d0ba1..961769c80f0 100644
--- a/usr.bin/mandoc/chars.c
+++ b/usr.bin/mandoc/chars.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: chars.c,v 1.30 2014/10/26 17:11:18 schwarze Exp $ */
+/* $OpenBSD: chars.c,v 1.31 2014/10/26 18:06:28 schwarze Exp $ */
/*
* Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011, 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -15,6 +15,8 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#include <sys/types.h>
+
#include <assert.h>
#include <ctype.h>
#include <stdlib.h>
@@ -145,6 +147,17 @@ mchars_spec2str(const struct mchars *arg,
return(ln->ascii);
}
+const char *
+mchars_uc2str(int uc)
+{
+ int i;
+
+ for (i = 0; i < LINES_MAX; i++)
+ if (uc == lines[i].unicode)
+ return(lines[i].ascii);
+ return("<?>");
+}
+
static const struct ln *
find(const struct mchars *tab, const char *p, size_t sz)
{
diff --git a/usr.bin/mandoc/mandoc.h b/usr.bin/mandoc/mandoc.h
index 2512e8b11d3..db71dcd8129 100644
--- a/usr.bin/mandoc/mandoc.h
+++ b/usr.bin/mandoc/mandoc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mandoc.h,v 1.107 2014/10/20 19:21:31 schwarze Exp $ */
+/* $OpenBSD: mandoc.h,v 1.108 2014/10/26 18:06:28 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -424,6 +424,7 @@ enum mandoc_esc mandoc_escape(const char **, const char **, int *);
struct mchars *mchars_alloc(void);
void mchars_free(struct mchars *);
char mchars_num2char(const char *, size_t);
+const char *mchars_uc2str(int);
int mchars_num2uc(const char *, size_t);
int mchars_spec2cp(const struct mchars *,
const char *, size_t);
diff --git a/usr.bin/mandoc/term_ascii.c b/usr.bin/mandoc/term_ascii.c
index 8fbb398d1ee..333bb2c1ac9 100644
--- a/usr.bin/mandoc/term_ascii.c
+++ b/usr.bin/mandoc/term_ascii.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: term_ascii.c,v 1.22 2014/10/26 17:11:18 schwarze Exp $ */
+/* $OpenBSD: term_ascii.c,v 1.23 2014/10/26 18:06:28 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
@@ -325,9 +325,11 @@ ascii_uc2str(int uc)
"j", "DZ", "D", "dz", "G", "g", "HV", "W",
"N", "n", "A", "a", "AE", "ae", "O", "o"};
- if (uc < 0 || (size_t)uc >= sizeof(tab)/sizeof(tab[0]))
+ if (uc < 0)
return("<?>");
- return(tab[uc]);
+ if ((size_t)uc < sizeof(tab)/sizeof(tab[0]))
+ return(tab[uc]);
+ return(mchars_uc2str(uc));
}
static size_t