From ada69bce757bdb8fff8d778e0660446c440c7613 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Wed, 29 Oct 2014 00:17:43 +0000 Subject: In terminal output, unify handling of Unicode and numbered character escape sequences just like it was earlier implemented for -Thtml. Do not let control characters other than ASCII 9 (horizontal tab) propagate to the output, even though groff allows them; but that really doesn't look like a great idea. Let mchars_num2char() return int such that we can distinguish invalid \N syntax from \N'0'. This also reduces the danger of signed char issues popping up. --- chars.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'chars.c') diff --git a/chars.c b/chars.c index 237fbe25..fe0b17de 100644 --- a/chars.c +++ b/chars.c @@ -1,4 +1,4 @@ -/* $Id: chars.c,v 1.64 2014/10/28 17:36:19 schwarze Exp $ */ +/* $Id: chars.c,v 1.65 2014/10/29 00:17:43 schwarze Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons * Copyright (c) 2011, 2014 Ingo Schwarze @@ -107,15 +107,13 @@ mchars_spec2cp(const struct mchars *arg, const char *p, size_t sz) return(ln != NULL ? ln->unicode : sz == 1 ? (unsigned char)*p : -1); } -char +int mchars_num2char(const char *p, size_t sz) { int i; - if ((i = mandoc_strntoi(p, sz, 10)) < 0) - return('\0'); - - return(i > 0 && i < 256 && isprint(i) ? i : '\0'); + i = mandoc_strntoi(p, sz, 10); + return(i >= 0 && i < 256 ? i : -1); } int -- cgit v1.2.3-56-ge451