aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/chars.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-05-01 08:38:56 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-05-01 08:38:56 +0000
commitf5b3942475d0ba43d54201c60e42f0ad657a11f9 (patch)
treef67aa9c044806b6dbaaefd8fa3887622c0cd64d6 /chars.c
parent4ac5d826a7fc322e357b1f87a58616c3ed2a3c5f (diff)
downloadmandoc-f5b3942475d0ba43d54201c60e42f0ad657a11f9.tar.gz
mandoc-f5b3942475d0ba43d54201c60e42f0ad657a11f9.tar.zst
mandoc-f5b3942475d0ba43d54201c60e42f0ad657a11f9.zip
Filter all \N'' values with isprint(). Ok schwarze@.
Diffstat (limited to 'chars.c')
-rw-r--r--chars.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/chars.c b/chars.c
index e4f742d9..c33dedcf 100644
--- a/chars.c
+++ b/chars.c
@@ -1,4 +1,4 @@
-/* $Id: chars.c,v 1.39 2011/04/30 22:24:31 kristaps Exp $ */
+/* $Id: chars.c,v 1.40 2011/05/01 08:38:56 kristaps Exp $ */
/*
* Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -20,6 +20,7 @@
#endif
#include <assert.h>
+#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -135,9 +136,11 @@ mchars_res2cp(struct mchars *arg, const char *p, size_t sz)
return(ln->unicode);
}
-
/*
* Numbered character to literal character.
+ * This can only be a printable character (i.e., alnum, punct, space) so
+ * prevent the character from ruining our state (backspace, newline, and
+ * so on).
*/
char
mchars_num2char(const char *p, size_t sz)
@@ -148,15 +151,9 @@ mchars_num2char(const char *p, size_t sz)
return('\0');
i = atoi(p);
- /*
- * FIXME:
- * This is wrong. Anything could be written here!
- * This should be carefully screened for possible characters.
- */
- return(i <= 0 || i > 255 ? '\0' : (char)i);
+ return(isprint(i) ? (char)i : '\0');
}
-
/*
* Special character to string array.
*/
@@ -173,7 +170,6 @@ mchars_spec2str(struct mchars *arg, const char *p, size_t sz, size_t *rsz)
return(ln->ascii);
}
-
/*
* Reserved word to string array.
*/